get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'page_on_front'" ); } // Look for ID... if ( preg_match( '/\/(\d+)/', $current_url_path, $matches ) ) { // Numeric ID in URL (lucky) return intval( $matches[1] ); } else { // Look for page name $path_parts = explode( '/', trim( $current_url_path, '/' ) ); $post_slug = end( $path_parts ); return $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_status = 'publish'", sanitize_title_for_query( $post_slug ) ) ); } } /** * Add filter to remove Elementor if not on a Canvas page template * * @since 1.0.0 * @since 1.0.1 - Allow Elementor in Customizer. */ function fictioneer_elementor_control() { // Abort if... if ( is_admin() || wp_doing_ajax() || strpos( $_SERVER['REQUEST_URI'], 'elementor' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'customize_changeset' ) !== false ) { return; } // Get the current page template $template = get_page_template_slug( fictioneer_mu_002_get_post_id() ); $allowed_templates = array( 'singular-canvas-site.php', 'singular-canvas-page.php', 'singular-canvas-main.php' ); // Canvas template? if ( empty( $template ) || ! in_array( $template, $allowed_templates ) ) { add_filter( 'option_active_plugins', 'fictioneer_exclude_elementor' ); } } add_action( 'muplugins_loaded', 'fictioneer_elementor_control' ); /** * Removed Elementor from list of active plugins * * @since 1.0.0 * * @param array $plugins An array of active plugin paths. * * @return array Array of active plugins with Elementor removed. */ function fictioneer_exclude_elementor( $plugins ) { $elementor_key = array_search( 'elementor/elementor.php', $plugins ); if ( $elementor_key !== false ) { unset( $plugins[ $elementor_key ] ); } return $plugins; }