Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1179446

    I have found a solution to a problem. When the User Role Editor Pro theme was activated, the last published page was displayed on all standard pages. https://www.role-editor.com/

    The reason of a problem is not accurate code from your theme Avia_Custom_Pages::handler_hide_special_pages()
    located at enfold/includes/class-avia-custom-pages.php file. It tries to exclude from the listings theme special pages, like footer page. But it make this even for own query which request footer page object, thus WP_Query 2 conflicting parameters at the same time. This code brought a solution:

    'post__in': array( ###id of footerpage### ) and 'post__not_in': array( ###id of footerpage### ). It may work, as WP_Query::get_posts() processes 'post__in' 1st and ignores 'post__not_in' in this case, but
    when you activate URE 'Content view restrictions', URE removes from 'post__in' any ID listed at 'post__not_in' - changes priority, excludes what really should be excluded.
    //---
    
    /**
     * Fixes issue with Avia_Custom_Pages::handler_hide_special_pages(), 
     * which puts footer page ID to 'post__not_in' even for query, which has it at 'post__in'. 
     * URE_Content_View_Restrictions_Posts_Lists::hide_prohibited_posts() respects 'post__not_in' with higher priority than WP_Query does, 
     * so URE apparently excludes prohibited ID from 'post_in'.
     **/
    add_action( 'pre_get_posts', 'avia_fix_hide_special_pages', 11, 1 );
    
    function avia_fix_hide_special_pages( $wp_query ) {
        
        if ( !class_exists( 'Avia_Custom_Pages' ) ) {
            return;
        }
        
        if ( is_admin() ) {
        return;
        }
        
        $post_not_in = $wp_query->get('post__not_in');
        if ( empty( $post_not_in )) {
            return;
        }
        $post_in = $wp_query->get('post__in');
        if ( empty( $post_not_in )) {
            return;
        }
        
        $pages = apply_filters( 'avf_get_special_pages_ids', array(), 'pre_get_posts_filter' );
        if ( empty( $pages ) ) {
           return; 
        }
        
        $modified = false;
        foreach( $post_not_in as $val1 ) {
            if ( !in_array( $val1, $pages ) ) {
                continue;
            }
            foreach( $post_in as $key2=>$val2 ) {
                if ( $val1==$val2 ) {
                    unset( $post_not_in[$key2] );
                    $modified = true;
                }
            }
        }
        
        $wp_query->set( 'post__not_in', $post_not_in );
    }
    // end of avia_fix_hide_special_pages()
    //---

    Maybe there is a way to consider this in a future version.

    Tobias

    #1179931

    Hey Tobias,

    Thanks for reporting this and providing a solution. The fix is merged and will be in next release (4.7.2.1).

    You will find it in enfold\includes\class-avia-custom-pages.php function handler_hide_special_pages().

    Have a great day.

    Best regards,
    Günter

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