WPR FM
uid=9814(b13i2mwmyrdbxio) php=8.4.28
info
cwd /data/sites/web/b13i2mwmyrdbxio/www |
naik
Buka
-
premium-seo-pack.php
5494
x
-
seo-framework.php
6346
x
-
seo-ultimate.php
2965
x
-
slim-seo.php
4080
x
-
smart-crawl.php
42673
x
-
squirrly.php
3092
x
-
wp-meta-seo.php
4440
x
-
yoast.php
33396
x
Upload
Simpan
<?php /** * Yoast migration. * * @package SEOPress * @subpackage Ajax */ defined( 'ABSPATH' ) || exit( 'Please don’t call the plugin directly. Thanks :)' ); /** * Map Yoast social account URLs to SEOPress social account fields. * * Facebook, X/Twitter, Instagram, LinkedIn, YouTube and Pinterest are routed * to their dedicated SEOPress fields; any other profile falls back to the * "additional accounts" field. X/Twitter handles are stored as-is (no http:// * prefix is ever added), and a dedicated field already imported from a specific * Yoast key (e.g. facebook_site) is never overwritten by other_social_urls. * * @param array $wpseo_social Yoast `wpseo_social` option. * @param array $seopress_social Current SEOPress social option array. * @return array Updated SEOPress social option array. */ function seopress_yoast_map_social_accounts( $wpseo_social, $seopress_social ) { if ( ! is_array( $wpseo_social ) ) { return $seopress_social; } if ( ! is_array( $seopress_social ) ) { $seopress_social = array(); } if ( isset( $wpseo_social['facebook_site'] ) && '' !== $wpseo_social['facebook_site'] ) { $seopress_social['seopress_social_accounts_facebook'] = esc_url( $wpseo_social['facebook_site'] ); } if ( isset( $wpseo_social['twitter_site'] ) && '' !== $wpseo_social['twitter_site'] ) { // Twitter/X handle - don't add http:// prefix. Remove a leading @ if present. $seopress_social['seopress_social_accounts_twitter'] = esc_html( ltrim( $wpseo_social['twitter_site'], '@' ) ); } if ( isset( $wpseo_social['other_social_urls'] ) && is_array( $wpseo_social['other_social_urls'] ) ) { // Map domain patterns to SEOPress social account fields. $social_networks = array( 'instagram.com' => 'seopress_social_accounts_instagram', 'linkedin.com' => 'seopress_social_accounts_linkedin', 'youtube.com' => 'seopress_social_accounts_youtube', 'youtu.be' => 'seopress_social_accounts_youtube', 'pinterest.com' => 'seopress_social_accounts_pinterest', 'pinterest.fr' => 'seopress_social_accounts_pinterest', 'facebook.com' => 'seopress_social_accounts_facebook', 'fb.com' => 'seopress_social_accounts_facebook', 'twitter.com' => 'seopress_social_accounts_twitter', 'x.com' => 'seopress_social_accounts_twitter', ); $extra_accounts = array(); foreach ( $wpseo_social['other_social_urls'] as $social_url ) { if ( empty( $social_url ) ) { continue; } $social_url_lower = strtolower( $social_url ); $matched = false; foreach ( $social_networks as $domain => $field ) { if ( false !== strpos( $social_url_lower, $domain ) ) { // Twitter/X: extract the handle from the URL, without a leading @. if ( 'seopress_social_accounts_twitter' === $field ) { if ( empty( $seopress_social[ $field ] ) ) { $parsed = wp_parse_url( $social_url ); if ( ! empty( $parsed['path'] ) ) { $seopress_social[ $field ] = esc_html( ltrim( trim( $parsed['path'], '/' ), '@' ) ); } } } elseif ( empty( $seopress_social[ $field ] ) ) { // Do not overwrite a dedicated field already imported // from a specific Yoast key (e.g. facebook_site). $seopress_social[ $field ] = esc_url( $social_url ); } $matched = true; break; } } // Unknown network - add to extra accounts. if ( ! $matched ) { $extra_accounts[] = ( 0 === strpos( $social_url, '@' ) ) ? esc_html( $social_url ) : esc_url( $social_url ); } } if ( ! empty( $extra_accounts ) ) { $seopress_social['seopress_social_accounts_extra'] = implode( "\n", $extra_accounts ); } } return $seopress_social; } /** * Map Yoast feed (crawl optimization) settings to SEOPress PRO RSS options. * * SEOPress exposes three feed toggles: the posts feed, the global comments feed * and a single "extra feeds" toggle. Yoast splits its extra feeds (per-post * comments, authors, categories, tags, custom taxonomies, post types and * search) into separate options, but they all map to WordPress' * feed_links_extra output, which SEOPress controls with that single toggle. We * therefore enable it when any of the Yoast extra feed options is enabled. * * @param array $wpseo Yoast `wpseo` option. * @param array $seopress_pro Current SEOPress PRO option array. * @return array Updated SEOPress PRO option array. */ function seopress_yoast_map_feed_settings( $wpseo, $seopress_pro ) { if ( ! is_array( $wpseo ) ) { return $seopress_pro; } if ( ! is_array( $seopress_pro ) ) { $seopress_pro = array(); } if ( isset( $wpseo['remove_feed_global'] ) ) { if ( true === $wpseo['remove_feed_global'] ) { $seopress_pro['seopress_rss_disable_posts_feed'] = '1'; } else { unset( $seopress_pro['seopress_rss_disable_posts_feed'] ); } } if ( isset( $wpseo['remove_feed_global_comments'] ) ) { if ( true === $wpseo['remove_feed_global_comments'] ) { $seopress_pro['seopress_rss_disable_comments_feed'] = '1'; } else { unset( $seopress_pro['seopress_rss_disable_comments_feed'] ); } } $yoast_extra_feed_keys = array( 'remove_feed_post_comments', 'remove_feed_authors', 'remove_feed_categories', 'remove_feed_tags', 'remove_feed_custom_taxonomies', 'remove_feed_post_types', 'remove_feed_search', ); $yoast_has_extra_feed_key = (bool) array_intersect_key( array_flip( $yoast_extra_feed_keys ), $wpseo ); $yoast_extra_feed_disabled = false; foreach ( $yoast_extra_feed_keys as $yoast_extra_feed_key ) { if ( ! empty( $wpseo[ $yoast_extra_feed_key ] ) ) { $yoast_extra_feed_disabled = true; break; } } if ( $yoast_has_extra_feed_key ) { if ( $yoast_extra_feed_disabled ) { $seopress_pro['seopress_rss_disable_extra_feed'] = '1'; } else { unset( $seopress_pro['seopress_rss_disable_extra_feed'] ); } } return $seopress_pro; } /** * Map Yoast's attachment redirect default to SEOPress. * * Yoast's `disable-attachment` option redirects attachment URLs to the media * file itself. SEOPress reproduces this with the "redirect attachments to their * file URL" advanced option, which also supersedes the "redirect to parent" * option. * * @param array $wpseo_titles Yoast `wpseo_titles` option. * @param array $seopress_advanced Current SEOPress advanced option array. * @return array Updated SEOPress advanced option array. */ function seopress_yoast_map_attachment_redirect( $wpseo_titles, $seopress_advanced ) { if ( ! is_array( $wpseo_titles ) || ! isset( $wpseo_titles['disable-attachment'] ) ) { return $seopress_advanced; } if ( ! is_array( $seopress_advanced ) ) { $seopress_advanced = array(); } if ( true === $wpseo_titles['disable-attachment'] ) { $seopress_advanced['seopress_advanced_advanced_attachments_file'] = '1'; unset( $seopress_advanced['seopress_advanced_advanced_attachments'] ); } else { unset( $seopress_advanced['seopress_advanced_advanced_attachments_file'] ); } return $seopress_advanced; } /** * Translate Yoast template variables to SEOPress names. * * SEOPress renders a few Yoast names as aliases (`%%title%%`, `%%sitename%%`, * `%%sitedesc%%`, `%%excerpt%%`, `%%date%%`), but the others (`%%name%%`, * `%%searchphrase%%`, `%%pt_plural%%`, `%%cf_*%%`…) would print literally. * Rewriting all of them gives templates that render and read the same as the * ones created in SEOPress. Yoast variables with no SEOPress equivalent * (`%%id%%`, `%%pt_single%%`, `%%ct_desc_*%%`…) are kept as is. * * Yoast resolves `%%category%%`, `%%tag%%` and `%%date%%` from the page being * displayed, so they map to a different SEOPress variable on a term or a * date archive than on a post. * * @param mixed $value Raw Yoast template. * @param string $context Where the template is used: 'post', 'term' or 'date_archive'. * * @return string Translated template, not escaped. */ function seopress_yoast_translate_template( $value, $context = 'post' ) { if ( ! is_string( $value ) || '' === $value ) { return is_scalar( $value ) ? (string) $value : ''; } $map = array( '%%title%%' => '%%post_title%%', '%%sitename%%' => '%%sitetitle%%', '%%sitedesc%%' => '%%tagline%%', '%%excerpt%%' => '%%post_excerpt%%', '%%excerpt_only%%' => '%%post_excerpt%%', '%%date%%' => '%%post_date%%', '%%modified%%' => '%%post_modified_date%%', '%%name%%' => '%%post_author%%', '%%user_description%%' => '%%author_bio%%', '%%category%%' => '%%post_category%%', '%%primary_category%%' => '%%post_category%%', '%%tag%%' => '%%post_tag%%', '%%category_description%%' => '%%_category_description%%', '%%category_title%%' => '%%_category_title%%', '%%searchphrase%%' => '%%search_keywords%%', '%%pagenumber%%' => '%%current_pagination%%', '%%pt_plural%%' => '%%cpt_plural%%', '%%permalink%%' => '%%post_url%%', '%%focuskw%%' => '%%target_keyword%%', '%%wc_price%%' => '%%wc_single_price%%', '%%wc_shortdesc%%' => '%%wc_single_short_desc%%', ); if ( 'term' === $context ) { $map['%%category%%'] = '%%term_title%%'; $map['%%tag%%'] = '%%term_title%%'; } elseif ( 'date_archive' === $context ) { $map['%%date%%'] = '%%archive_date%%'; } // Custom fields and taxonomies: %%cf_<key>%% and %%ct_<slug>%%. $value = preg_replace( '/%%(cf|ct)_(?!desc_)([^%\s]+)%%/', '%%_$1_$2%%', $value ); return strtr( $value, $map ); } /** * Yoast migration */ function seopress_yoast_migration() { check_ajax_referer( 'seopress_yoast_migrate_nonce', '_ajax_nonce', true ); if ( current_user_can( seopress_capability( 'manage_options', 'migration' ) ) ) { if ( isset( $_POST['offset'] ) && isset( $_POST['offset'] ) ) { $offset = absint( $_POST['offset'] ); } global $wpdb; // phpcs:ignore $total_count_posts = (int) $wpdb->get_var( "SELECT count(*) FROM {$wpdb->posts}" ); // phpcs:ignore $total_count_terms = (int) $wpdb->get_var( "SELECT count(*) FROM {$wpdb->terms}" ); $increment = 200; global $post; // === Import settings ===// // Import titles $wpseo = get_option( 'wpseo' ); $wpseo_titles = get_option( 'wpseo_titles' ); $wpseo_social = get_option( 'wpseo_social' ); $seopress_titles = get_option( 'seopress_titles_option_name' ); $seopress_social = get_option( 'seopress_social_option_name' ); $seopress_advanced = get_option( 'seopress_advanced_option_name' ); $seopress_pro = get_option( 'seopress_pro_option_name' ); // A SEOPress option never saved yet comes back as false. $seopress_titles = is_array( $seopress_titles ) ? $seopress_titles : array(); $seopress_social = is_array( $seopress_social ) ? $seopress_social : array(); $seopress_advanced = is_array( $seopress_advanced ) ? $seopress_advanced : array(); $seopress_pro = is_array( $seopress_pro ) ? $seopress_pro : array(); if ( ! empty( $wpseo ) ) { foreach ( $wpseo as $key => $value ) { if ( 'googleverify' === $key ) { $seopress_advanced['seopress_advanced_advanced_google'] = esc_html( $value ); } if ( 'msverify' === $key ) { $seopress_advanced['seopress_advanced_advanced_bing'] = esc_html( $value ); } if ( 'yandexverify' === $key ) { $seopress_advanced['seopress_advanced_advanced_yandex'] = esc_html( $value ); } if ( 'baiduverify' === $key ) { $seopress_advanced['seopress_advanced_advanced_baidu'] = esc_html( $value ); } if ( 'remove_shortlinks' === $key ) { if ( true === $value ) { $seopress_advanced['seopress_advanced_advanced_wp_shortlink'] = '1'; } else { unset( $seopress_advanced['seopress_advanced_advanced_wp_shortlink'] ); } } if ( 'remove_rsd_wlw_links' === $key ) { if ( true === $value ) { $seopress_advanced['seopress_advanced_advanced_wp_rsd'] = '1'; $seopress_advanced['seopress_advanced_advanced_wp_wlw'] = '1'; } else { unset( $seopress_advanced['seopress_advanced_advanced_wp_rsd'] ); unset( $seopress_advanced['seopress_advanced_advanced_wp_wlw'] ); } } if ( 'remove_oembed_links' === $key ) { if ( true === $value ) { $seopress_advanced['seopress_advanced_advanced_wp_oembed'] = '1'; } else { unset( $seopress_advanced['seopress_advanced_advanced_wp_oembed'] ); } } if ( 'remove_generator' === $key ) { if ( true === $value ) { $seopress_advanced['seopress_advanced_advanced_wp_generator'] = '1'; } else { unset( $seopress_advanced['seopress_advanced_advanced_wp_generator'] ); } } if ( 'remove_pingback_header' === $key ) { if ( true === $value ) { $seopress_advanced['seopress_advanced_advanced_wp_x_pingback'] = '1'; } else { unset( $seopress_advanced['seopress_advanced_advanced_wp_x_pingback'] ); } } if ( 'remove_powered_by_header' === $key ) { if ( true === $value ) { $seopress_advanced['seopress_advanced_advanced_wp_x_powered_by'] = '1'; } else { unset( $seopress_advanced['seopress_advanced_advanced_wp_x_powered_by'] ); } } if ( 'remove_emoji_scripts' === $key ) { if ( true === $value ) { $seopress_advanced['seopress_advanced_advanced_emoji'] = '1'; } else { unset( $seopress_advanced['seopress_advanced_advanced_emoji'] ); } } } // RSS / feed crawl optimization. $seopress_pro = seopress_yoast_map_feed_settings( $wpseo, $seopress_pro ); } if ( ! empty( $wpseo_titles ) ) { foreach ( $wpseo_titles as $key => $value ) { if ( 'separator' === $key ) { // Plain characters, as the settings screen saves them: the // front end encodes the separator when printing it, so an // entity here would show up as ">" in the title. $separator = array( 'sc-dash' => '-', 'sc-ndash' => '–', 'sc-mdash' => '—', 'sc-colon' => ':', 'sc-middot' => '·', 'sc-bull' => '•', 'sc-star' => '*', 'sc-smstar' => '⋆', 'sc-pipe' => '|', 'sc-tilde' => '~', 'sc-laquo' => '«', 'sc-raquo' => '»', // Yoast swaps these two: "sc-gt" prints "<" and "sc-lt" prints ">". 'sc-gt' => '<', 'sc-lt' => '>', ); if ( isset( $separator[ $value ] ) ) { $seopress_titles['seopress_titles_sep'] = $separator[ $value ]; } } // Not `website_name`: that is the site name of Yoast's Schema // graph, the home title template is `title-home-wpseo`. if ( 'title-home-wpseo' === $key ) { $seopress_titles['seopress_titles_home_site_title'] = esc_html( seopress_yoast_translate_template( $value ) ); } if ( 'alternate_website_name' === $key ) { $seopress_titles['seopress_titles_home_site_title_alt'] = esc_html( $value ); } if ( 'metadesc-home-wpseo' === $key ) { $seopress_titles['seopress_titles_home_site_desc'] = esc_html( seopress_yoast_translate_template( $value ) ); } if ( 'company_or_person' === $key ) { $type = array( 'company' => 'Organization', 'person' => 'Person', ); $seopress_social['seopress_social_knowledge_type'] = esc_html( $type[ $value ] ); } if ( 'company_name' === $key ) { $seopress_social['seopress_social_knowledge_name'] = esc_html( $value ); } if ( 'company_logo' === $key ) { $seopress_social['seopress_social_knowledge_img'] = esc_url( $value ); } // Breadcrumbs. if ( 'breadcrumbs-enable' === $key ) { if ( true === $value ) { $seopress_pro['seopress_breadcrumbs_enable'] = '1'; $seopress_pro['seopress_breadcrumbs_json_enable'] = '1'; } else { unset( $seopress_pro['seopress_breadcrumbs_enable'] ); unset( $seopress_pro['seopress_breadcrumbs_json_enable'] ); } } if ( 'breadcrumbs-sep' === $key ) { $seopress_pro['seopress_breadcrumbs_separator'] = esc_html( $value ); } if ( 'breadcrumbs-home' === $key ) { $seopress_pro['seopress_breadcrumbs_i18n_home'] = esc_html( $value ); } if ( 'breadcrumbs-prefix' === $key ) { $seopress_pro['seopress_breadcrumbs_i18n_here'] = esc_html( $value ); } if ( 'breadcrumbs-searchprefix' === $key ) { $seopress_pro['seopress_breadcrumbs_i18n_search'] = esc_html( $value ); } if ( 'breadcrumbs-404crumb' === $key ) { $seopress_pro['seopress_breadcrumbs_i18n_404'] = esc_html( $value ); } if ( 'breadcrumbs-display-blog-page' === $key ) { if ( true === $value ) { unset( $seopress_pro['seopress_breadcrumbs_remove_blog_page'] ); } else { $seopress_pro['seopress_breadcrumbs_remove_blog_page'] = '1'; } } // RSS Feeds. if ( 'rssbefore' === $key || 'rssafter' === $key ) { $rss_vars = array( '%%AUTHORLINK%%' => '<a href="%%author_permalink%%">%%post_author%%</a>', '%%POSTLINK%%' => '<a href="%%post_permalink%%">%%post_title%%</a>', '%%BLOGLINK%%' => '<a href="' . get_bloginfo( 'url' ) . '">' . get_bloginfo( 'name' ) . '</a>', '%%BLOGDESCLINK%%' => '<a href="' . get_bloginfo( 'url' ) . '">' . get_bloginfo( 'name' ) . ' ' . get_bloginfo( 'description' ) . '</a>', ); $value = str_replace( array_keys( $rss_vars ), array_values( $rss_vars ), $value ); } if ( 'rssbefore' === $key ) { $args = array( 'strong' => array(), 'em' => array(), 'br' => array(), 'a' => array( 'href' => array(), 'rel' => array(), ), ); $seopress_pro['seopress_rss_before_html'] = wp_kses( $value, $args ); } if ( 'rssafter' === $key ) { $args = array( 'strong' => array(), 'em' => array(), 'br' => array(), 'a' => array( 'href' => array(), 'rel' => array(), ), ); $seopress_pro['seopress_rss_after_html'] = wp_kses( $value, $args ); } // Import CPT settings. $post_types = seopress_get_service( 'WordPressData' )->getPostTypes(); foreach ( $post_types as $seopress_cpt_key => $seopress_cpt_value ) { // Single title. if ( 'title-' . $seopress_cpt_key === $key ) { $seopress_titles['seopress_titles_single_titles'][ $seopress_cpt_key ]['title'] = esc_html( seopress_yoast_translate_template( $value ) ); } // Single description. if ( 'metadesc-' . $seopress_cpt_key === $key ) { $seopress_titles['seopress_titles_single_titles'][ $seopress_cpt_key ]['description'] = esc_html( seopress_yoast_translate_template( $value ) ); } // Single noindex. if ( 'noindex-' . $seopress_cpt_key === $key ) { unset( $seopress_titles['seopress_titles_single_titles'][ $seopress_cpt_key ]['noindex'] ); if ( true === $value ) { $seopress_titles['seopress_titles_single_titles'][ $seopress_cpt_key ]['noindex'] = '1'; } } // Single Enable. if ( 'display-metabox-pt-' . $seopress_cpt_key === $key ) { $seopress_titles['seopress_titles_single_titles'][ $seopress_cpt_key ]['enable'] = '1'; if ( true === $value ) { unset( $seopress_titles['seopress_titles_single_titles'][ $seopress_cpt_key ]['enable'] ); } } // Breadcrumbs. if ( 'post_types-' . $seopress_cpt_key . '-maintax' === $key ) { $seopress_pro['seopress_breadcrumbs_tax'][ $seopress_cpt_key ]['tax'] = esc_html( $value ); } } // Import taxonomies settings. $taxonomies = seopress_get_service( 'WordPressData' )->getTaxonomies(); foreach ( $taxonomies as $seopress_tax_key => $seopress_tax_value ) { // Tax title. if ( 'title-tax-' . $seopress_tax_key === $key ) { $seopress_titles['seopress_titles_tax_titles'][ $seopress_tax_key ]['title'] = esc_html( seopress_yoast_translate_template( $value, 'term' ) ); } // Tax description. if ( 'metadesc-tax-' . $seopress_tax_key === $key ) { $seopress_titles['seopress_titles_tax_titles'][ $seopress_tax_key ]['description'] = esc_html( seopress_yoast_translate_template( $value, 'term' ) ); } // Tax noindex. if ( 'noindex-tax-' . $seopress_tax_key === $key ) { unset( $seopress_titles['seopress_titles_tax_titles'][ $seopress_tax_key ]['noindex'] ); if ( true === $value ) { $seopress_titles['seopress_titles_tax_titles'][ $seopress_tax_key ]['noindex'] = '1'; } } // Tax Enable. if ( 'display-metabox-tax-' . $seopress_tax_key === $key ) { $seopress_titles['seopress_titles_tax_titles'][ $seopress_tax_key ]['enable'] = '1'; if ( true === $value ) { unset( $seopress_titles['seopress_titles_tax_titles'][ $seopress_tax_key ]['enable'] ); } } // Breadcrumbs. if ( 'taxonomy-' . $seopress_tax_key . '-ptparent' === $key ) { $seopress_pro['seopress_breadcrumbs_cpt'][ $seopress_tax_key ]['cpt'] = esc_html( $value ); } } // 404. if ( 'title-404-wpseo' === $key ) { $seopress_titles['seopress_titles_archives_404_title'] = esc_html( seopress_yoast_translate_template( $value ) ); } // Internal search. if ( 'title-search-wpseo' === $key ) { $seopress_titles['seopress_titles_archives_search_title'] = esc_html( seopress_yoast_translate_template( $value ) ); } // Date archive. if ( 'disable-date' === $key ) { if ( true === $value ) { $seopress_titles['seopress_titles_archives_date_disable'] = '1'; } else { unset( $seopress_titles['seopress_titles_archives_date_disable'] ); } } if ( 'noindex-archive-wpseo' === $key ) { if ( true === $value ) { $seopress_titles['seopress_titles_archives_date_noindex'] = '1'; } else { unset( $seopress_titles['seopress_titles_archives_date_noindex'] ); } } if ( 'title-archive-wpseo' === $key ) { $seopress_titles['seopress_titles_archives_date_title'] = esc_html( seopress_yoast_translate_template( $value, 'date_archive' ) ); } if ( 'metadesc-archive-wpseo' === $key ) { $seopress_titles['seopress_titles_archives_date_desc'] = esc_html( seopress_yoast_translate_template( $value, 'date_archive' ) ); } // Author. if ( 'disable-author' === $key ) { if ( true === $value ) { $seopress_titles['seopress_titles_archives_author_disable'] = '1'; } else { unset( $seopress_titles['seopress_titles_archives_author_disable'] ); } } if ( 'noindex-author-wpseo' === $key ) { if ( true === $value ) { $seopress_titles['seopress_titles_archives_author_noindex'] = '1'; } else { unset( $seopress_titles['seopress_titles_archives_author_noindex'] ); } } if ( 'title-author-wpseo' === $key ) { $seopress_titles['seopress_titles_archives_author_title'] = esc_html( seopress_yoast_translate_template( $value ) ); } if ( 'metadesc-author-wpseo' === $key ) { $seopress_titles['seopress_titles_archives_author_desc'] = esc_html( seopress_yoast_translate_template( $value ) ); } } } // Attachment redirect. $seopress_advanced = seopress_yoast_map_attachment_redirect( $wpseo_titles, $seopress_advanced ); // Import social. if ( ! empty( $wpseo_social ) ) { $seopress_social = seopress_yoast_map_social_accounts( $wpseo_social, $seopress_social ); if ( isset( $wpseo_social['pinterestverify'] ) ) { $seopress_advanced['seopress_advanced_advanced_pinterest'] = esc_html( $wpseo_social['pinterestverify'] ); } } update_option( 'seopress_titles_option_name', $seopress_titles, false ); update_option( 'seopress_social_option_name', $seopress_social, false ); update_option( 'seopress_advanced_option_name', $seopress_advanced, false ); update_option( 'seopress_pro_option_name', $seopress_pro, false ); // Import terms. if ( $offset > $total_count_posts ) { wp_reset_postdata(); $yoast_query_terms = get_option( 'wpseo_taxonomy_meta' ); if ( $yoast_query_terms ) { foreach ( $yoast_query_terms as $taxonomies => $taxonomie ) { foreach ( $taxonomie as $term_id => $term_value ) { if ( ! empty( $term_value['wpseo_title'] ) ) { // Import title tag. update_term_meta( $term_id, '_seopress_titles_title', esc_html( seopress_yoast_translate_template( $term_value['wpseo_title'], 'term' ) ) ); } if ( ! empty( $term_value['wpseo_desc'] ) ) { // Import meta desc. update_term_meta( $term_id, '_seopress_titles_desc', esc_html( seopress_yoast_translate_template( $term_value['wpseo_desc'], 'term' ) ) ); } if ( ! empty( $term_value['wpseo_opengraph-title'] ) ) { // Import Facebook Title. update_term_meta( $term_id, '_seopress_social_fb_title', esc_html( seopress_yoast_translate_template( $term_value['wpseo_opengraph-title'], 'term' ) ) ); } if ( ! empty( $term_value['wpseo_opengraph-description'] ) ) { // Import Facebook Desc. update_term_meta( $term_id, '_seopress_social_fb_desc', esc_html( seopress_yoast_translate_template( $term_value['wpseo_opengraph-description'], 'term' ) ) ); } if ( ! empty( $term_value['wpseo_opengraph-image'] ) ) { // Import Facebook Image. update_term_meta( $term_id, '_seopress_social_fb_img', esc_url( $term_value['wpseo_opengraph-image'] ) ); } if ( ! empty( $term_value['wpseo_twitter-title'] ) ) { // Import Twitter Title. update_term_meta( $term_id, '_seopress_social_twitter_title', esc_html( seopress_yoast_translate_template( $term_value['wpseo_twitter-title'], 'term' ) ) ); } if ( ! empty( $term_value['wpseo_twitter-description'] ) ) { // Import Twitter Desc. update_term_meta( $term_id, '_seopress_social_twitter_desc', esc_html( seopress_yoast_translate_template( $term_value['wpseo_twitter-description'], 'term' ) ) ); } if ( ! empty( $term_value['wpseo_twitter-image'] ) ) { // Import Twitter Image. update_term_meta( $term_id, '_seopress_social_twitter_img', esc_url( $term_value['wpseo_twitter-image'] ) ); } if ( isset( $term_value['wpseo_noindex'] ) && 'noindex' === $term_value['wpseo_noindex'] ) { // Import Robots NoIndex. update_term_meta( $term_id, '_seopress_robots_index', 'yes' ); } if ( ! empty( $term_value['wpseo_canonical'] ) ) { // Import Canonical URL. update_term_meta( $term_id, '_seopress_robots_canonical', esc_url( $term_value['wpseo_canonical'] ) ); } if ( ! empty( $term_value['wpseo_bctitle'] ) ) { // Import Breadcrumb Title. update_term_meta( $term_id, '_seopress_robots_breadcrumbs', esc_html( $term_value['wpseo_bctitle'] ) ); } } } } $offset = 'done'; wp_reset_postdata(); } else { // Import posts. $args = array( 'posts_per_page' => $increment, 'post_type' => 'any', 'post_status' => 'any', 'offset' => $offset, ); $yoast_query = get_posts( $args ); if ( $yoast_query ) { foreach ( $yoast_query as $post ) { if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_title', true ) ) { // Import title tag. update_post_meta( $post->ID, '_seopress_titles_title', esc_html( seopress_yoast_translate_template( get_post_meta( $post->ID, '_yoast_wpseo_title', true ) ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_metadesc', true ) ) { // Import meta desc. update_post_meta( $post->ID, '_seopress_titles_desc', esc_html( seopress_yoast_translate_template( get_post_meta( $post->ID, '_yoast_wpseo_metadesc', true ) ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_opengraph-title', true ) ) { // Import Facebook Title. update_post_meta( $post->ID, '_seopress_social_fb_title', esc_html( seopress_yoast_translate_template( get_post_meta( $post->ID, '_yoast_wpseo_opengraph-title', true ) ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_opengraph-description', true ) ) { // Import Facebook Desc. update_post_meta( $post->ID, '_seopress_social_fb_desc', esc_html( seopress_yoast_translate_template( get_post_meta( $post->ID, '_yoast_wpseo_opengraph-description', true ) ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_opengraph-image', true ) ) { // Import Facebook Image. update_post_meta( $post->ID, '_seopress_social_fb_img', esc_url( get_post_meta( $post->ID, '_yoast_wpseo_opengraph-image', true ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_twitter-title', true ) ) { // Import Twitter Title. update_post_meta( $post->ID, '_seopress_social_twitter_title', esc_html( seopress_yoast_translate_template( get_post_meta( $post->ID, '_yoast_wpseo_twitter-title', true ) ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_twitter-description', true ) ) { // Import Twitter Desc. update_post_meta( $post->ID, '_seopress_social_twitter_desc', esc_html( seopress_yoast_translate_template( get_post_meta( $post->ID, '_yoast_wpseo_twitter-description', true ) ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_twitter-image', true ) ) { // Import Twitter Image. update_post_meta( $post->ID, '_seopress_social_twitter_img', esc_url( get_post_meta( $post->ID, '_yoast_wpseo_twitter-image', true ) ) ); } if ( '1' === get_post_meta( $post->ID, '_yoast_wpseo_meta-robots-noindex', true ) ) { // Import Robots NoIndex. update_post_meta( $post->ID, '_seopress_robots_index', 'yes' ); } if ( '1' === get_post_meta( $post->ID, '_yoast_wpseo_meta-robots-nofollow', true ) ) { // Import Robots NoFollow. update_post_meta( $post->ID, '_seopress_robots_follow', 'yes' ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_meta-robots-adv', true ) ) { // Import Robots NoImageIndex, NoSnippet. $yoast_wpseo_meta_robots_adv = get_post_meta( $post->ID, '_yoast_wpseo_meta-robots-adv', true ); if ( false !== strpos( $yoast_wpseo_meta_robots_adv, 'noimageindex' ) ) { update_post_meta( $post->ID, '_seopress_robots_imageindex', 'yes' ); } if ( false !== strpos( $yoast_wpseo_meta_robots_adv, 'nosnippet' ) ) { update_post_meta( $post->ID, '_seopress_robots_snippet', 'yes' ); } } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_canonical', true ) ) { // Import Canonical URL. update_post_meta( $post->ID, '_seopress_robots_canonical', esc_url( get_post_meta( $post->ID, '_yoast_wpseo_canonical', true ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_bctitle', true ) ) { // Import Breadcrumb Title. update_post_meta( $post->ID, '_seopress_robots_breadcrumbs', esc_html( get_post_meta( $post->ID, '_yoast_wpseo_bctitle', true ) ) ); } if ( '' !== get_post_meta( $post->ID, '_yoast_wpseo_focuskw', true ) || '' !== get_post_meta( $post->ID, '_yoast_wpseo_focuskeywords', true ) ) { // Import Focus Keywords. $y_fkws_clean = array(); // reset array. // Handle _yoast_wpseo_focuskeywords (JSON array or empty). $focuskeywords_meta = get_post_meta( $post->ID, '_yoast_wpseo_focuskeywords', true ); if ( ! empty( $focuskeywords_meta ) && is_string( $focuskeywords_meta ) ) { $decoded = json_decode( $focuskeywords_meta ); if ( is_array( $decoded ) ) { foreach ( $decoded as $decoded_kw ) { if ( isset( $decoded_kw->keyword ) && '' !== $decoded_kw->keyword ) { $y_fkws_clean[] = esc_html( $decoded_kw->keyword ); } } } } // Handle _yoast_wpseo_focuskw (string or empty). $focuskw = get_post_meta( $post->ID, '_yoast_wpseo_focuskw', true ); if ( ! empty( $focuskw ) && is_string( $focuskw ) ) { $y_fkws_clean[] = esc_html( $focuskw ); } // Save if we have any keywords. if ( ! empty( $y_fkws_clean ) ) { update_post_meta( $post->ID, '_seopress_analysis_target_kw', implode( ',', $y_fkws_clean ) ); } } // Primary term, for every taxonomy that has one rather than // only the two SEOPress used to support. Yoast stores one // `_yoast_wpseo_primary_{taxonomy}` per taxonomy, which is // exactly what WPSEO_Primary_Term reads, so a site migrating // a `doc_cat` or a `genre` kept nothing before this. if ( class_exists( 'WPSEO_Primary_Term' ) ) { $taxonomies = \SEOPress\Helpers\Metas\PrimaryTerm::get_taxonomies( get_post_type( $post->ID ) ); foreach ( array_keys( $taxonomies ) as $tax ) { $primary_term = new WPSEO_Primary_Term( $tax, $post->ID ); $primary_term = absint( $primary_term->get_primary_term() ); if ( $primary_term > 0 ) { \SEOPress\Helpers\Metas\PrimaryTerm::save( $post->ID, $tax, $primary_term ); } } } } } $offset += $increment; } $data = array(); $data['total'] = $total_count_posts; if ( $offset >= $total_count_posts ) { $data['count'] = $total_count_posts; } else { $data['count'] = $offset; } $data['offset'] = $offset; wp_send_json_success( $data ); exit(); } } add_action( 'wp_ajax_seopress_yoast_migration', 'seopress_yoast_migration' );
Exec