-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin-page.php
executable file
·257 lines (209 loc) · 11.1 KB
/
admin-page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
/*
===========================================================
ACTION HOOKS
=========================================================== */
add_action('admin_menu', 'ssp_menu_entry');
/*
===========================================================
DECLARE PLUGIN ENTRY FOR THE ADMIN MENU
=========================================================== */
function ssp_menu_entry()
{
add_menu_page('Smart Shopify Product Settings', 'S. Shopify Product', 'administrator', 'smart-shopify-product-settings', 'ssp_settings_page', 'dashicons-products');
}
/*
===========================================================
RENDER PLUGIN ADMIN PAGE
=========================================================== */
function ssp_settings_page()
{
if (!current_user_can('administrator')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
?>
<div id="ssp_admin_page" class="wrap">
<h2>Smart Shopify Product Settings</h2>
<hr>
<h2 class="nav-tab-wrapper">
<a class="nav-tab nav-tab-active" href="#">Shopify API</a>
<a class="nav-tab" href="#">Post Type of Product</a>
<a class="nav-tab" href="#">Shopify fields options</a>
</h2>
<form method="post" action="options.php">
<?php settings_fields('smart-shopify-product-settings-group'); ?>
<?php do_settings_sections('smart-shopify-product-settings-group'); ?>
<div id='sections'>
<section>
<table class="form-table">
<tr valign="top">
<th scope="row">API url</th>
<td>
<input type="text" name="ssp_api_url" size="100"
value="<?php echo esc_attr(get_option('ssp_api_url')); ?>"/>
<br/>
<small><strong>Eg:</strong> https://apikey:[email protected]</small>
</td>
</tr>
<tr valign="top">
<th scope="row">Shop url</th>
<td>
<input type="text" name="ssp_shop_url" size="100"
value="<?php echo esc_attr(get_option('ssp_shop_url')); ?>"/>
<br/>
<small><strong>Eg:</strong> my-shop.myshopify.com</small>
</td>
</tr>
<tr valign="top">
<th scope="row">Access Token</th>
<td>
<input type="text" name="ssp_access_token" size="100"
value="<?php echo esc_attr(get_option('ssp_access_token')); ?>"/>
<br/>
<small>A long randomize string provided by Shopify.</small>
</td>
</tr>
<tr valign="top">
<th scope="row">App ID Number</th>
<td>
<input type="text" name="ssp_app_id" size="100"
value="<?php echo esc_attr(get_option('ssp_app_id')); ?>"/>
<br/>
<small>For Buy Button, usually is 6.</small>
</td>
</tr>
</table>
</section>
<section>
<table class="form-table">
<tr valign="top">
<th scope="row">Post Type Slug</th>
<td>
<input type="text" name="ssp_product_post_type_slug" size="100"
value="<?php echo esc_attr(get_option('ssp_product_post_type_slug')); ?>"/>
<br/>
<small>
Slug of the Post Type for Products you have had created, using Toolset or another
plugin for management of custom Post Type.
<br/> <strong>Eg:</strong> product, shopify-product, sh-product.
</small>
</td>
</tr>
<tr valign="top">
<th scope="row">Product ID Meta Slug</th>
<td>
<input type="text" name="ssp_product_id_meta_slug" size="100"
value="<?php echo esc_attr(get_option('ssp_product_id_meta_slug')); ?>"/>
<br/>
<small>
Slug of the custom field type (or meta) of Shopify Product ID, for the Product Post
Type you have had created, using Toolset or another plugin for management of custom
Post Type.
<br/> <strong>Eg:</strong> product-id, shopify-product-id, sh-product-id.
<br/> <strong>Note:</strong> Custom field created with Toolset plugin have a "wpcf-"
prefix. Eg: wpcf-product-id.
</small>
</td>
</tr>
</table>
</section>
<section>
<table class="form-table">
<tr valign="top">
<th scope="row">Show Shopify price field</th>
<td>
<input type="checkbox"
value="1" <?php echo checked(get_option('ssp_shopify_field_price_show', 1), 1); ?>
name="ssp_shopify_field_price_show"/>
<br/>
<small>
Mean that the price of Shopify products will be shown or not.
</small>
</td>
</tr>
<tr valign="top">
<th scope="row">Replacing text for Shopify price field</th>
<td>
<input type="text" name="ssp_shopify_field_price_text" size="100"
value="<?php echo esc_attr(get_option('ssp_shopify_field_price_text', "")); ?>"/>
<br/>
<small>
If it's not empty, the price of the Shopify products will be replaced with your
replacing text. It's ideal when you don't want to show the prices to users.
</small>
</td>
</tr>
<tr valign="top">
<th scope="row">Show card Buy Button</th>
<td>
<input type="checkbox"
value="1" <?php echo checked(get_option('ssp_shopify_field_card_buy_btn', 1), 1); ?>
name="ssp_shopify_field_card_buy_btn" size="100"/>
<br/>
<small>
If checked, the Buy Button will be shown on the product cards, for collection views
or sections.
</small>
</td>
</tr>
<tr valign="top">
<th scope="row">Show details page Buy Button</th>
<td>
<input type="checkbox"
value="1" <?php echo checked(get_option('ssp_shopify_field_details_buy_btn', 1), 1); ?>
name="ssp_shopify_field_details_buy_btn" size="100"/>
<br/>
<small>
If checked, the Buy Button will be shown on product detail pages.
</small>
</td>
</tr>
<tr valign="top">
<th scope="row">Show Variant Options selector</th>
<td>
<input type="checkbox"
value="1" <?php echo checked(get_option('ssp_shopify_field_variant_selector', 1), 1); ?>
name="ssp_shopify_field_variant_selector" size="100"/>
<br/>
<small>
If checked, the selector of the Variant Options for Shopify products will be shown.
<br/> <strong>Note:</strong> Be careful. If checked and the product that is
currently shown has no items available in stock for the first Variant Option, it
will cause you not able to choice another variant to make shop.
</small>
</td>
</tr>
</table>
</section>
</div>
<?php submit_button(); ?>
</form>
<?php /* Only draw 'refresh' section if plugin is linked to Shopify store */
if (!empty(sanitize_option('ssp_api_url', get_option('ssp_api_url')))
and !empty(sanitize_option('ssp_shop_url', get_option('ssp_shop_url')))
and !empty(sanitize_option('ssp_app_id', get_option('ssp_app_id')))
) : ?>
<hr>
<h3>Import all products</h3>
<form method="POST" id="refresh">
<p class="auto-approve-wrap">
<input type="checkbox" name="auto_approve" value="1" id="auto_approve" checked>
<label for="auto_approve">Publish new products right away (set to Pending Review if
unchecked)</label>
</p>
<p class="submit">
<input type="hidden" name="ssp_product_id_meta_slug" id="ssp_product_id_meta_slug"
value="<?php echo esc_attr(get_option('ssp_product_id_meta_slug')) ?>">
<input type="submit" name="refresh-button" id="ssp-refresh-button" class="button"
value="Refresh Shopify Products">
</p>
</form>
<ul class="refresh-message">
</ul>
<?php
endif;
?>
</div>
<?php
}
/* ======================================================== */