Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3501
    Federico Mariani
    Participant

    Hi,
    in my site i need to restrict widget for category page. Plugin work properly only after editing the file restrict-widgets.php in this way:

    ….
    elseif(is_page()) {
    $found_main = isset($instance[‘rw_opt’][‘pageid_’.$post_id]) ? TRUE : FALSE;

    /* ADDED CODE */
    $post = $wp_query->post;
    $categs= get_the_category( $post->ID );
    $categ = $categs[0];
    $catprop = ‘category_’.$categ->term_id;

    if (isset($instance[‘rw_opt’][$catprop])) {
    $found_main = isset($instance[‘rw_opt’][$catprop]) ? TRUE : FALSE;
    }
    }
    elseif(is_singular())
    {
    $found_main = isset($instance[‘rw_opt’][‘cpt_’.get_post_type($post_id)]) ? TRUE : FALSE;

    if(is_single() && $found_main == FALSE)
    $found_main = isset($instance[‘rw_opt’][‘others_single_post’]) ? TRUE : FALSE;

    /* ADDED CODE */
    $post = $wp_query->post;
    $categs= get_the_category( $post->ID );
    $categ = $categs[0];
    $catprop = ‘category_’.$categ->term_id;

    if (isset($instance[‘rw_opt’][$catprop])) {
    $found_main = isset($instance[‘rw_opt’][$catprop]) ? TRUE : FALSE;
    }
    }
    elseif(is_category()) {
    /* ADDED CODE */
    //$found_main = isset($instance[‘rw_opt’][‘category_’.get_query_var(‘cat’)]) ? TRUE : FALSE;
    $post = $wp_query->post;
    $categs= get_the_category( $post->ID );
    $categ = $categs[0];
    $catprop = ‘category_’.$categ->term_id;
    $found_main = isset($instance[‘rw_opt’][$catprop]) ? TRUE : FALSE;
    }

    otherwise the widgets were not filtered.
    It’s right? Any idea?
    Federico

    #3506
    Bartosz
    Keymaster

    Federico, I’m not sure if I undarstand you the right way, but did you try using this filter: http://www.dfactory.eu/docs/restrict-widgets-plugin/filters/rw_display_widget/

    It allows you to do literaly any condition for any widget / page / user etc. according to your needs.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.