Automattic\WooCommerce\Admin\Features\Blueprint\Exporters

ExportWCSettings{}abstractWC 1.0└─ StepExporter, HasAlias

Class ExportWCSettings

This abstract class provides the functionality for exporting WooCommerce settings on a specific page.

No Hooks.

Usage

$ExportWCSettings = new ExportWCSettings();
// use class methods

Methods

  1. public __construct( ?SettingOptions $setting_options = null )
  2. public check_step_capabilities()
  3. public export()
  4. public get_alias()
  5. public get_description()
  6. public get_label()
  7. public get_page_id()
  8. public get_step_name()

Notes

  • Package: Automattic\WooCommerce\Admin\Features\Blueprint\Exporters

ExportWCSettings{} code WC 10.4.3

abstract class ExportWCSettings implements StepExporter, HasAlias {
	use UseWPFunctions;

	/**
	 * The setting options class.
	 *
	 * @var SettingOptions
	 */
	protected $setting_options;

	/**
	 * Constructor.
	 *
	 * @param SettingOptions|null $setting_options The setting options class.
	 */
	public function __construct( ?SettingOptions $setting_options = null ) {
		$this->setting_options = $setting_options ?? new SettingOptions();
	}

	/**
	 * Return a page I.D to export.
	 *
	 * @return string The page ID.
	 */
	abstract protected function get_page_id(): string;

	/**
	 * Export WooCommerce settings.
	 *
	 * @return SetSiteOptions
	 */
	public function export() {
		return new SetSiteOptions( $this->setting_options->get_page_options( $this->get_page_id() ) );
	}


	/**
	 * Get the name of the step.
	 *
	 * @return string
	 */
	public function get_step_name() {
		return 'setSiteOptions';
	}

	/**
	 * Get the alias for this exporter.
	 *
	 * @return string
	 */
	public function get_alias() {
		return 'setWCSettingsGeneral';
	}

	/**
	 * Return label used in the frontend.
	 *
	 * @return string
	 */
	public function get_label() {
		return __( 'General', 'woocommerce' );
	}

	/**
	 * Return description used in the frontend.
	 *
	 * @return string
	 */
	public function get_description() {
		return __( 'Includes all settings in WooCommerce | Settings | General.', 'woocommerce' );
	}

	/**
	 * Check if the current user has the required capabilities for this step.
	 *
	 * @return bool True if the user has the required capabilities. False otherwise.
	 */
	public function check_step_capabilities(): bool {
		return current_user_can( 'manage_woocommerce' );
	}
}