PluginProbe
WooCommerce / 11.1.0-rc.2
WooCommerce v11.1.0-rc.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Internal / Admin / Settings / RegisteredSettingsSectionAdapter.php
RegisteredSettingsSectionAdapter.php
82 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Registered settings section adapter for settings UI.
4 */
5
6 declare( strict_types=1 );
7
8 namespace Automattic\WooCommerce\Internal\Admin\Settings;
9
10 use Automattic\WooCommerce\Admin\Settings\SettingsSectionInterface;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Adapts a registered settings section into the settings UI page contract.
16 *
17 * @since 10.9.0
18 */
19 class RegisteredSettingsSectionAdapter extends LegacySettingsPageAdapter {
20
21 /**
22 * Registered settings section.
23 *
24 * @var SettingsSectionInterface
25 */
26 private SettingsSectionInterface $section;
27
28 /**
29 * Constructor.
30 *
31 * @since 10.9.0
32 *
33 * @param \WC_Settings_Page $settings_page Parent settings page.
34 * @param SettingsSectionInterface $section Registered settings section.
35 */
36 public function __construct( \WC_Settings_Page $settings_page, SettingsSectionInterface $section ) {
37 parent::__construct( $settings_page );
38 $this->section = $section;
39 }
40
41 /**
42 * Build the canonical settings schema for the registered section.
43 *
44 * The page is scoped to the registered section, so it is titled with the
45 * section label rather than the parent settings page label.
46 *
47 * @param string $section Unused. This adapter wraps a single registered section.
48 * @return array
49 *
50 * @since 11.0.0
51 */
52 public function get_schema( string $section ): array {
53 $schema = parent::get_schema( $section );
54
55 $label = html_entity_decode( $this->section->get_label(), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 );
56 $schema['title'] = $label;
57 $schema['shell']['title'] = $label;
58
59 return $schema;
60 }
61
62 /**
63 * Get script handles that must be loaded before the settings UI app mounts.
64 *
65 * @param string $section Unused. This adapter wraps a single registered section.
66 * @return string[]
67 */
68 public function get_script_handles( string $section ): array {
69 return $this->section->get_script_handles( $this->settings_page );
70 }
71
72 /**
73 * Get the default save adapter for fields in this section.
74 *
75 * @param string $section Unused. This adapter wraps a single registered section.
76 * @return string
77 */
78 public function get_save_adapter( string $section ): string {
79 return $this->section->get_save_adapter( $this->settings_page );
80 }
81 }
82