Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    Hard to tell without looking at the code or knowing how you implemented the tabbed interface ?? Please share your site’s URL.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey Thomas!

    I need the HTML part as well to know what is what ?? (and please, remember to use the code button to wrap your code).

    Thread Starter stl99

    (@stl99)

    <?php
    
    /* Register tabbed widget areas */
    
    function _tabbed_widget_register_sidebars() {
    
    	$tabbed_widget_theme_support = get_theme_support( 'tabbed-widget' );
    	$tabbed_widget_areas = $tabbed_widget_theme_support[0];
    
    	foreach( $tabbed_widget_areas as $widget_area_id => $widget_area_name ) {
    		register_sidebar( array(
    			'id'   => $widget_area_id,
    			'name' => $widget_area_name
    		) );
    	}
    
    }
    add_action( 'widgets_init', '_tabbed_widget_register_sidebars' );
    
    /* Register tabbed widget scripts */
    
    function _tabbed_widget_register_scripts() {
    
    	wp_register_script( 'tabbed-widget', _CORE_PLUGIN_URL . '/js/tabbed-widget.js', array( 'jquery' ), null, true );
    
    }
    add_action( 'wp_enqueue_scripts', '_tabbed_widget_register_scripts' );
    
    /* Tabbed widget class */
    
    class _tabbed_widget extends WP_Widget {
    
    	function _tabbed_widget() {
    		parent::WP_Widget( false, __( ' Tabbed Widget' ) );
    	}
    
    	function widget( $widget_area_args, $instance ) {
    
    		$widget_area_id = $instance['widget_area_id'];
    		if ( empty( $widget_area_id ) OR ! is_active_sidebar( $widget_area_id ) ) {
    			return;
    		}
    
    		wp_enqueue_script( 'tabbed-widget' );
    
    		echo $widget_area_args['before_widget'];
    
    		add_filter( 'dynamic_sidebar_params', array( &$this, 'dynamic_sidebar_params' ) );
    		dynamic_sidebar( $widget_area_id );
    		remove_filter( 'dynamic_sidebar_params', array( &$this, 'dynamic_sidebar_params' ) );
    
    		echo $widget_area_args['after_widget'];
    
    	}
    
    	function update( $new_instance, $old_instance ) {
    		return array(
    			'widget_area_id' => strip_tags( $new_instance['widget_area_id'] )
    		);
    	}
    
    	function form( $instance ) {
    
    		$current_widget_area_id = isset( $instance['widget_area_id'] ) ? $instance['widget_area_id'] : '';
    
    		$tabbed_widget_theme_support = get_theme_support( 'tabbed-widget' );
    		$tabbed_widget_areas = $tabbed_widget_theme_support[0];
    
    		$select_items = '<option value=""></option>';
    		foreach( $tabbed_widget_areas as $widget_area_id => $widget_area_name ) {
    			$select_items .= sprintf( '<option value="%1$s"%2$s>%3$s</option>',
    				$widget_area_id,
    				selected( $widget_area_id, $current_widget_area_id, false ),
    				$widget_area_name
    			);
    		}
    
    		printf( '<p><label for="%1$s">%2$s:</label> <select id="%1$s" name="%3$s">%4$s</select></p>',
    			$this->get_field_id( 'widget_area_id' ),
    			__( 'Widget area', '' ),
    			$this->get_field_name( 'widget_area_id' ),
    			$select_items
    		);
    
    	}
    
    	function dynamic_sidebar_params( $params ) {
    
    		$params[0]['before_widget'] = '<div id="' . $params[0]['id'] . '_' . $params[0]['widget_id'] . '" class="tabbed-widget-tab widget_' . str_replace( '-', '_', sanitize_title( $params[0]['widget_name'] ) ) . '">';
    		$params[0]['after_widget']  = '</div>';
    		$params[0]['before_title']  = '<a href="#' . $params[0]['id'] . '_' . $params[0]['widget_id'] . '" class="tabbed-widget-tab-header">';
    		$params[0]['after_title']   = '</a>';
    
    		return $params;
    
    	}
    
    }
    add_action( 'widgets_init', create_function( '', 'return register_widget( "_tabbed_widget" );' ) );
    Plugin Author Hector Cabrera

    (@hcabrera)

    So, basically, your widget creates two (or more) dynamic sidebars where other widgets can be placed on.

    I’m pretty sure that the issue isn’t front-end related (at least, not Javascript related) so I have a couple of questions for you:

    • Did you check the error log already?
    • Are you able to drag&drop the WPP widget (or any other widget) in your tabbed widget?
    • What’s the HTML output on the front-end?
    Thread Starter stl99

    (@stl99)

    Yes!

    – no errors so far
    – yes, text widgets and even more advanced widgets from other plugins are displayed fine
    – it seems the part where WPP should execute somehting is empty:

    <div class="widget-wrap">
    <!-- WordPress Popular Posts Plugin v3.3.4 [W] [daily] [views] [custom] [PID] -->
    <div id="tabbed-widget-area-1_wpp-2" class="tabbed-widget-tab widget_wordpress_popular_posts">
    <a href="#tabbed-widget-area-1_wpp-2" class="tabbed-widget-tab-header"><i class="fa fa-line-chart"></i> WPP Widget</a>
    <script type="text/javascript">
    
    					/* jQuery is available, so proceed */
    
    					if ( window.jQuery ) {
    
    						jQuery(document).ready(function($){
    
    							$.get('/wp-admin/admin-ajax.php', {
    
    								action: 'wpp_get_popular',
    
    								id: '2'
    
    							}, function(data){
    
    								$('#wpp-2').append(data);
    
    							});
    
    						});
    
    					} /* jQuery is not defined */
    
    					else {
    
    						if ( window.console && window.console.log ) {
    
    							window.console.log('WordPress Popular Posts: jQuery is not defined!');
    
    						}
    
    					}
    
    </script>
    </div>
    <!-- End WordPress Popular Posts Plugin v3.3.4 -->
    <div id="tabbed-widget-area-1_text-108" class="tabbed-widget-tab widget_text"><a href="#tabbed-widget-area-1_text-108" class="tabbed-widget-tab-header"><i class="fa fa-comments"></i>Text Widget</a><div class="textwidget"><span style="color:#fff">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</span></div>
    </div></div>
    Plugin Author Hector Cabrera

    (@hcabrera)

    Ah, that explains it.

    When the Ajaxify widget feature is on, WPP uses WordPress’ $widget_id to know where to inject the HTML output once the Ajax script is done executing. While WordPress says that the HTML id of the container is wpp-2, your widget says is tabbed-widget-area-1_wpp-2 and so jQuery fails to find the #wpp-2 element and thus the HTML injection doesn’t happen.

    If you disable the Ajaxify widget feature it’ll work just fine… although that’s doesn’t really solve the problem IMHO ??

    Thread Starter stl99

    (@stl99)

    Too bad, it doesn’t seem to work that way then (my host has rather aggressive caching). Would be nice to have it in tabs…

    Anyway – thanks for your support!

    Cheers,
    Thomas

    Plugin Author Hector Cabrera

    (@hcabrera)

    Well, there might be a workaround but you’d have to make a couple of changes in your code. Since the Javascript part was deleted by the moderator I can’t give you specific suggestions though.

    Thread Starter stl99

    (@stl99)

    Would it be OK for you if I contact you via your website’s contact form?

    Cheers,
    Thomas

    Plugin Author Hector Cabrera

    (@hcabrera)

    Yep, that’s why the contact form is there in the first place ??

    Suddenly I have this problem. I have not made any updates:

    Error: cannot ajaxify WordPress Popular Posts on this theme. It’s missing the id attribute on before_widget (see register_sidebar for more).

    How can I fix the problem?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @evangelististefano,

    Your issue actually is different from what the OP reported.

    Please open a new topic so we can discuss it there.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘WPP not loaded in jQuery tabbed widget’ is closed to new replies.