gger a 404 process. This method handles such * cases by overriding the $wp_query global to fetch the correct landing page post entry. * * For example, since Landing Pages slugs come directly after the site domain name, WP_Query might parse the post * as a category page. Since there is no category matching the slug, it triggers a 404 process. In this case, we * run a query for a Landing Page post with the passed slug ($query->query['category_name']. If a Landing Page * with the passed slug is found, we override the global $wp_query with the new, correct query. * * @param $current_value * @param $query * @return false */ private function handle_404( $current_value, $query ) { global $wp_query; // If another plugin/theme already used this filter, exit here to avoid conflicts. if ( $current_value ) { return $current_value; } if ( // Make sure we only intervene in the main query. ! $query->is_main_query() // If a post was found, this is not a 404 case, so do not intervene. || ! empty( $query->posts ) // This filter is only meant to deal with wrong queries where the only query var is 'category_name'. // If there is no 'category_name' query var, do not intervene. || empty( $query->query['category_name'] ) // If the query is for a real taxonomy (determined by it including a table to search in, such as the // wp_term_relationships table), do not intervene. || ! empty( $query->tax_query->table_aliases ) ) { return false; } // Search for a Landing Page with the same name passed as the 'category name'. $possible_new_query = new \WP_Query( [ 'no_found_rows' => true, 'post_type' => self::CPT, 'name' => $query->query['category_name'], ] ); // Only if such a Landing Page is found, override the query to fetch the correct page. if ( ! empty( $possible_new_query->posts ) ) { $wp_query = $possible_new_query; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited } return false; } public function __construct() { $this->permalink_structure = get_option( 'permalink_structure' ); $this->register_landing_page_cpt(); // If there is a permalink structure set to the site, run the hooks that modify the Landing Pages permalinks to // match WordPress' native 'Pages' post type. if ( '' !== $this->permalink_structure ) { // Landing Pages' post link needs to be modified to be identical to the pages permalink structure. This // needs to happen in both the admin and the front end, since post links are also used in the admin pages. add_filter( 'post_type_link', function( $post_link, $post, $leavename ) { return $this->remove_post_type_slug( $post_link, $post, $leavename ); }, 10, 3 ); // The query itself only has to be manipulated when pages are viewed in the front end. if ( ! is_admin() || wp_doing_ajax() ) { add_action( 'pre_get_posts', function ( $query ) { $this->adjust_landing_page_query( $query ); } ); // Handle cases where visiting a Landing Page's URL returns 404. add_filter( 'pre_handle_404', function ( $value, $query ) { return $this->handle_404( $value, $query ); }, 10, 2 ); } } add_action( 'elementor/documents/register', function( Documents_Manager $documents_manager ) { $documents_manager->register_document_type( self::DOCUMENT_TYPE, Landing_Page::get_class_full_name() ); } ); if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) { add_action( 'elementor/admin/menu_registered/elementor', function( MainMenu $menu ) { $this->register_admin_menu( $menu ); } ); } else { add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { $this->register_admin_menu_legacy( $admin_menu ); }, Source_Local::ADMIN_MENU_PRIORITY + 20 ); } // Add the custom 'Add New' link for Landing Pages into Elementor's admin config. add_action( 'elementor/admin/localize_settings', function( array $settings ) { return $this->admin_localize_settings( $settings ); } ); add_filter( 'elementor/template_library/sources/local/register_taxonomy_cpts', function( array $cpts ) { $cpts[] = self::CPT; return $cpts; } ); // In the Landing Pages Admin Table page - Overwrite Template type column header title. add_action( 'manage_' . Landing_Pages_Module::CPT . '_posts_columns', function( $posts_columns ) { /** @var Source_Local $source_local */ $source_local = Plugin::$instance->templates_manager->get_source( 'local' ); return $source_local->admin_columns_headers( $posts_columns ); } ); // In the Landing Pages Admin Table page - Overwrite Template type column row values. add_action( 'manage_' . Landing_Pages_Module::CPT . '_posts_custom_column', function( $column_name, $post_id ) { /** @var Landing_Page $document */ $document = Plugin::$instance->documents->get( $post_id ); $document->admin_columns_content( $column_name ); }, 10, 2 ); // Overwrite the Admin Bar's 'New +' Landing Page URL with the link that creates the new LP in Elementor // with the Template Library modal open. add_action( 'admin_bar_menu', function( $admin_bar ) { // Get the Landing Page menu node. $new_landing_page_node = $admin_bar->get_node( 'new-e-landing-page' ); if ( $new_landing_page_node ) { $new_landing_page_node->href = $this->get_add_new_landing_page_url(); $admin_bar->add_node( $new_landing_page_node ); } }, 100 ); } }
Fatal error: Uncaught Error: Class 'Elementor\Modules\LandingPages\Module' not found in /home/sportuga/public_html/wp-content/plugins/elementor/core/modules-manager.php:53 Stack trace: #0 /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php(730): Elementor\Core\Modules_Manager->__construct() #1 /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php(647): Elementor\Plugin->init_components() #2 /home/sportuga/public_html/wp-includes/class-wp-hook.php(324): Elementor\Plugin->init('') #3 /home/sportuga/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #4 /home/sportuga/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #5 /home/sportuga/public_html/wp-settings.php(695): do_action('init') #6 /home/sportuga/public_html/wp-config.php(102): require_once('/home/sportuga/...') #7 /home/sportuga/public_html/wp-load.php(50): require_once('/home/sportuga/...') #8 /home/sportuga/public_html/wp-blog-header.php(13): require_once('/home/sportuga/ in /home/sportuga/public_html/wp-content/plugins/elementor/core/modules-manager.php on line 53