PHP 8.2.31
Preview: class-export.php Size: 3.46 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/wordpress-seo/admin/class-export.php

<?php
/**
 * WPSEO plugin file.
 *
 * @package WPSEO\Admin\Export
 */

/**
 * Class WPSEO_Export.
 *
 * Class with functionality to export the WP SEO settings.
 */
class WPSEO_Export {

	/**
	 * Holds the nonce action.
	 *
	 * @var string
	 */
	public const NONCE_ACTION = 'wpseo_export';

	/**
	 * Holds the export data.
	 *
	 * @var string
	 */
	private $export = '';

	/**
	 * Holds whether the export was a success.
	 *
	 * @var bool
	 */
	public $success;

	/**
	 * Handles the export request.
	 *
	 * @return void
	 */
	public function export() {
		check_admin_referer( self::NONCE_ACTION );
		$this->export_settings();
		$this->output();
	}

	/**
	 * Outputs the export.
	 *
	 * @return void
	 */
	public function output() {
		if ( ! WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ) ) {
			esc_html_e( 'You do not have the required rights to export settings.', 'wordpress-seo' );
			return;
		}

		echo '<p id="wpseo-settings-export-desc">';
		printf(
			/* translators: %1$s expands to Import settings */
			esc_html__(
				'Copy all these settings to another site\'s %1$s tab and click "%1$s" there.',
				'wordpress-seo',
			),
			esc_html__(
				'Import settings',
				'wordpress-seo',
			),
		);
		echo '</p>';
		/* translators: %1$s expands to Yoast SEO */
		echo '<label for="wpseo-settings-export" class="yoast-inline-label">' . sprintf( __( 'Your %1$s settings:', 'wordpress-seo' ), 'Yoast SEO' ) . '</label><br />';
		echo '<textarea id="wpseo-settings-export" rows="20" cols="100" aria-describedby="wpseo-settings-export-desc">' . esc_textarea( $this->export ) . '</textarea>';
	}

	/**
	 * Exports the current site's WP SEO settings.
	 *
	 * @return void
	 */
	private function export_settings() {
		$this->export_header();

		foreach ( WPSEO_Options::get_option_names() as $opt_group ) {
			$this->write_opt_group( $opt_group );
		}
	}

	/**
	 * Writes the header of the export.
	 *
	 * @return void
	 */
	private function export_header() {
		$header = sprintf(
			/* translators: %1$s expands to Yoast SEO, %2$s expands to Yoast.com */
			esc_html__( 'These are settings for the %1$s plugin by %2$s', 'wordpress-seo' ),
			'Yoast SEO',
			'Yoast.com',
		);
		$this->write_line( '; ' . $header );
	}

	/**
	 * Writes a line to the export.
	 *
	 * @param string $line          Line string.
	 * @param bool   $newline_first Boolean flag whether to prepend with new line.
	 *
	 * @return void
	 */
	private function write_line( $line, $newline_first = false ) {
		if ( $newline_first ) {
			$this->export .= PHP_EOL;
		}
		$this->export .= $line . PHP_EOL;
	}

	/**
	 * Writes an entire option group to the export.
	 *
	 * @param string $opt_group Option group name.
	 *
	 * @return void
	 */
	private function write_opt_group( $opt_group ) {

		$this->write_line( '[' . $opt_group . ']', true );

		$options = get_option( $opt_group );

		if ( ! is_array( $options ) ) {
			return;
		}

		foreach ( $options as $key => $elem ) {
			if ( is_array( $elem ) ) {
				$count = count( $elem );
				for ( $i = 0; $i < $count; $i++ ) {
					$elem_check = ( $elem[ $i ] ?? null );
					$this->write_setting( $key . '[]', $elem_check );
				}
			}
			else {
				$this->write_setting( $key, $elem );
			}
		}
	}

	/**
	 * Writes a settings line to the export.
	 *
	 * @param string $key Key string.
	 * @param string $val Value string.
	 *
	 * @return void
	 */
	private function write_setting( $key, $val ) {
		if ( is_string( $val ) ) {
			$val = '"' . $val . '"';
		}
		$this->write_line( $key . ' = ' . $val );
	}
}

Directory Contents

Dirs: 20 × Files: 54

Name Size Perms Modified Actions
ajax DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
endpoints DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
filters DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
formatter DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
import DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
listeners DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
menu DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
metabox DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
notifiers DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
pages DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
roles DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
services DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
taxonomy DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
tracking DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
views DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
watchers DIR
- drwxr-xr-x 2026-06-11 02:40:13
Edit Download
2.39 KB lrw-r--r-- 2024-01-19 15:31:02
Edit Download
11.16 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
1.81 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
1.61 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
488 B lrw-r--r-- 2018-03-20 20:19:04
Edit Download
20.57 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
2.08 KB lrw-r--r-- 2021-10-05 12:07:22
Edit Download
6.35 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
2.55 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
2.70 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
10.72 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
5.98 KB lrw-r--r-- 2024-01-19 15:31:02
Edit Download
3.06 KB lrw-r--r-- 2025-10-08 18:12:28
Edit Download
2.15 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
12.73 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
4.30 KB lrw-r--r-- 2024-10-22 13:45:22
Edit Download
2.05 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
29.43 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
2.23 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
1005 B lrw-r--r-- 2025-04-07 13:46:06
Edit Download
4.93 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
7.51 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
3.46 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
7.08 KB lrw-r--r-- 2025-10-08 18:12:28
Edit Download
2.47 KB lrw-r--r-- 2026-05-27 15:40:30
Edit Download
27.30 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
6.14 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
2.21 KB lrw-r--r-- 2022-05-30 15:34:46
Edit Download
2.84 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
2.26 KB lrw-r--r-- 2024-01-19 15:31:02
Edit Download
3.52 KB lrw-r--r-- 2021-05-18 17:42:44
Edit Download
10.06 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
4.04 KB lrw-r--r-- 2024-04-03 15:08:10
Edit Download
2.81 KB lrw-r--r-- 2025-04-07 13:46:06
Edit Download
7.83 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
7.32 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
5.75 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
3.13 KB lrw-r--r-- 2024-01-19 15:31:02
Edit Download
2.23 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
4.33 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
3.53 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
3.52 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
3.93 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
35.73 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
7.21 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
9.97 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
4.14 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
26.02 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
10.10 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
7.63 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
10.29 KB lrw-r--r-- 2026-02-17 17:17:50
Edit Download
38 B lrw-r--r-- 2015-07-21 17:37:30
Edit Download
257 B lrw-r--r-- 2018-08-28 15:09:12
Edit Download
254 B lrw-r--r-- 2018-03-20 20:19:04
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).