Code_Metabox::FIELD_LOCATION === $column_name ) { $location_labels = $this->meta_box->get_location_labels(); if ( isset( $location_labels[ $value ] ) ) { $value = $location_labels[ $value ]; } } echo esc_html( $value ); } else if ( self::ADDITIONAL_COLUMN_INSTANCES === $column_name ) { /** @var Conditions_Manager $conditions_manager */ $conditions_manager = Plugin::instance()->modules_manager->get_modules( 'theme-builder' )->get_conditions_manager(); echo esc_html( implode( ', ', $conditions_manager->get_document_instances( $post_id ) ) ); } } private function get_snippets_by_location( $location ) { return get_posts( [ 'numberposts' => -1, 'post_type' => self::CPT, 'meta_query' => [ [ 'key' => '_elementor_' . Custom_Code_Metabox::FIELD_LOCATION, 'value' => $location, ], ], // Order. 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => '_elementor_' . Custom_Code_Metabox::FIELD_PRIORITY, ] ); } private function print_snippets( $location ) { // Do not print snippets on safe mode. if ( isset( $_REQUEST['elementor-mode'] ) && 'safe' === $_REQUEST['elementor-mode'] ) { return; } $snippets = $this->get_snippets_by_location( $location ); /** @var \ElementorPro\Modules\ThemeBuilder\Module $theme_builder */ $theme_builder = Plugin::instance()->modules_manager->get_modules( 'theme-builder' ); $documents_by_conditions = $theme_builder->get_conditions_manager()->get_documents_for_location( $location ); $location_manager = $theme_builder->get_locations_manager(); foreach ( $snippets as $snippet ) { // Add snippet to location. // Also handling situation without conditions, bind current snippet id with current location. if ( isset( $documents_by_conditions[ $snippet->ID ] ) || ! get_post_meta( $snippet->ID, '_elementor_conditions', true ) ) { $location_manager->add_doc_to_location( $location, $snippet->ID ); } } elementor_theme_do_location( $location ); } }