PluginProbe
Simple Ticker / 2.09
Simple Ticker v2.09
trunk 1.0 1.01 1.02 1.03 1.04 1.05 1.06 1.07 2.00 2.01 2.02 2.03 2.04 2.05 2.06 2.07 2.08 2.09 2.10 2.11 3.00 3.01 3.02 3.03 All 33 releases
simple-ticker / lib / class-simpletickeradmin.php

class-simpletickeradmin.php in Simple Ticker 2.09, at lib/class-simpletickeradmin.php

559 lines 24.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Simple Ticker
4 *
5 * @package SimpleTicker
6 * @subpackage SimpleTicker Management screen
7 /*
8 Copyright (c) 2016- Katsushi Kawamori (email : dodesyoswift312@gmail.com)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 $simpletickeradmin = new SimpleTickerAdmin();
24
25 /** ==================================================
26 * Management screen
27 */
28 class SimpleTickerAdmin {
29
30 /** ==================================================
31 * Construct
32 *
33 * @since 1.06
34 */
35 public function __construct() {
36
37 add_action( 'admin_menu', array( $this, 'plugin_menu' ) );
38 add_action( 'admin_enqueue_scripts', array( $this, 'load_custom_wp_admin_style' ) );
39 add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
40
41 }
42
43 /** ==================================================
44 * Add a "Settings" link to the plugins page
45 *
46 * @param array $links links array.
47 * @param string $file file.
48 * @return array $links links array.
49 * @since 1.00
50 */
51 public function settings_link( $links, $file ) {
52 static $this_plugin;
53 if ( empty( $this_plugin ) ) {
54 $this_plugin = 'simple-ticker/simpleticker.php';
55 }
56 if ( $file == $this_plugin ) {
57 $links[] = '<a href="' . admin_url( 'options-general.php?page=SimpleTicker' ) . '">' . __( 'Settings' ) . '</a>';
58 }
59 return $links;
60 }
61
62 /** ==================================================
63 * Settings page
64 *
65 * @since 1.0
66 */
67 public function plugin_menu() {
68 add_options_page( 'Simple Ticker Options', 'Simple Ticker', 'manage_options', 'SimpleTicker', array( $this, 'plugin_options' ) );
69 }
70
71 /** ==================================================
72 * Add Css and Script
73 *
74 * @since 1.0
75 */
76 public function load_custom_wp_admin_style() {
77 if ( $this->is_my_plugin_screen() ) {
78 wp_enqueue_style( 'jquery-responsiveTabs', plugin_dir_url( __DIR__ ) . 'css/responsive-tabs.css', array(), '1.4.0' );
79 wp_enqueue_style( 'jquery-responsiveTabs-style', plugin_dir_url( __DIR__ ) . 'css/style.css', array(), '1.4.0' );
80 wp_enqueue_script( 'jquery' );
81 wp_enqueue_script( 'jquery-responsiveTabs', plugin_dir_url( __DIR__ ) . 'js/jquery.responsiveTabs.min.js', array(), '1.4.0', false );
82 wp_enqueue_script( 'jquery-jscolor', plugin_dir_url( __DIR__ ) . 'js/jscolor.min.js', array(), '2.0.5', false );
83 wp_enqueue_script( 'simpleticker-js', plugin_dir_url( __DIR__ ) . 'js/jquery.simpleticker.js', array( 'jquery' ), '1.00', false );
84 }
85 }
86
87 /** ==================================================
88 * For only admin style
89 *
90 * @since 1.0
91 */
92 private function is_my_plugin_screen() {
93 $screen = get_current_screen();
94 if ( is_object( $screen ) && 'settings_page_SimpleTicker' == $screen->id ) {
95 return true;
96 } else {
97 return false;
98 }
99 }
100
101 /** ==================================================
102 * Settings page
103 *
104 * @since 1.0
105 */
106 public function plugin_options() {
107
108 if ( ! current_user_can( 'manage_options' ) ) {
109 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );
110 }
111
112 $this->options_updated();
113
114 $scriptname = admin_url( 'options-general.php?page=SimpleTicker' );
115
116 $simpleticker_option = get_option( 'simple_ticker' );
117
118 ?>
119
120 <div class="wrap">
121 <h2>Simple Ticker</h2>
122
123 <div id="simpleticker-admin-tabs">
124 <ul>
125 <li><a href="#simpleticker-admin-tabs-1"><?php esc_html_e( 'How to use', 'simple-ticker' ); ?></a></li>
126 <li><a href="#simpleticker-admin-tabs-2"><?php esc_html_e( 'Settings' ); ?></a></li>
127 <li><a href="#simpleticker-admin-tabs-3"><?php esc_html_e( 'Donate to this plugin &#187;' ); ?></a></li>
128 <!--
129 <li><a href="#simpleticker-admin-tabs-4">FAQ</a></li>
130 -->
131 </ul>
132 <div id="simpleticker-admin-tabs-1">
133 <div class="wrap">
134
135 <h2><?php esc_html_e( 'How to use', 'simple-ticker' ); ?></h2>
136
137 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
138 <h3><?php esc_html_e( 'Set the widget', 'simple-ticker' ); ?></h3>
139 <?php
140 $widget_html = '<a href="' . admin_url( 'widgets.php' ) . '" style="text-decoration: none; word-break: break-all;">' . __( 'Widgets' ) . '[' . __( 'Ticker', 'simple-ticker' ) . ']</a>';
141 ?>
142 <div style="padding: 5px 20px; font-weight: bold;">
143 <?php
144 /* translators: Widget html */
145 echo wp_kses_post( sprintf( __( 'Please set the %1$s.', 'simple-ticker' ), $widget_html ) );
146 ?>
147 </div>
148 </div>
149
150 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
151 <h3><?php esc_html_e( 'Set up a shortcode', 'simple-ticker' ); ?></h3>
152
153 <div style="padding: 5px 20px; font-weight: bold;"><?php esc_html_e( 'Example', 'simple-ticker' ); ?></div>
154 <div style="padding: 5px 25px;"><?php esc_html_e( 'to the post or pages', 'simple-ticker' ); ?></div>
155 <div style="padding: 5px 35px;"><code>[simpleticker]</code></div>
156 <div style="padding: 5px 35px;"><code>[simpleticker ticker1_text="Ticker test!!" ticker1_color="#008000" sticky_posts_display=FALSE]</code></div>
157 <div style="padding: 5px 25px;"><?php esc_html_e( 'to the template of the theme', 'simple-ticker' ); ?></div>
158 <div style="padding: 5px 35px;"><code>&lt;?php echo do_shortcode('[simpleticker]'); ?&gt</code></div>
159 <div style="padding: 5px 35px;"><code>&lt;?php echo do_shortcode('[simpleticker ticker1_text="Ticker test!!" ticker1_color="#008000" sticky_posts_display=FALSE]'); ?&gt</code></div>
160
161 <div style="padding: 5px 20px; font-weight: bold;"><?php esc_html_e( 'Description of each attribute', 'simple-ticker' ); ?></div>
162
163 <div style="padding: 5px 35px;"><?php esc_html_e( 'Text of ticker', 'simple-ticker' ); ?> : <code>ticker1_text</code> <code>ticker2_text</code> <code>ticker3_text</code></div>
164 <div style="padding: 5px 35px;"><?php esc_html_e( 'Color of ticker', 'simple-ticker' ); ?> : <code>ticker1_color</code> <code>ticker2_color</code> <code>ticker3_color</code></div>
165 <div style="padding: 5px 35px;"><?php esc_html_e( 'Boolean value of sticky_posts', 'simple-ticker' ); ?> : <code>sticky_posts_display</code></div>
166 <div style="padding: 5px 35px;"><?php esc_html_e( 'Title color of sticky_posts', 'simple-ticker' ); ?> : <code>sticky_posts_title_color</code></div>
167 <div style="padding: 5px 35px;"><?php esc_html_e( 'Content color of sticky_posts', 'simple-ticker' ); ?> : <code>sticky_posts_content_color</code></div>
168 <div style="padding: 5px 35px;"><?php esc_html_e( 'Boolean value of WooCommerce sale', 'simple-ticker' ); ?> : <code>woo_sales_display</code></div>
169 <div style="padding: 5px 35px;"><?php esc_html_e( 'Color of WooCommerce sale', 'simple-ticker' ); ?> : <code>woo_sales_color</code></div>
170
171 <?php
172 $settings_html = '<a href="' . $scriptname . '#simpleticker-admin-tabs-2" style="text-decoration: none; word-break: break-all;">' . __( 'Settings', 'simple-ticker' ) . '</a>';
173 ?>
174 <div style="padding: 5px 20px; font-weight: bold;">
175 <?php
176 /* translators: Settings link */
177 echo wp_kses_post( sprintf( __( 'Attribute value of short codes can also be specified in the %1$s. Attribute value of the short code takes precedence.', 'simple-ticker' ), $settings_html ) );
178 ?>
179 </div>
180 </div>
181
182 </div>
183 </div>
184
185 <div id="simpleticker-admin-tabs-2">
186 <div class="wrap">
187
188 <h2><?php esc_html_e( 'Settings' ); ?></h2>
189
190 <form method="post" action="<?php echo esc_url( $scriptname . '#simpleticker-admin-tabs-2' ); ?>">
191 <?php wp_nonce_field( 'simpleticker_settings', 'simpleticker_tabs' ); ?>
192
193 <div class="submit">
194 <input type="submit" class="button" name="Submit" value="<?php esc_attr_e( 'Save Changes' ); ?>" />
195 <input type="submit" class="button" name="Default" value="<?php esc_attr_e( 'Default' ); ?>" />
196 </div>
197
198 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
199 <div style="display: block; padding:5px 5px;">
200 <h3><?php esc_html_e( 'Speed adjust', 'simple-ticker' ); ?></h3>
201 <?php esc_html_e( 'Up', 'simple-ticker' ); ?><input type="range" style="vertical-align:middle;" step="1" min="20" max="280" name="simple_ticker_speed" value="<?php echo esc_attr( intval( $simpleticker_option['speed'] ) ); ?>" /><?php esc_html_e( 'Down', 'simple-ticker' ); ?>
202 </div>
203 </div>
204
205 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
206 <h3><?php esc_html_e( 'Insert before and after post without using shortcode', 'simple-ticker' ); ?></h3>
207 <div style="display: block;padding:5px 20px">
208 <input type="radio" name="simple_ticker_insert" value="none"
209 <?php
210 if ( 'none' === $simpleticker_option['insert'] ) {
211 echo 'checked';}
212 ?>
213 >
214 <?php esc_html_e( 'none' ); ?>
215 </div>
216 <div style="display: block;padding:5px 20px">
217 <input type="radio" name="simple_ticker_insert" value="before"
218 <?php
219 if ( 'before' === $simpleticker_option['insert'] ) {
220 echo 'checked';}
221 ?>
222 >
223 <?php esc_html_e( 'Before post', 'simple-ticker' ); ?>
224 </div>
225 <div style="display: block;padding:5px 20px">
226 <input type="radio" name="simple_ticker_insert" value="after"
227 <?php
228 if ( 'after' === $simpleticker_option['insert'] ) {
229 echo 'checked';}
230 ?>
231 >
232 <?php esc_html_e( 'After post', 'simple-ticker' ); ?>
233 </div>
234 <div style="display: block;padding:5px 20px">
235 <input type="radio" name="simple_ticker_insert" value="beforeafter"
236 <?php
237 if ( 'beforeafter' === $simpleticker_option['insert'] ) {
238 echo 'checked';}
239 ?>
240 >
241 <?php esc_html_e( 'Before and after post', 'simple-ticker' ); ?>
242 </div>
243 </div>
244
245 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
246
247 <div style="display: block; padding:5px 5px;">
248 <h3><?php esc_html_e( 'Own Ticker', 'simple-ticker' ); ?></h3>
249 <div style="display: block; padding:5px 20px;">
250 <?php esc_html_e( 'Ticker1', 'simple-ticker' ); ?> :
251 <div style="display: block; padding:5px 35px;">
252 <div>
253 <?php esc_html_e( 'Text', 'simple-ticker' ); ?> :
254 <textarea name="simpleticker_ticker1_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker1']['text'] ); ?></textarea>
255 </div>
256 <div>
257 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
258 <input type="text" class="jscolor" name="simpleticker_ticker1_color" value="<?php echo esc_attr( $simpleticker_option['ticker1']['color'] ); ?>" size="10" />
259 </div>
260 </div>
261 </div>
262 <div style="display: block; padding:5px 20px;">
263 <?php esc_html_e( 'Ticker2', 'simple-ticker' ); ?> :
264 <div style="display: block; padding:5px 35px;">
265 <div>
266 <?php esc_html_e( 'Text', 'simple-ticker' ); ?> :
267 <textarea name="simpleticker_ticker2_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker2']['text'] ); ?></textarea>
268 </div>
269 <div>
270 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
271 <input type="text" class="jscolor" name="simpleticker_ticker2_color" value="<?php echo esc_attr( $simpleticker_option['ticker2']['color'] ); ?>" size="10" />
272 </div>
273 </div>
274 </div>
275 <div style="display: block; padding:5px 20px;">
276 <?php esc_html_e( 'Ticker3', 'simple-ticker' ); ?> :
277 <div style="display: block; padding:5px 35px;">
278 <div>
279 <?php esc_html_e( 'Text', 'simple-ticker' ); ?> :
280 <textarea name="simpleticker_ticker3_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker3']['text'] ); ?></textarea>
281 </div>
282 <div>
283 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
284 <input type="text" class="jscolor" name="simpleticker_ticker3_color" value="<?php echo esc_attr( $simpleticker_option['ticker3']['color'] ); ?>" size="10" />
285 </div>
286 </div>
287 </div>
288 </div>
289 </div>
290 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
291 <div style="display: block; padding:5px 5px;">
292 <h3><?php esc_html_e( 'Sticky Posts', 'simple-ticker' ); ?></h3>
293 <div style="display: block; padding:5px 20px;">
294 <input type="checkbox" name="simpleticker_sticky_posts" value="1" <?php checked( '1', $simpleticker_option['sticky_posts']['display'] ); ?> />
295 <?php esc_html_e( 'Include sticky_posts', 'simple-ticker' ); ?>
296 </div>
297 <div style="display: block; padding:5px 35px;">
298 <?php esc_html_e( 'Title color', 'simple-ticker' ); ?> :
299 <input type="text" class="jscolor" name="simpleticker_sticky_posts_titlecolor" value="<?php echo esc_attr( $simpleticker_option['sticky_posts']['title_color'] ); ?>" size="10" />
300 </div>
301 <div style="display: block; padding:5px 35px;">
302 <?php esc_html_e( 'Content color', 'simple-ticker' ); ?> :
303 <input type="text" class="jscolor" name="simpleticker_sticky_posts_contentcolor" value="<?php echo esc_attr( $simpleticker_option['sticky_posts']['content_color'] ); ?>" size="10" />
304 </div>
305 </div>
306 </div>
307 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
308 <div style="display: block; padding:5px 5px;">
309 <h3><?php esc_html_e( 'WooCommerce Sales', 'simple-ticker' ); ?></h3>
310 <div style="display: block; padding:5px 20px;">
311 <input type="checkbox" name="simpleticker_woo_sales" value="1" <?php checked( '1', $simpleticker_option['woo_sales']['display'] ); ?> />
312 <?php esc_html_e( 'Include WooCommerce Sales', 'simple-ticker' ); ?>
313 </div>
314 <div style="display: block; padding:5px 35px;">
315 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
316 <input type="text" class="jscolor" name="simpleticker_woo_sales_color" value="<?php echo esc_attr( $simpleticker_option['woo_sales']['color'] ); ?>" size="10" />
317 </div>
318 <div style="display: block; padding:5px 35px;">
319 <div><?php esc_html_e( 'WooCommerce Sales', 'simple-ticker' ); ?> <?php esc_html_e( 'Tags' ); ?></div>
320 <div style="display: block; padding:5px 45px;">
321 <li>
322 [<b>%regular_price%</b> : <?php esc_html_e( 'List price', 'simple-ticker' ); ?>]
323 [<b>%sale_price%</b> : <?php esc_html_e( 'Sale price', 'simple-ticker' ); ?>]
324 [<b>%dis_rate_price%</b> : <?php esc_html_e( 'Discount price', 'simple-ticker' ); ?>]
325 [<b>%dis_rate_percent%</b> : <?php esc_html_e( 'Discount rate', 'simple-ticker' ); ?>]
326 [<b>%to_date%</b> : <?php esc_html_e( 'Last day of sale', 'simple-ticker' ); ?>]
327 [<b>%interval_day%</b> : <?php esc_html_e( 'Remaining number of selling days', 'simple-ticker' ); ?>]
328 [<b>%interval_time%</b> : <?php esc_html_e( 'Remaining sales time', 'simple-ticker' ); ?>]
329 </li>
330 <li><b><?php esc_html_e( 'Please write any letters between tags. You can move and delete tags freely.', 'simple-ticker' ); ?></b></li>
331 <div>
332 <textarea name="simpleticker_woo_sales_text" style="width: 100%;"><?php echo esc_textarea( $simpleticker_option['woo_sales']['text'] ); ?></textarea>
333 </div>
334 </div>
335 </div>
336 </div>
337 </div>
338
339 <div class="submit">
340 <input type="hidden" name="simpleticker_admin_tabs" value="2" />
341 <input type="submit" class="button" name="Submit" value="<?php esc_attr_e( 'Save Changes' ); ?>" />
342 </div>
343
344 </form>
345
346 </div>
347 </div>
348
349 <div id="simpleticker-admin-tabs-3">
350 <div class="wrap">
351 <?php $this->credit(); ?>
352 </div>
353 </div>
354
355 <!--
356 <div id="simpleticker-admin-tabs-4">
357 <div class="wrap">
358 <h2>FAQ</h2>
359
360 </div>
361 </div>
362 -->
363
364 </div>
365 </div>
366 <?php
367
368 }
369
370 /** ==================================================
371 * Credit
372 *
373 * @since 1.00
374 */
375 private function credit() {
376
377 $plugin_name = null;
378 $plugin_ver_num = null;
379 $plugin_path = plugin_dir_path( __DIR__ );
380 $plugin_dir = untrailingslashit( $plugin_path );
381 $slugs = explode( '/', $plugin_dir );
382 $slug = end( $slugs );
383 $files = scandir( $plugin_dir );
384 foreach ( $files as $file ) {
385 if ( '.' === $file || '..' === $file || is_dir( $plugin_path . $file ) ) {
386 continue;
387 } else {
388 $exts = explode( '.', $file );
389 $ext = strtolower( end( $exts ) );
390 if ( 'php' === $ext ) {
391 $plugin_datas = get_file_data(
392 $plugin_path . $file,
393 array(
394 'name' => 'Plugin Name',
395 'version' => 'Version',
396 )
397 );
398 if ( array_key_exists( 'name', $plugin_datas ) && ! empty( $plugin_datas['name'] ) && array_key_exists( 'version', $plugin_datas ) && ! empty( $plugin_datas['version'] ) ) {
399 $plugin_name = $plugin_datas['name'];
400 $plugin_ver_num = $plugin_datas['version'];
401 break;
402 }
403 }
404 }
405 }
406 $plugin_version = __( 'Version:' ) . ' ' . $plugin_ver_num;
407 /* translators: FAQ Link & Slug */
408 $faq = sprintf( esc_html__( 'https://wordpress.org/plugins/%s/faq', '%s' ), $slug );
409 $support = 'https://wordpress.org/support/plugin/' . $slug;
410 $review = 'https://wordpress.org/support/view/plugin-reviews/' . $slug;
411 $translate = 'https://translate.wordpress.org/projects/wp-plugins/' . $slug;
412 $facebook = 'https://www.facebook.com/katsushikawamori/';
413 $twitter = 'https://twitter.com/dodesyo312';
414 $youtube = 'https://www.youtube.com/channel/UC5zTLeyROkvZm86OgNRcb_w';
415 $donate = sprintf( esc_html__( 'https://shop.riverforest-wp.info/donate/', '%s' ), $slug );
416
417 ?>
418 <span style="font-weight: bold;">
419 <div>
420 <?php echo esc_html( $plugin_version ); ?> |
421 <a style="text-decoration: none;" href="<?php echo esc_url( $faq ); ?>" target="_blank"><?php esc_html_e( 'FAQ' ); ?></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $support ); ?>" target="_blank"><?php esc_html_e( 'Support Forums' ); ?></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $review ); ?>" target="_blank"><?php sprintf( esc_html_e( 'Reviews', '%s' ), $slug ); ?></a>
422 </div>
423 <div>
424 <a style="text-decoration: none;" href="<?php echo esc_url( $translate ); ?>" target="_blank">
425 <?php
426 /* translators: Plugin translation link */
427 echo sprintf( esc_html__( 'Translations for %s' ), esc_html( $plugin_name ) );
428 ?>
429 </a> | <a style="text-decoration: none;" href="<?php echo esc_url( $facebook ); ?>" target="_blank"><span class="dashicons dashicons-facebook"></span></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $twitter ); ?>" target="_blank"><span class="dashicons dashicons-twitter"></span></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $youtube ); ?>" target="_blank"><span class="dashicons dashicons-video-alt3"></span></a>
430 </div>
431 </span>
432
433 <div style="width: 250px; height: 180px; margin: 5px; padding: 5px; border: #CCC 2px solid;">
434 <h3><?php sprintf( esc_html_e( 'Please make a donation if you like my work or would like to further the development of this plugin.', '%s' ), $slug ); ?></h3>
435 <div style="text-align: right; margin: 5px; padding: 5px;"><span style="padding: 3px; color: #ffffff; background-color: #008000">Plugin Author</span> <span style="font-weight: bold;">Katsushi Kawamori</span></div>
436 <button type="button" style="margin: 5px; padding: 5px;" onclick="window.open('<?php echo esc_url( $donate ); ?>')"><?php esc_html_e( 'Donate to this plugin &#187;' ); ?></button>
437 </div>
438
439 <?php
440
441 }
442
443 /** ==================================================
444 * Update wp_options table.
445 *
446 * @since 1.0
447 */
448 private function options_updated() {
449
450 if ( ! empty( $_POST ) ) {
451 if ( isset( $_POST['simpleticker_tabs'] ) && ! empty( $_POST['simpleticker_tabs'] ) ) {
452 if ( check_admin_referer( 'simpleticker_settings', 'simpleticker_tabs' ) ) {
453 if ( ! empty( $_POST['simpleticker_admin_tabs'] ) ) {
454 $tabs = intval( $_POST['simpleticker_admin_tabs'] );
455 } else {
456 return;
457 }
458 include_once( dirname( __FILE__ ) . '/class-simpleticker.php' );
459 $simpleticker = new SimpleTicker();
460
461 $woo_sales_text_tag_def = '%regular_price% %sale_price% %dis_rate_price% %dis_rate_percent% %to_date% %interval_day% %interval_time%';
462 $simple_ticker_reset_tbl = array(
463 'speed' => 150,
464 'insert' => 'none',
465 'ticker1' => array(
466 'text' => '',
467 'color' => 'ff0000',
468 ),
469 'ticker2' => array(
470 'text' => '',
471 'color' => 'ffff00',
472 ),
473 'ticker3' => array(
474 'text' => '',
475 'color' => '008000',
476 ),
477 'sticky_posts' => array(
478 'display' => true,
479 'title_color' => 'ff0000',
480 'content_color' => '000000',
481 ),
482 'woo_sales' => array(
483 'display' => false,
484 'color' => '000000',
485 'text' => $woo_sales_text_tag_def,
486 ),
487 );
488
489 switch ( $tabs ) {
490 case 1:
491 break;
492 case 2:
493 if ( ! empty( $_POST['Default'] ) ) {
494 update_option( 'simple_ticker', $simple_ticker_reset_tbl );
495 echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Settings' ) . ' --> ' . __( 'Default' ) . ' --> ' . __( 'Changes saved.' ) ) . '</li></ul></div>';
496 } else {
497 $simple_ticker_settings = get_option( 'simple_ticker' );
498 if ( ! empty( $_POST['simple_ticker_speed'] ) ) {
499 $simple_ticker_settings['speed'] = intval( $_POST['simple_ticker_speed'] );
500 }
501 if ( ! empty( $_POST['simple_ticker_insert'] ) ) {
502 $simple_ticker_settings['insert'] = sanitize_text_field( wp_unslash( $_POST['simple_ticker_insert'] ) );
503 }
504 if ( ! empty( $_POST['simpleticker_ticker1_text'] ) ) {
505 $simple_ticker_settings['ticker1']['text'] = $simpleticker->html_text( sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker1_text'] ) ) );
506 }
507 if ( ! empty( $_POST['simpleticker_ticker1_color'] ) ) {
508 $simple_ticker_settings['ticker1']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker1_color'] ) );
509 }
510 if ( ! empty( $_POST['simpleticker_ticker2_text'] ) ) {
511 $simple_ticker_settings['ticker2']['text'] = $simpleticker->html_text( sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker2_text'] ) ) );
512 }
513 if ( ! empty( $_POST['simpleticker_ticker2_color'] ) ) {
514 $simple_ticker_settings['ticker2']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker2_color'] ) );
515 }
516 if ( ! empty( $_POST['simpleticker_ticker3_text'] ) ) {
517 $simple_ticker_settings['ticker3']['text'] = $simpleticker->html_text( sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker3_text'] ) ) );
518 }
519 if ( ! empty( $_POST['simpleticker_ticker3_color'] ) ) {
520 $simple_ticker_settings['ticker3']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker3_color'] ) );
521 }
522 if ( ! empty( $_POST['simpleticker_sticky_posts'] ) ) {
523 $simple_ticker_settings['sticky_posts']['display'] = intval( $_POST['simpleticker_sticky_posts'] );
524 } else {
525 $simple_ticker_settings['sticky_posts']['display'] = false;
526 }
527 if ( ! empty( $_POST['simpleticker_sticky_posts_titlecolor'] ) ) {
528 $simple_ticker_settings['sticky_posts']['title_color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_sticky_posts_titlecolor'] ) );
529 }
530 if ( ! empty( $_POST['simpleticker_sticky_posts_contentcolor'] ) ) {
531 $simple_ticker_settings['sticky_posts']['content_color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_sticky_posts_contentcolor'] ) );
532 }
533 if ( ! empty( $_POST['simpleticker_woo_sales'] ) ) {
534 $simple_ticker_settings['woo_sales']['display'] = intval( $_POST['simpleticker_woo_sales'] );
535 } else {
536 $simple_ticker_settings['woo_sales']['display'] = false;
537 }
538 if ( ! empty( $_POST['simpleticker_woo_sales_color'] ) ) {
539 $simple_ticker_settings['woo_sales']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_woo_sales_color'] ) );
540 }
541 if ( ! empty( $_POST['simpleticker_woo_sales_text'] ) ) {
542 $simple_ticker_settings['woo_sales']['text'] = wp_strip_all_tags( wp_unslash( $_POST['simpleticker_woo_sales_text'] ) );
543 }
544 update_option( 'simple_ticker', $simple_ticker_settings );
545 echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html__( 'Settings' ) . ' --> ' . esc_html__( 'Changes saved.' ) . '</li></ul></div>';
546 }
547 break;
548 }
549 unset( $simpleticker );
550 }
551 }
552 }
553
554 }
555
556 }
557
558
559