Support » Plugin: Widget Content Blocks » Feature request (a simple link)

  • This is so good.

    I wish where was a link on the widget that could lead user to the selected “widget block” edit page, not only list for all of them.

    demo

    • This topic was modified 2 years, 7 months ago by  garfield.ir. Reason: wrong image
Viewing 4 replies - 1 through 4 (of 4 total)
  • That was easy

    
    <p class="help"><?php printf( __( 'Edit widget block: %s', 'wysiwyg-widgets' ), '<a target="_blank" href="' . get_edit_post_link($selected_widget_id) . '">' . $title . '</a>' ); ?></p>
    
    

    I will be thankful if you add it to file “class-widget.php” line 123

    Best Regards

    May I ask you add these lines to the same file at line 48 too ?

    
    if ( current_user_can( 'manage_options' )) {
        echo '<a target="_blank" class="wysiwyg-widgets-edit-link" href="' . get_edit_post_link($id) . '">' . __('Edit Widget Block', 'wysiwyg-widgets') . '</a>';
    }
    

    Hope you forgive me. I tweaked it a little bit. May this will be useful for you too.

    
    @@ -7,13 +7,13 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
     	 */
     	public function __construct() {
     		parent::__construct(
    -			'Widget Blocks Widget', // Name
    +			__('Widget Blocks Widget', 'wysiwyg-widgets'), // Name
     			array( 'description' => __('Displays one of your Widget Blocks.', 'wysiwyg-widgets') ) // Args
     		);
     	}
    
    @@ -27,10 +27,9 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
     		$show_title = (isset($instance['show_title'])) ? $instance['show_title'] : 1;
     		$post = get_post( $id );
     
    -		echo $args['before_widget'];
    -
    -		if( ! empty( $id ) && $post ) {
    +
    +		if( ! empty( $id ) && $post && ! empty( $post->post_content ) ) {
    +			echo $args['before_widget'];
     			// Allow filtering of content
     			$content = apply_filters( 'ww_content', $post->post_content, $id );
     
    @@ -45,6 +44,12 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
     			}
     
     			echo $content;
    +
    +			if ( current_user_can( 'manage_options' )) {
    +				echo '<a target="_blank" class="wysiwyg-widgets-edit-link" href="' . get_edit_post_link($id) . '">' . __('Edit Widget Block', 'wysiwyg-widgets') . '</a>';
    +			}
    +
    +			echo $args['after_widget'];
     			echo '<!-- / WYSIWYG Widgets -->';
     
     		} elseif( current_user_can( 'manage_options' ) ) { ?>
    @@ -55,11 +60,9 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
     						printf( __( 'No widget block found with ID %d, please select an existing Widget Block in the widget settings.', 'wysiwyg-widgets' ), $id );
     					} ?>
     				</p>
    		<?php
     		}
     
    -		echo $args['after_widget'];
     	}
    
    @@ -96,13 +99,13 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
     
     		$show_title = ( isset( $instance['show_title'] ) ) ? $instance['show_title'] : 1;
     		$selected_widget_id = ( isset( $instance['wysiwyg-widget-id'] ) ) ? $instance['wysiwyg-widget-id'] : 0;
    -		$title = ($selected_widget_id) ? get_the_title( $selected_widget_id ) : 'No widget block selected.';
    +		$title = ($selected_widget_id) ? get_the_title( $selected_widget_id ) : __('No widget block selected.' , 'wysiwyg-widgets' );
     		?>
    
    @@ -120,9 +123,10 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
     		<p>
     			<label><input type="checkbox" id="<?php echo $this->get_field_id( 'show_title' ); ?>" name="<?php echo $this->get_field_name( 'show_title' ); ?>" value="1" <?php checked( $show_title, 1 ); ?> /> <?php _e( "Show title?", "wysiwyg-widgets" ); ?></label>
     		</p>
    +		<p class="help"><?php printf( __( 'Edit widget block: %s', 'wysiwyg-widgets' ), '<a target="_blank" href="' . get_edit_post_link($selected_widget_id) . '">' . $title . '</a>' ); ?></p>
     		<p class="help"><?php printf( __( 'Manage your widget blocks %shere%s', 'wysiwyg-widgets' ), '<a href="'. admin_url( 'edit.php?post_type=wysiwyg-widget' ) .'">', '</a>' ); ?></p>
     		<?php
     	}
    

    Commit 2: fix showing error, ID not exists.

    
    @@ -27,31 +27,39 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
     		$show_title = (isset($instance['show_title'])) ? $instance['show_title'] : 1;
     		$post = get_post( $id );
     
    -		if( ! empty( $id ) && $post && ! empty( $post->post_content ) ) {
    +		if( ! empty( $id ) && $post ) {
    +
    +			if ( ! empty( $post->post_content ) ) {
                echo $args['before_widget'];
    
    @@ -27,31 +27,39 @@ class WYSIWYG_Widgets_Widget extends WP_Widget {
    
    			echo $args['after_widget'];
    			echo '<!-- / WYSIWYG Widgets -->';
    +				
    +			} else {
    +				if ( current_user_can( 'manage_options' ) ) {
    +					echo '<a target="_blank" class="wysiwyg-widgets-edit-link" href="' . get_edit_post_link( $id ) . '">' . __( 'Edit Widget Block',
    +							'wysiwyg-widgets' ) . '</a>';
    +				}
    +			}
    
    • This reply was modified 2 years, 7 months ago by  garfield.ir.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Feature request (a simple link)’ is closed to new replies.