'rank-math', 'wordpress-seo' => 'yoast', 'all-in-one-seo-pack' => 'aioseo', 'wp-seopress' => 'seopress', 'autodescription' => 'the-seo-framework', ); /** * Active plugins as `folder => [file, name, version]`, network-activated ones included. * * @return array */ public static function active_plugins() { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $active = (array) get_option( 'active_plugins', array() ); if ( is_multisite() ) { $active = array_merge( $active, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) ); } $all = get_plugins(); $out = array(); foreach ( array_unique( $active ) as $file ) { if ( ! isset( $all[ $file ] ) ) { continue; } $folder = false === strpos( $file, '/' ) ? $file : dirname( $file ); $out[ $folder ] = array( 'file' => $file, 'name' => $all[ $file ]['Name'], 'version' => $all[ $file ]['Version'], ); } return $out; } /** * The active SEO plugins Studio knows. More than one is a misconfiguration worth showing, so all are listed. * * @return array */ public static function seo_plugins() { $out = array(); foreach ( self::active_plugins() as $folder => $plugin ) { if ( isset( self::SEO_PLUGINS[ $folder ] ) ) { $out[] = array( 'id' => self::SEO_PLUGINS[ $folder ], 'version' => $plugin['version'], ); } } return $out; } /** * The address settings Studio needs to know where a post will live. * * @return array{structure: string, category_base: string, tag_base: string, verbose_page_rules: bool} */ public static function permalinks() { global $wp_rewrite; return array( 'structure' => (string) get_option( 'permalink_structure', '' ), 'category_base' => (string) get_option( 'category_base', '' ), 'tag_base' => (string) get_option( 'tag_base', '' ), 'verbose_page_rules' => (bool) ( $wp_rewrite && $wp_rewrite->use_verbose_page_rules ), ); } }