Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-conte.../plugins/wordpres.../admin/import/plugins
File: class-import-seopressor.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* File with the class to handle data from SEOPressor.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Admin\Import\Plugins
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Class WPSEO_Import_SEOPressor.
[8] Fix | Delete
*
[9] Fix | Delete
* Class with functionality to import & clean SEOPressor post metadata.
[10] Fix | Delete
*/
[11] Fix | Delete
class WPSEO_Import_SEOPressor extends WPSEO_Plugin_Importer {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* The plugin name.
[15] Fix | Delete
*
[16] Fix | Delete
* @var string
[17] Fix | Delete
*/
[18] Fix | Delete
protected $plugin_name = 'SEOpressor';
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Meta key, used in SQL LIKE clause for delete query.
[22] Fix | Delete
*
[23] Fix | Delete
* @var string
[24] Fix | Delete
*/
[25] Fix | Delete
protected $meta_key = '_seop_settings';
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Array of meta keys to detect and import.
[29] Fix | Delete
*
[30] Fix | Delete
* @var array
[31] Fix | Delete
*/
[32] Fix | Delete
protected $clone_keys = [
[33] Fix | Delete
[
[34] Fix | Delete
'old_key' => '_seop_settings',
[35] Fix | Delete
],
[36] Fix | Delete
];
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Imports the post meta values to Yoast SEO.
[40] Fix | Delete
*
[41] Fix | Delete
* @return bool Import success status.
[42] Fix | Delete
*/
[43] Fix | Delete
protected function import() {
[44] Fix | Delete
// Query for all the posts that have an _seop_settings meta set.
[45] Fix | Delete
$query_posts = new WP_Query( 'post_type=any&meta_key=_seop_settings&order=ASC&fields=ids&nopaging=true' );
[46] Fix | Delete
foreach ( $query_posts->posts as $post_id ) {
[47] Fix | Delete
$this->import_post_focus_keywords( $post_id );
[48] Fix | Delete
$this->import_seopressor_post_settings( $post_id );
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
return true;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Removes all the post meta fields SEOpressor creates.
[56] Fix | Delete
*
[57] Fix | Delete
* @return bool Cleanup status.
[58] Fix | Delete
*/
[59] Fix | Delete
protected function cleanup() {
[60] Fix | Delete
global $wpdb;
[61] Fix | Delete
[62] Fix | Delete
// If we get to replace the data, let's do some proper cleanup.
[63] Fix | Delete
return $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_seop_%'" );
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Imports the data. SEOpressor stores most of the data in one post array, this loops over it.
[68] Fix | Delete
*
[69] Fix | Delete
* @param int $post_id Post ID.
[70] Fix | Delete
*
[71] Fix | Delete
* @return void
[72] Fix | Delete
*/
[73] Fix | Delete
private function import_seopressor_post_settings( $post_id ) {
[74] Fix | Delete
$settings = get_post_meta( $post_id, '_seop_settings', true );
[75] Fix | Delete
[76] Fix | Delete
foreach (
[77] Fix | Delete
[
[78] Fix | Delete
'fb_description' => 'opengraph-description',
[79] Fix | Delete
'fb_title' => 'opengraph-title',
[80] Fix | Delete
'fb_type' => 'og_type',
[81] Fix | Delete
'fb_img' => 'opengraph-image',
[82] Fix | Delete
'meta_title' => 'title',
[83] Fix | Delete
'meta_description' => 'metadesc',
[84] Fix | Delete
'meta_canonical' => 'canonical',
[85] Fix | Delete
'tw_description' => 'twitter-description',
[86] Fix | Delete
'tw_title' => 'twitter-title',
[87] Fix | Delete
'tw_image' => 'twitter-image',
[88] Fix | Delete
] as $seopressor_key => $yoast_key ) {
[89] Fix | Delete
$this->import_meta_helper( $seopressor_key, $yoast_key, $settings, $post_id );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
if ( isset( $settings['meta_rules'] ) ) {
[93] Fix | Delete
$this->import_post_robots( $settings['meta_rules'], $post_id );
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* Imports the focus keywords, and stores them for later use.
[99] Fix | Delete
*
[100] Fix | Delete
* @param int $post_id Post ID.
[101] Fix | Delete
*
[102] Fix | Delete
* @return void
[103] Fix | Delete
*/
[104] Fix | Delete
private function import_post_focus_keywords( $post_id ) {
[105] Fix | Delete
// Import the focus keyword.
[106] Fix | Delete
$focuskw = trim( get_post_meta( $post_id, '_seop_kw_1', true ) );
[107] Fix | Delete
$this->maybe_save_post_meta( 'focuskw', $focuskw, $post_id );
[108] Fix | Delete
[109] Fix | Delete
// Import additional focus keywords for use in premium.
[110] Fix | Delete
$focuskw2 = trim( get_post_meta( $post_id, '_seop_kw_2', true ) );
[111] Fix | Delete
$focuskw3 = trim( get_post_meta( $post_id, '_seop_kw_3', true ) );
[112] Fix | Delete
[113] Fix | Delete
$focus_keywords = [];
[114] Fix | Delete
if ( ! empty( $focuskw2 ) ) {
[115] Fix | Delete
$focus_keywords[] = $focuskw2;
[116] Fix | Delete
}
[117] Fix | Delete
if ( ! empty( $focuskw3 ) ) {
[118] Fix | Delete
$focus_keywords[] = $focuskw3;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
if ( $focus_keywords !== [] ) {
[122] Fix | Delete
$this->maybe_save_post_meta( 'focuskeywords', WPSEO_Utils::format_json_encode( $focus_keywords ), $post_id );
[123] Fix | Delete
}
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Retrieves the SEOpressor robot value and map this to Yoast SEO values.
[128] Fix | Delete
*
[129] Fix | Delete
* @param string $meta_rules The meta rules taken from the SEOpressor settings array.
[130] Fix | Delete
* @param int $post_id The post id of the current post.
[131] Fix | Delete
*
[132] Fix | Delete
* @return void
[133] Fix | Delete
*/
[134] Fix | Delete
private function import_post_robots( $meta_rules, $post_id ) {
[135] Fix | Delete
$seopressor_robots = explode( '#|#|#', $meta_rules );
[136] Fix | Delete
$robot_value = $this->get_robot_value( $seopressor_robots );
[137] Fix | Delete
[138] Fix | Delete
// Saving the new meta values for Yoast SEO.
[139] Fix | Delete
$this->maybe_save_post_meta( 'meta-robots-noindex', $robot_value['index'], $post_id );
[140] Fix | Delete
$this->maybe_save_post_meta( 'meta-robots-nofollow', $robot_value['follow'], $post_id );
[141] Fix | Delete
$this->maybe_save_post_meta( 'meta-robots-adv', $robot_value['advanced'], $post_id );
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
/**
[145] Fix | Delete
* Gets the robot config by given SEOpressor robots value.
[146] Fix | Delete
*
[147] Fix | Delete
* @param array $seopressor_robots The value in SEOpressor that needs to be converted to the Yoast format.
[148] Fix | Delete
*
[149] Fix | Delete
* @return array The robots values in Yoast format.
[150] Fix | Delete
*/
[151] Fix | Delete
private function get_robot_value( $seopressor_robots ) {
[152] Fix | Delete
$return = [
[153] Fix | Delete
'index' => 2,
[154] Fix | Delete
'follow' => 0,
[155] Fix | Delete
'advanced' => '',
[156] Fix | Delete
];
[157] Fix | Delete
[158] Fix | Delete
if ( in_array( 'noindex', $seopressor_robots, true ) ) {
[159] Fix | Delete
$return['index'] = 1;
[160] Fix | Delete
}
[161] Fix | Delete
if ( in_array( 'nofollow', $seopressor_robots, true ) ) {
[162] Fix | Delete
$return['follow'] = 1;
[163] Fix | Delete
}
[164] Fix | Delete
foreach ( [ 'noarchive', 'nosnippet', 'noimageindex' ] as $needle ) {
[165] Fix | Delete
if ( in_array( $needle, $seopressor_robots, true ) ) {
[166] Fix | Delete
$return['advanced'] .= $needle . ',';
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
$return['advanced'] = rtrim( $return['advanced'], ',' );
[170] Fix | Delete
[171] Fix | Delete
return $return;
[172] Fix | Delete
}
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function