PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 3.8.1
WooCommerce Square v3.8.1
5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / includes / Admin / Settings_Page.php
woocommerce-square / includes / Admin Last commit date
Privacy.php 3 years ago Settings_Page.php 3 years ago Sync_Page.php 3 years ago
Settings_Page.php
199 lines
1 <?php
2 /**
3 * WooCommerce Square
4 *
5 * This source file is subject to the GNU General Public License v3.0
6 * that is bundled with this package in the file license.txt.
7 * It is also available through the world-wide-web at this URL:
8 * http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
9 * If you did not receive a copy of the license and are unable to
10 * obtain it through the world-wide-web, please send an email
11 * to license@woocommerce.com so we can send you a copy immediately.
12 *
13 * DISCLAIMER
14 *
15 * Do not edit or add to this file if you wish to upgrade WooCommerce Square to newer
16 * versions in the future. If you wish to customize WooCommerce Square for your
17 * needs please refer to https://docs.woocommerce.com/document/woocommerce-square/
18 *
19 * @author WooCommerce
20 * @copyright Copyright: (c) 2019, Automattic, Inc.
21 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
22 */
23
24 namespace WooCommerce\Square\Admin;
25
26 defined( 'ABSPATH' ) || exit;
27
28 use WooCommerce\Square;
29
30 /**
31 * The settings page class.
32 *
33 * @see \WooCommerce\Square\Settings handles settings registration
34 *
35 * @since 2.0.0
36 */
37 class Settings_Page extends \WC_Settings_Page {
38
39
40 /** @var Square\Settings settings handler instance */
41 protected $settings_handler;
42
43
44 /**
45 * Constructs the settings page.
46 *
47 * @since 2.0.0
48 *
49 * @param Square\Settings $settings_handler a settings handler instance, for displaying and saving the settings
50 */
51 public function __construct( Square\Settings $settings_handler ) {
52
53 $this->id = Square\Plugin::PLUGIN_ID;
54 $this->label = __( 'Square', 'woocommerce-square' );
55 $this->settings_handler = $settings_handler;
56
57 parent::__construct();
58 }
59
60
61 /**
62 * Outputs the settings page.
63 *
64 * @internal
65 *
66 * @since 2.0.0
67 */
68 public function output() {
69 global $current_section;
70
71 if ( 'update' === $current_section ) {
72 $this->output_update_section();
73 } else {
74 $this->output_general_section();
75 }
76 }
77
78
79 /**
80 * Outputs the general settings section.
81 *
82 * @since 2.0.0
83 */
84 private function output_general_section() {
85
86 $this->settings_handler->admin_options();
87 self::output_import_products_modal_template();
88 }
89
90
91 /**
92 * Outputs the "Update" settings section.
93 *
94 * @since 2.0.0
95 */
96 private function output_update_section() {
97 global $hide_save_button;
98
99 // removes the save/update button from the screen
100 $hide_save_button = true;
101
102 Sync_Page::output();
103 }
104
105
106 /**
107 * Saves the settings.
108 *
109 * @internal
110 *
111 * @since 2.0.0
112 */
113 public function save() {
114
115 $this->settings_handler->process_admin_options();
116 }
117
118
119 /**
120 * Gets the settings.
121 *
122 * @since 2.0.0
123 *
124 * @return array
125 */
126 public function get_settings() {
127
128 return (array) apply_filters( 'woocommerce_get_settings_square', $this->settings_handler->get_form_fields() );
129 }
130
131
132 /**
133 * Gets the settings sections.
134 *
135 * @internal
136 *
137 * @since 2.0.0
138 *
139 * @return array
140 */
141 public function get_sections() {
142
143 $sections = array(
144 '' => __( 'Settings', 'woocommerce-square' ), // this key is intentionally blank
145 'update' => __( 'Update', 'woocommerce-square' ),
146 );
147
148 /**
149 * Filters the WooCommerce Square settings sections.
150 *
151 * @since 2.0.0
152 *
153 * @param array $sections settings sections
154 */
155 return (array) apply_filters( 'woocommerce_get_sections_square', $sections );
156 }
157
158
159 /**
160 * Outputs a backbone modal template for importing products from Square.
161 *
162 * @since 2.0.0
163 */
164 private static function output_import_products_modal_template() {
165
166 ?>
167 <script type="text/template" id="tmpl-wc-square-import-products">
168 <div class="wc-backbone-modal">
169 <div class="wc-backbone-modal-content">
170 <section class="wc-backbone-modal-main" role="main">
171 <header class="wc-backbone-modal-header">
172 <h1><?php esc_html_e( 'Import Products From Square', 'woocommerce-square' ); ?></h1>
173 <button class="modal-close modal-close-link dashicons dashicons-no-alt">
174 <span class="screen-reader-text"><?php esc_html_e( 'Close modal window', 'woocommerce-square' ); ?></span>
175 </button>
176 </header>
177 <article>
178 <p><?php esc_html_e( 'You are about to import all new products, variations and categories from Square. This will create a new product in WooCommerce for every product retrieved from Square. If you have products in the trash from the previous imports, these will be ignored in the import.', 'woocommerce-square' ); ?></p>
179 <hr>
180 <h4><?php esc_html_e( 'Do you wish to import existing product updates from Square?', 'woocommerce-square' ); ?></h4>
181 <?php /* translators: Placeholders: %1$s - <a> tag linking to WooCommerce Square docs, %2%s - closing </a> tag */ ?>
182 <p><?php printf( esc_html__( 'Doing so will update existing WooCommerce products with the latest information from Square. %1$sView Documentation%2$s.', 'woocommerce-square' ), '<a href="https://docs.woocommerce.com/document/woocommerce-square/#section-4">', '</a>' ); ?></p>
183 <label for="wc-square-import-product-updates"><input type="checkbox" id="wc-square-import-product-updates" /><?php esc_html_e( 'Update existing products during import.', 'woocommerce-square' ); ?></label>
184 </article>
185 <footer>
186 <div class="inner">
187 <button id="btn-close" class="button button-large"><?php esc_html_e( 'Cancel', 'woocommerce-square' ); ?></button>
188 <button id="btn-ok" class="button button-large button-primary"><?php esc_html_e( 'Import Products', 'woocommerce-square' ); ?></button>
189 </div>
190 </footer>
191 </section>
192 </div>
193 </div>
194 <div class="wc-backbone-modal-backdrop modal-close"></div>
195 </script>
196 <?php
197 }
198 }
199