Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../admin
File: class-export.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Admin\Export
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Class WPSEO_Export.
[8] Fix | Delete
*
[9] Fix | Delete
* Class with functionality to export the WP SEO settings.
[10] Fix | Delete
*/
[11] Fix | Delete
class WPSEO_Export {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Holds the nonce action.
[15] Fix | Delete
*
[16] Fix | Delete
* @var string
[17] Fix | Delete
*/
[18] Fix | Delete
const NONCE_ACTION = 'wpseo_export';
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Holds the export data.
[22] Fix | Delete
*
[23] Fix | Delete
* @var string
[24] Fix | Delete
*/
[25] Fix | Delete
private $export = '';
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Holds whether the export was a success.
[29] Fix | Delete
*
[30] Fix | Delete
* @var bool
[31] Fix | Delete
*/
[32] Fix | Delete
public $success;
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Handles the export request.
[36] Fix | Delete
*/
[37] Fix | Delete
public function export() {
[38] Fix | Delete
check_admin_referer( self::NONCE_ACTION );
[39] Fix | Delete
$this->export_settings();
[40] Fix | Delete
$this->output();
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Outputs the export.
[45] Fix | Delete
*/
[46] Fix | Delete
public function output() {
[47] Fix | Delete
if ( ! WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ) ) {
[48] Fix | Delete
esc_html_e( 'You do not have the required rights to export settings.', 'wordpress-seo' );
[49] Fix | Delete
return;
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
echo '<p id="wpseo-settings-export-desc">';
[53] Fix | Delete
printf(
[54] Fix | Delete
/* translators: %1$s expands to Import settings */
[55] Fix | Delete
esc_html__(
[56] Fix | Delete
'Copy all these settings to another site\'s %1$s tab and click "%1$s" there.',
[57] Fix | Delete
'wordpress-seo'
[58] Fix | Delete
),
[59] Fix | Delete
esc_html__(
[60] Fix | Delete
'Import settings',
[61] Fix | Delete
'wordpress-seo'
[62] Fix | Delete
)
[63] Fix | Delete
);
[64] Fix | Delete
echo '</p>';
[65] Fix | Delete
/* translators: %1$s expands to Yoast SEO */
[66] Fix | Delete
echo '<label for="wpseo-settings-export" class="yoast-inline-label">' . sprintf( __( 'Your %1$s settings:', 'wordpress-seo' ), 'Yoast SEO' ) . '</label><br />';
[67] Fix | Delete
echo '<textarea id="wpseo-settings-export" rows="20" cols="100" aria-describedby="wpseo-settings-export-desc">' . esc_textarea( $this->export ) . '</textarea>';
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Exports the current site's WP SEO settings.
[72] Fix | Delete
*/
[73] Fix | Delete
private function export_settings() {
[74] Fix | Delete
$this->export_header();
[75] Fix | Delete
[76] Fix | Delete
foreach ( WPSEO_Options::get_option_names() as $opt_group ) {
[77] Fix | Delete
$this->write_opt_group( $opt_group );
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Writes the header of the export.
[83] Fix | Delete
*/
[84] Fix | Delete
private function export_header() {
[85] Fix | Delete
$header = sprintf(
[86] Fix | Delete
/* translators: %1$s expands to Yoast SEO, %2$s expands to Yoast.com */
[87] Fix | Delete
esc_html__( 'These are settings for the %1$s plugin by %2$s', 'wordpress-seo' ),
[88] Fix | Delete
'Yoast SEO',
[89] Fix | Delete
'Yoast.com'
[90] Fix | Delete
);
[91] Fix | Delete
$this->write_line( '; ' . $header );
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Writes a line to the export.
[96] Fix | Delete
*
[97] Fix | Delete
* @param string $line Line string.
[98] Fix | Delete
* @param bool $newline_first Boolean flag whether to prepend with new line.
[99] Fix | Delete
*/
[100] Fix | Delete
private function write_line( $line, $newline_first = false ) {
[101] Fix | Delete
if ( $newline_first ) {
[102] Fix | Delete
$this->export .= PHP_EOL;
[103] Fix | Delete
}
[104] Fix | Delete
$this->export .= $line . PHP_EOL;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Writes an entire option group to the export.
[109] Fix | Delete
*
[110] Fix | Delete
* @param string $opt_group Option group name.
[111] Fix | Delete
*/
[112] Fix | Delete
private function write_opt_group( $opt_group ) {
[113] Fix | Delete
[114] Fix | Delete
$this->write_line( '[' . $opt_group . ']', true );
[115] Fix | Delete
[116] Fix | Delete
$options = get_option( $opt_group );
[117] Fix | Delete
[118] Fix | Delete
if ( ! is_array( $options ) ) {
[119] Fix | Delete
return;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
foreach ( $options as $key => $elem ) {
[123] Fix | Delete
if ( is_array( $elem ) ) {
[124] Fix | Delete
$count = count( $elem );
[125] Fix | Delete
for ( $i = 0; $i < $count; $i++ ) {
[126] Fix | Delete
$this->write_setting( $key . '[]', $elem[ $i ] );
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
else {
[130] Fix | Delete
$this->write_setting( $key, $elem );
[131] Fix | Delete
}
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
/**
[136] Fix | Delete
* Writes a settings line to the export.
[137] Fix | Delete
*
[138] Fix | Delete
* @param string $key Key string.
[139] Fix | Delete
* @param string $val Value string.
[140] Fix | Delete
*/
[141] Fix | Delete
private function write_setting( $key, $val ) {
[142] Fix | Delete
if ( is_string( $val ) ) {
[143] Fix | Delete
$val = '"' . $val . '"';
[144] Fix | Delete
}
[145] Fix | Delete
$this->write_line( $key . ' = ' . $val );
[146] Fix | Delete
}
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function