switch ( $match[1] ) { case 'Article': case 'NewsArticle': case 'BlogPosting': $meta['schema_type'] = 'Article'; $meta['schema_type_options'] = wp_json_encode( [ 'article' => [ 'articleType' => $match[1] ] ] ); break; default: break; } } if ( ! in_array( $name, array_keys( $mappedMeta ), true ) ) { continue; } switch ( $name ) { case 'rank_math_focus_keyword': $keyphrases = array_map( 'trim', explode( ',', $value ) ); $keyphraseArray = [ 'focus' => [ 'keyphrase' => aioseo()->helpers->sanitizeOption( $keyphrases[0] ) ], 'additional' => [] ]; unset( $keyphrases[0] ); foreach ( $keyphrases as $keyphrase ) { $keyphraseArray['additional'][] = [ 'keyphrase' => aioseo()->helpers->sanitizeOption( $keyphrase ) ]; } $meta['keyphrases'] = $keyphraseArray; break; case 'rank_math_robots': $value = aioseo()->helpers->maybeUnserialize( $value ); if ( ! empty( $value ) ) { $supportedValues = [ 'index', 'noindex', 'nofollow', 'noarchive', 'noimageindex', 'nosnippet' ]; $meta['robots_default'] = false; foreach ( $supportedValues as $val ) { $meta[ "robots_$val" ] = false; } // This is a separated foreach as we can import any and all values. foreach ( $value as $robotsName ) { $meta[ "robots_$robotsName" ] = true; } } break; case 'rank_math_advanced_robots': $value = aioseo()->helpers->maybeUnserialize( $value ); if ( isset( $value['max-snippet'] ) && is_numeric( $value['max-snippet'] ) ) { $meta['robots_default'] = false; $meta['robots_max_snippet'] = intval( $value['max-snippet'] ); } if ( isset( $value['max-video-preview'] ) && is_numeric( $value['max-video-preview'] ) ) { $meta['robots_default'] = false; $meta['robots_max_videopreview'] = intval( $value['max-video-preview'] ); } if ( ! empty( $value['max-image-preview'] ) ) { $meta['robots_default'] = false; $meta['robots_max_imagepreview'] = aioseo()->helpers->sanitizeOption( lcfirst( $value['max-image-preview'] ) ); } break; case 'rank_math_facebook_image': $meta['og_image_type'] = 'custom_image'; $meta[ $mappedMeta[ $name ] ] = esc_url( $value ); break; case 'rank_math_twitter_image': $meta['twitter_image_type'] = 'custom_image'; $meta[ $mappedMeta[ $name ] ] = esc_url( $value ); break; case 'rank_math_twitter_card_type': preg_match( '#large#', $value, $match ); $meta[ $mappedMeta[ $name ] ] = ! empty( $match ) ? 'summary_large_image' : 'summary'; break; case 'rank_math_twitter_use_facebook': $meta[ $mappedMeta[ $name ] ] = 'on' === $value; break; case 'rank_math_primary_category': $taxonomy = 'category'; $options = new \stdClass(); $options->$taxonomy = (int) $value; $meta[ $mappedMeta[ $name ] ] = wp_json_encode( $options ); break; case 'rank_math_title': case 'rank_math_description': if ( 'page' === $post->post_type ) { $value = aioseo()->helpers->pregReplace( '#%category%#', '', $value ); $value = aioseo()->helpers->pregReplace( '#%excerpt%#', '', $value ); } $value = aioseo()->importExport->rankMath->helpers->macrosToSmartTags( $value ); $meta[ $mappedMeta[ $name ] ] = esc_html( wp_strip_all_tags( strval( $value ) ) ); break; case 'rank_math_pillar_content': $meta['pillar_content'] = 'on' === $value ? 1 : 0; break; default: $meta[ $mappedMeta[ $name ] ] = esc_html( wp_strip_all_tags( strval( $value ) ) ); break; } } $aioseoPost = Models\Post::getPost( $post->ID ); $aioseoPost->set( $meta ); $aioseoPost->save(); aioseo()->migration->meta->migrateAdditionalPostMeta( $post->ID ); // Clear the Overview cache. aioseo()->postSettings->clearPostTypeOverviewCache( $post->ID ); } if ( count( $posts ) === $postsPerAction ) { try { as_schedule_single_action( time() + 5, aioseo()->importExport->rankMath->postActionName, [], 'aioseo' ); } catch ( \Exception $e ) { // Do nothing. } } else { aioseo()->core->cache->delete( 'import_post_meta_rank_math' ); } } }