PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 2.2.5
WooCommerce Square v2.2.5
5.5.0 5.4.3 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 6 years ago Settings_Page.php 5 years ago Sync_Page.php 6 years ago
Settings_Page.php
203 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
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
22 */
23
24 namespace WooCommerce\Square\Admin;
25
26 defined( 'ABSPATH' ) || exit;
27
28 use SkyVerge\WooCommerce\PluginFramework\v5_4_0 as Framework;
29 use WooCommerce\Square;
30
31 /**
32 * The settings page class.
33 *
34 * @see \WooCommerce\Square\Settings handles settings registration
35 *
36 * @since 2.0.0
37 */
38 class Settings_Page extends \WC_Settings_Page {
39
40
41 /** @var Square\Settings settings handler instance */
42 protected $settings_handler;
43
44
45 /**
46 * Constructs the settings page.
47 *
48 * @since 2.0.0
49 *
50 * @param Square\Settings $settings_handler a settings handler instance, for displaying and saving the settings
51 */
52 public function __construct( Square\Settings $settings_handler ) {
53
54 $this->id = Square\Plugin::PLUGIN_ID;
55 $this->label = __( 'Square', 'woocommerce-square' );
56 $this->settings_handler = $settings_handler;
57
58 parent::__construct();
59 }
60
61
62 /**
63 * Outputs the settings page.
64 *
65 * @internal
66 *
67 * @since 2.0.0
68 */
69 public function output() {
70 global $current_section;
71
72 if ( 'update' === $current_section ) {
73 $this->output_update_section();
74 } else {
75 $this->output_general_section();
76 }
77 }
78
79
80 /**
81 * Outputs the general settings section.
82 *
83 * @since 2.0.0
84 */
85 private function output_general_section() {
86
87 $this->settings_handler->admin_options();
88 self::output_import_products_modal_template();
89 }
90
91
92 /**
93 * Outputs the "Update" settings section.
94 *
95 * @since 2.0.0
96 */
97 private function output_update_section() {
98 global $hide_save_button;
99
100 // removes the save/update button from the screen
101 $hide_save_button = true;
102
103 Sync_Page::output();
104 }
105
106
107 /**
108 * Saves the settings.
109 *
110 * @internal
111 *
112 * @since 2.0.0
113 */
114 public function save() {
115
116 $this->settings_handler->process_admin_options();
117 }
118
119
120 /**
121 * Gets the settings.
122 *
123 * @since 2.0.0
124 *
125 * @return array
126 */
127 public function get_settings() {
128
129 return (array) apply_filters( 'woocommerce_get_settings_' . $this->get_id(), $this->settings_handler->get_form_fields() );
130 }
131
132
133 /**
134 * Gets the settings sections.
135 *
136 * @internal
137 *
138 * @since 2.0.0
139 *
140 * @return array
141 */
142 public function get_sections() {
143
144 $sections = array(
145 '' => __( 'Settings', 'woocommerce-square' ), // this key is intentionally blank
146 'update' => __( 'Update', 'woocommerce-square' ),
147 );
148
149 /**
150 * Filters the WooCommerce Square settings sections.
151 *
152 * @since 2.0.0
153 *
154 * @param array $sections settings sections
155 */
156 return (array) apply_filters( 'woocommerce_get_sections_' . $this->get_id(), $sections );
157 }
158
159
160 /**
161 * Outputs a backbone modal template for importing products from Square.
162 *
163 * @since 2.0.0
164 */
165 private static function output_import_products_modal_template() {
166
167 ?>
168 <script type="text/template" id="tmpl-wc-square-import-products">
169 <div class="wc-backbone-modal">
170 <div class="wc-backbone-modal-content">
171 <section class="wc-backbone-modal-main" role="main">
172 <header class="wc-backbone-modal-header">
173 <h1><?php esc_html_e( 'Import Products From Square', 'woocommerce-square' ); ?></h1>
174 <button class="modal-close modal-close-link dashicons dashicons-no-alt">
175 <span class="screen-reader-text"><?php esc_html_e( 'Close modal window', 'woocommerce-square' ); ?></span>
176 </button>
177 </header>
178 <article>
179 <?php /* translators: Placeholders: %1$s - <strong>, %2%s - </strong> */ ?>
180 <p><?php printf( esc_html__( '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' ), '<strong>', '</strong>' ); ?></p>
181 <hr>
182 <h4><?php esc_html_e( 'Do you wish to import existing product updates from Square?', 'woocommerce-square' ); ?></h4>
183 <?php /* translators: Placeholders: %1$s - <a> tag linking to WooCommerce Square docs, %2%s - closing </a> tag */ ?>
184 <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>
185 <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>
186 </article>
187 <footer>
188 <div class="inner">
189 <button id="btn-close" class="button button-large"><?php esc_html_e( 'Cancel', 'woocommerce-square' ); ?></button>
190 <button id="btn-ok" class="button button-large button-primary"><?php esc_html_e( 'Import Products', 'woocommerce-square' ); ?></button>
191 </div>
192 </footer>
193 </section>
194 </div>
195 </div>
196 <div class="wc-backbone-modal-backdrop modal-close"></div>
197 </script>
198 <?php
199 }
200
201
202 }
203