'WPSEO_VERSION', self::SEO_RANK_MATH => 'RANK_MATH_VERSION', self::SEO_AIOSEO => 'AIOSEO_VERSION', ); $plugin = self::seo_plugin(); if ( isset( $constants[ $plugin ] ) && defined( $constants[ $plugin ] ) ) { return (string) constant( $constants[ $plugin ] ); } return null; } /** * Whether the active SEO plugin prints the SEO fields into the page itself. * * Being active is not always enough. Rank Math prints nothing until the * site owner connects a Rank Math account or skips that step in its setup * wizard. While it is silent, {@see HeadOutput} prints the fields instead. * * @return bool False when no SEO plugin is active. */ public static function seo_plugin_prints_head() { switch ( self::seo_plugin() ) { case self::SEO_NONE: $prints = false; break; case self::SEO_RANK_MATH: $prints = ! ( class_exists( '\RankMath\Helper' ) && method_exists( '\RankMath\Helper', 'is_invalid_registration' ) && \RankMath\Helper::is_invalid_registration() ); break; default: $prints = true; } /** * Filters whether the active SEO plugin prints the SEO fields itself. * * @param bool $prints Whether it does. * @param string $plugin The active SEO plugin. */ return (bool) apply_filters( 'searchsmith_seo_plugin_prints_head', $prints, self::seo_plugin() ); } /** * Page builders active on the site. * * @return string[] */ public static function page_builders() { $builders = array(); if ( defined( 'ELEMENTOR_VERSION' ) ) { $builders[] = 'elementor'; } if ( defined( 'ET_BUILDER_VERSION' ) || defined( 'ET_BUILDER_PLUGIN_VERSION' ) ) { $builders[] = 'divi'; } if ( defined( 'WPB_VC_VERSION' ) ) { $builders[] = 'wpbakery'; } if ( defined( 'FL_BUILDER_VERSION' ) ) { $builders[] = 'beaver_builder'; } if ( defined( 'BRICKS_VERSION' ) ) { $builders[] = 'bricks'; } /** * Filters the page builders the connector reports as active. * * @param string[] $builders Builder slugs. */ return array_values( (array) apply_filters( 'searchsmith_page_builders', $builders ) ); } /** * The page builder that holds this post's real layout, or null when the * post is edited in the block editor or the classic editor. * * A builder stores its layout outside `post_content`, so changing * `post_content` on such a post changes nothing visitors see. * * @param int $post_id Post id. * @return string|null */ public static function builder_for_post( $post_id ) { $builder = null; if ( 'builder' === get_post_meta( $post_id, '_elementor_edit_mode', true ) ) { $builder = 'elementor'; } elseif ( 'on' === get_post_meta( $post_id, '_et_pb_use_builder', true ) ) { $builder = 'divi'; } elseif ( get_post_meta( $post_id, '_fl_builder_enabled', true ) ) { $builder = 'beaver_builder'; } elseif ( metadata_exists( 'post', $post_id, '_bricks_page_content_2' ) ) { $builder = 'bricks'; } elseif ( false !== strpos( (string) get_post_field( 'post_content', $post_id ), '[vc_row' ) ) { $builder = 'wpbakery'; } /** * Filters which page builder, if any, owns a post's layout. * * @param string|null $builder Builder slug, or null. * @param int $post_id Post id. */ $builder = apply_filters( 'searchsmith_builder_for_post', $builder, $post_id ); return is_string( $builder ) && '' !== $builder ? $builder : null; } /** * Cache plugins or hosts whose caches the connector knows how to clear. * * @return string[] */ public static function cache_plugins() { $caches = array(); if ( function_exists( 'rocket_clean_post' ) ) { $caches[] = 'wp_rocket'; } if ( defined( 'LSCWP_V' ) ) { $caches[] = 'litespeed'; } if ( function_exists( 'w3tc_flush_post' ) ) { $caches[] = 'w3_total_cache'; } if ( function_exists( 'wp_cache_post_change' ) ) { $caches[] = 'wp_super_cache'; } if ( function_exists( 'sg_cachepress_purge_cache' ) ) { $caches[] = 'siteground'; } if ( class_exists( 'WpeCommon' ) ) { $caches[] = 'wp_engine'; } return $caches; } }