'1' === get_post_meta( $post_id, '_yoast_wpseo_meta-robots-noindex', true ), 'nofollow' => '1' === get_post_meta( $post_id, '_yoast_wpseo_meta-robots-nofollow', true ), ); } /** * Reads Yoast's Open Graph title for a post. * * @param int $post_id Post ID. * @return string */ public function get_og_title( int $post_id ): string { return (string) get_post_meta( $post_id, '_yoast_wpseo_opengraph-title', true ); } /** * Reads Yoast's Open Graph description for a post. * * @param int $post_id Post ID. * @return string */ public function get_og_description( int $post_id ): string { return (string) get_post_meta( $post_id, '_yoast_wpseo_opengraph-description', true ); } /** * Reads Yoast's focus keyword for a post. * * @param int $post_id Post ID. * @return string */ public function get_focus_keyword( int $post_id ): string { return (string) get_post_meta( $post_id, '_yoast_wpseo_focuskw', true ); } /** * Counts posts that have Yoast title or description data set. * * @return int */ public function count_migratable_pages(): int { global $wpdb; // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- {$wpdb->postmeta} is WP core's own table-name property, never user input; both meta_key values are passed through $wpdb->prepare(). Only runs when previewing/counting a migration from the admin UI, not a cacheable read path. $count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT post_id) FROM {$wpdb->postmeta} WHERE meta_key IN (%s, %s) AND meta_value != ''", '_yoast_wpseo_title', '_yoast_wpseo_metadesc' ) ); // phpcs:enable return $count; } /** * Deactivates Yoast SEO if it's currently active. * * @return bool True if it was active and is now deactivated. */ public function deactivate_self(): bool { if ( ! function_exists( 'deactivate_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_file = $this->find_active_plugin_file( 'wp-seo.php' ); if ( ! $plugin_file ) { return false; } deactivate_plugins( $plugin_file ); return ! is_plugin_active( $plugin_file ); } }