PluginProbe
Simple Ticker / 3.03
Simple Ticker v3.03
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 3.03, at lib/class-simpletickeradmin.php

651 lines 29.2 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( 'init', array( $this, 'register_settings' ) );
38
39 add_action( 'admin_menu', array( $this, 'plugin_menu' ) );
40 add_action( 'admin_enqueue_scripts', array( $this, 'load_custom_wp_admin_style' ) );
41 add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
42
43 }
44
45 /** ==================================================
46 * Add a "Settings" link to the plugins page
47 *
48 * @param array $links links array.
49 * @param string $file file.
50 * @return array $links links array.
51 * @since 1.00
52 */
53 public function settings_link( $links, $file ) {
54 static $this_plugin;
55 if ( empty( $this_plugin ) ) {
56 $this_plugin = 'simple-ticker/simpleticker.php';
57 }
58 if ( $file == $this_plugin ) {
59 $links[] = '<a href="' . admin_url( 'options-general.php?page=SimpleTicker' ) . '">' . __( 'Settings' ) . '</a>';
60 }
61 return $links;
62 }
63
64 /** ==================================================
65 * Settings page
66 *
67 * @since 1.00
68 */
69 public function plugin_menu() {
70 add_options_page( 'Simple Ticker Options', 'Simple Ticker', 'manage_options', 'SimpleTicker', array( $this, 'plugin_options' ) );
71 }
72
73 /** ==================================================
74 * Add Css and Script
75 *
76 * @since 1.00
77 */
78 public function load_custom_wp_admin_style() {
79 if ( $this->is_my_plugin_screen() ) {
80 wp_enqueue_style( 'wp-color-picker' );
81 wp_enqueue_script( 'jquery' );
82 wp_enqueue_script( 'colorpicker-admin-js', plugin_dir_url( __DIR__ ) . 'js/jquery.colorpicker.admin.js', array( 'wp-color-picker' ), '1.0.0', false );
83 }
84 }
85
86 /** ==================================================
87 * For only admin style
88 *
89 * @since 1.0
90 */
91 private function is_my_plugin_screen() {
92 $screen = get_current_screen();
93 if ( is_object( $screen ) && 'settings_page_SimpleTicker' == $screen->id ) {
94 return true;
95 } else {
96 return false;
97 }
98 }
99
100 /** ==================================================
101 * Settings page
102 *
103 * @since 1.0
104 */
105 public function plugin_options() {
106
107 if ( ! current_user_can( 'manage_options' ) ) {
108 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );
109 }
110
111 $this->options_updated();
112
113 $scriptname = admin_url( 'options-general.php?page=SimpleTicker' );
114
115 $simpleticker_option = get_option( 'simple_ticker' );
116
117 ?>
118
119 <div class="wrap">
120 <h2>Simple Ticker</h2>
121
122 <details>
123 <summary><strong><?php esc_html_e( 'Various links of this plugin', 'simple-ticker' ); ?></strong></summary>
124 <?php $this->credit(); ?>
125 </details>
126
127 <details style="margin-bottom: 5px;">
128 <summary style="cursor: pointer; padding: 10px; border: 1px solid #ddd; background: #f4f4f4; color: #000;"><strong><?php esc_html_e( 'How to use', 'simple-ticker' ); ?></strong></summary>
129 <h3><?php esc_html_e( 'Set the widget', 'simple-ticker' ); ?></h3>
130 <?php
131 $widget_html = '<a href="' . admin_url( 'widgets.php' ) . '" style="text-decoration: none; word-break: break-all;">' . __( 'Widgets' ) . '[' . __( 'Ticker', 'simple-ticker' ) . ']</a>';
132 ?>
133 <div style="padding: 5px 20px; font-weight: bold;">
134 <?php
135 /* translators: Widget html */
136 echo wp_kses_post( sprintf( __( 'Please set the %1$s.', 'simple-ticker' ), $widget_html ) );
137 ?>
138 </div>
139
140 <hr>
141
142 <h3><?php esc_html_e( 'Set up a shortcode', 'simple-ticker' ); ?></h3>
143
144 <div style="padding: 5px 20px; font-weight: bold;"><?php esc_html_e( 'Example', 'simple-ticker' ); ?></div>
145 <div style="padding: 5px 25px;"><?php esc_html_e( 'to the post or pages', 'simple-ticker' ); ?></div>
146 <div style="padding: 5px 35px;"><code>[simpleticker]</code></div>
147 <div style="padding: 5px 35px;"><code>[simpleticker ticker1_text="Ticker test!!" ticker1_color="#008000" sticky_posts_display=FALSE]</code></div>
148 <div style="padding: 5px 25px;"><?php esc_html_e( 'to the template of the theme', 'simple-ticker' ); ?></div>
149 <div style="padding: 5px 35px;"><code>&lt;?php echo do_shortcode('[simpleticker]'); ?&gt</code></div>
150 <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>
151
152 <div style="padding: 5px 20px; font-weight: bold;"><?php esc_html_e( 'Description of each attribute', 'simple-ticker' ); ?></div>
153
154 <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>
155 <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>
156 <div style="padding: 5px 35px;"><?php esc_html_e( 'Boolean value of sticky_posts', 'simple-ticker' ); ?> : <code>sticky_posts_display</code></div>
157 <div style="padding: 5px 35px;"><?php esc_html_e( 'Title color of sticky_posts', 'simple-ticker' ); ?> : <code>sticky_posts_title_color</code></div>
158 <div style="padding: 5px 35px;"><?php esc_html_e( 'Content color of sticky_posts', 'simple-ticker' ); ?> : <code>sticky_posts_content_color</code></div>
159 <div style="padding: 5px 35px;"><?php esc_html_e( 'Boolean value of WooCommerce sale', 'simple-ticker' ); ?> : <code>woo_sales_display</code></div>
160 <div style="padding: 5px 35px;"><?php esc_html_e( 'Color of WooCommerce sale', 'simple-ticker' ); ?> : <code>woo_sales_color</code></div>
161 <div style="padding: 5px 20px; font-weight: bold;"><?php esc_html_e( 'Attribute value of short codes can also be specified in the "Settings". Attribute value of the short code takes precedence.', 'simple-ticker' ); ?></div>
162 </details>
163
164 <form method="post" action="<?php echo esc_url( $scriptname ); ?>">
165 <?php wp_nonce_field( 'simpleticker_settings', 'simpleticker_tabs' ); ?>
166
167 <details style="margin-bottom: 5px;">
168 <summary style="cursor: pointer; padding: 10px; border: 1px solid #ddd; background: #f4f4f4; color: #000;"><strong><?php esc_html_e( 'Speed adjust', 'simple-ticker' ); ?></strong></summary>
169 <div style="display: block; padding:5px 5px;">
170 <?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' ); ?>
171 </div>
172 </details>
173
174 <details style="margin-bottom: 5px;">
175 <summary style="cursor: pointer; padding: 10px; border: 1px solid #ddd; background: #f4f4f4; color: #000;"><strong><?php esc_html_e( 'Insert without using block or shortcode', 'simple-ticker' ); ?></strong></summary>
176 <div><strong><?php esc_html_e( 'Beginning', 'simple-ticker' ); ?></strong></div>
177 <div style="display: block;padding:5px 20px">
178 <input type="checkbox" name="insert_body_open" value="1" <?php checked( '1', $simpleticker_option['insert_body_open'] ); ?> />
179 <?php esc_html_e( 'Beginning', 'simple-ticker' ); ?>
180 </div>
181 <div><strong><?php esc_html_e( 'Before and after post', 'simple-ticker' ); ?></strong></div>
182 <div style="display: block;padding:5px 20px">
183 <input type="radio" name="simple_ticker_insert" value="none"
184 <?php
185 if ( 'none' === $simpleticker_option['insert'] ) {
186 echo 'checked';}
187 ?>
188 >
189 <?php esc_html_e( 'none' ); ?>
190 </div>
191 <div style="display: block;padding:5px 20px">
192 <input type="radio" name="simple_ticker_insert" value="before"
193 <?php
194 if ( 'before' === $simpleticker_option['insert'] ) {
195 echo 'checked';}
196 ?>
197 >
198 <?php esc_html_e( 'Before post', 'simple-ticker' ); ?>
199 </div>
200 <div style="display: block;padding:5px 20px">
201 <input type="radio" name="simple_ticker_insert" value="after"
202 <?php
203 if ( 'after' === $simpleticker_option['insert'] ) {
204 echo 'checked';}
205 ?>
206 >
207 <?php esc_html_e( 'After post', 'simple-ticker' ); ?>
208 </div>
209 <div style="display: block;padding:5px 20px">
210 <input type="radio" name="simple_ticker_insert" value="beforeafter"
211 <?php
212 if ( 'beforeafter' === $simpleticker_option['insert'] ) {
213 echo 'checked';}
214 ?>
215 >
216 <?php esc_html_e( 'Before and after post', 'simple-ticker' ); ?>
217 </div>
218 </details>
219
220 <details style="margin-bottom: 5px;">
221 <summary style="cursor: pointer; padding: 10px; border: 1px solid #ddd; background: #f4f4f4; color: #000;"><strong><?php esc_html_e( 'Own Ticker', 'simple-ticker' ); ?></strong></summary>
222 <div style="display: block; padding:5px 5px;">
223 <div style="display: block; padding:5px 20px;">
224 <?php esc_html_e( 'Ticker1', 'simple-ticker' ); ?> :
225 <div style="display: block; padding:5px 35px;">
226 <div>
227 <?php esc_html_e( 'Text', 'simple-ticker' ); ?> :
228 <textarea name="simpleticker_ticker1_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker1']['text'] ); ?></textarea>
229 </div>
230 <div>
231 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
232 <input type="text" class="wpcolor" name="simpleticker_ticker1_color" value="<?php echo esc_attr( $simpleticker_option['ticker1']['color'] ); ?>" size="10" />
233 </div>
234 <div>
235 URL :
236 <input type="text" style="width: 100%" name="simpleticker_ticker1_url" value="<?php echo esc_attr( $simpleticker_option['ticker1']['url'] ); ?>" />
237 </div>
238 </div>
239 </div>
240 <div style="display: block; padding:5px 20px;">
241 <?php esc_html_e( 'Ticker2', 'simple-ticker' ); ?> :
242 <div style="display: block; padding:5px 35px;">
243 <div>
244 <?php esc_html_e( 'Text', 'simple-ticker' ); ?> :
245 <textarea name="simpleticker_ticker2_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker2']['text'] ); ?></textarea>
246 </div>
247 <div>
248 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
249 <input type="text" class="wpcolor" name="simpleticker_ticker2_color" value="<?php echo esc_attr( $simpleticker_option['ticker2']['color'] ); ?>" size="10" />
250 </div>
251 <div>
252 URL :
253 <input type="text" style="width: 100%;" name="simpleticker_ticker2_url" value="<?php echo esc_attr( $simpleticker_option['ticker2']['url'] ); ?>" />
254 </div>
255 </div>
256 </div>
257 <div style="display: block; padding:5px 20px;">
258 <?php esc_html_e( 'Ticker3', 'simple-ticker' ); ?> :
259 <div style="display: block; padding:5px 35px;">
260 <div>
261 <?php esc_html_e( 'Text', 'simple-ticker' ); ?> :
262 <textarea name="simpleticker_ticker3_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker3']['text'] ); ?></textarea>
263 </div>
264 <div>
265 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
266 <input type="text" class="wpcolor" name="simpleticker_ticker3_color" value="<?php echo esc_attr( $simpleticker_option['ticker3']['color'] ); ?>" size="10" />
267 </div>
268 <div>
269 URL :
270 <input type="text" style="width: 100%;" name="simpleticker_ticker3_url" value="<?php echo esc_attr( $simpleticker_option['ticker3']['url'] ); ?>" />
271 </div>
272 </div>
273 </div>
274 </div>
275 </details>
276
277 <details style="margin-bottom: 5px;">
278 <summary style="cursor: pointer; padding: 10px; border: 1px solid #ddd; background: #f4f4f4; color: #000;"><strong><?php esc_html_e( 'Sticky Posts', 'simple-ticker' ); ?></strong></summary>
279 <div style="display: block; padding:5px 5px;">
280 <div style="display: block; padding:5px 20px;">
281 <input type="checkbox" name="simpleticker_sticky_posts" value="1" <?php checked( '1', $simpleticker_option['sticky_posts']['display'] ); ?> />
282 <?php esc_html_e( 'Include sticky_posts', 'simple-ticker' ); ?>
283 </div>
284 <div style="display: block; padding:5px 35px;">
285 <?php esc_html_e( 'Title color', 'simple-ticker' ); ?> :
286 <input type="text" class="wpcolor" name="simpleticker_sticky_posts_titlecolor" value="<?php echo esc_attr( $simpleticker_option['sticky_posts']['title_color'] ); ?>" size="10" />
287 </div>
288 <div style="display: block; padding:5px 35px;">
289 <?php esc_html_e( 'Content color', 'simple-ticker' ); ?> :
290 <input type="text" class="wpcolor" name="simpleticker_sticky_posts_contentcolor" value="<?php echo esc_attr( $simpleticker_option['sticky_posts']['content_color'] ); ?>" size="10" />
291 </div>
292 </div>
293 </details>
294
295 <details style="margin-bottom: 5px;">
296 <summary style="cursor: pointer; padding: 10px; border: 1px solid #ddd; background: #f4f4f4; color: #000;"><strong><?php esc_html_e( 'WooCommerce Sales', 'simple-ticker' ); ?></strong></summary>
297 <div style="display: block; padding:5px 5px;">
298 <div style="display: block; padding:5px 20px;">
299 <input type="checkbox" name="simpleticker_woo_sales" value="1" <?php checked( '1', $simpleticker_option['woo_sales']['display'] ); ?> />
300 <?php esc_html_e( 'Include WooCommerce Sales', 'simple-ticker' ); ?>
301 </div>
302 <div style="display: block; padding:5px 35px;">
303 <?php esc_html_e( 'Color', 'simple-ticker' ); ?> :
304 <input type="text" class="wpcolor" name="simpleticker_woo_sales_color" value="<?php echo esc_attr( $simpleticker_option['woo_sales']['color'] ); ?>" size="10" />
305 </div>
306 <div style="display: block; padding:5px 35px;">
307 <div><?php esc_html_e( 'WooCommerce Sales', 'simple-ticker' ); ?> <?php esc_html_e( 'Tags' ); ?></div>
308 <div style="display: block; padding:5px 45px;">
309 <li>
310 [<b>%regular_price%</b> : <?php esc_html_e( 'List price', 'simple-ticker' ); ?>]
311 [<b>%sale_price%</b> : <?php esc_html_e( 'Sale price', 'simple-ticker' ); ?>]
312 [<b>%dis_rate_price%</b> : <?php esc_html_e( 'Discount price', 'simple-ticker' ); ?>]
313 [<b>%dis_rate_percent%</b> : <?php esc_html_e( 'Discount rate', 'simple-ticker' ); ?>]
314 [<b>%to_date%</b> : <?php esc_html_e( 'Last day of sale', 'simple-ticker' ); ?>]
315 [<b>%interval_day%</b> : <?php esc_html_e( 'Remaining number of selling days', 'simple-ticker' ); ?>]
316 [<b>%interval_time%</b> : <?php esc_html_e( 'Remaining sales time', 'simple-ticker' ); ?>]
317 </li>
318 <li><b><?php esc_html_e( 'Please write any letters between tags. You can move and delete tags freely.', 'simple-ticker' ); ?></b></li>
319 <div>
320 <textarea name="simpleticker_woo_sales_text" style="width: 100%;"><?php echo esc_textarea( $simpleticker_option['woo_sales']['text'] ); ?></textarea>
321 </div>
322 </div>
323 </div>
324 </div>
325 </details>
326
327 <div class="submit">
328 <?php submit_button( __( 'Save Changes' ), 'large', 'SaveSimpt', false ); ?>
329 <?php submit_button( __( 'Default' ), 'large', 'Default', false ); ?>
330 </div>
331
332 </form>
333
334 </div>
335 <?php
336
337 }
338
339 /** ==================================================
340 * Credit
341 *
342 * @since 1.00
343 */
344 private function credit() {
345
346 $plugin_name = null;
347 $plugin_ver_num = null;
348 $plugin_path = plugin_dir_path( __DIR__ );
349 $plugin_dir = untrailingslashit( wp_normalize_path( $plugin_path ) );
350 $slugs = explode( '/', $plugin_dir );
351 $slug = end( $slugs );
352 $files = scandir( $plugin_dir );
353 foreach ( $files as $file ) {
354 if ( '.' === $file || '..' === $file || is_dir( $plugin_path . $file ) ) {
355 continue;
356 } else {
357 $exts = explode( '.', $file );
358 $ext = strtolower( end( $exts ) );
359 if ( 'php' === $ext ) {
360 $plugin_datas = get_file_data(
361 $plugin_path . $file,
362 array(
363 'name' => 'Plugin Name',
364 'version' => 'Version',
365 )
366 );
367 if ( array_key_exists( 'name', $plugin_datas ) && ! empty( $plugin_datas['name'] ) && array_key_exists( 'version', $plugin_datas ) && ! empty( $plugin_datas['version'] ) ) {
368 $plugin_name = $plugin_datas['name'];
369 $plugin_ver_num = $plugin_datas['version'];
370 break;
371 }
372 }
373 }
374 }
375 $plugin_version = __( 'Version:' ) . ' ' . $plugin_ver_num;
376 /* translators: FAQ Link & Slug */
377 $faq = sprintf( __( 'https://wordpress.org/plugins/%s/faq', 'simple-ticker' ), $slug );
378 $support = 'https://wordpress.org/support/plugin/' . $slug;
379 $review = 'https://wordpress.org/support/view/plugin-reviews/' . $slug;
380 $translate = 'https://translate.wordpress.org/projects/wp-plugins/' . $slug;
381 $facebook = 'https://www.facebook.com/katsushikawamori/';
382 $twitter = 'https://twitter.com/dodesyo312';
383 $youtube = 'https://www.youtube.com/channel/UC5zTLeyROkvZm86OgNRcb_w';
384 $donate = __( 'https://shop.riverforest-wp.info/donate/', 'simple-ticker' );
385
386 ?>
387 <span style="font-weight: bold;">
388 <div>
389 <?php echo esc_html( $plugin_version ); ?> |
390 <a style="text-decoration: none;" href="<?php echo esc_url( $faq ); ?>" target="_blank" rel="noopener noreferrer">FAQ</a> | <a style="text-decoration: none;" href="<?php echo esc_url( $support ); ?>" target="_blank" rel="noopener noreferrer">Support Forums</a> | <a style="text-decoration: none;" href="<?php echo esc_url( $review ); ?>" target="_blank" rel="noopener noreferrer">Reviews</a>
391 </div>
392 <div>
393 <a style="text-decoration: none;" href="<?php echo esc_url( $translate ); ?>" target="_blank" rel="noopener noreferrer">
394 <?php
395 /* translators: Plugin translation link */
396 echo esc_html( sprintf( __( 'Translations for %s' ), $plugin_name ) );
397 ?>
398 </a> | <a style="text-decoration: none;" href="<?php echo esc_url( $facebook ); ?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-facebook"></span></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $twitter ); ?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-twitter"></span></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $youtube ); ?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-video-alt3"></span></a>
399 </div>
400 </span>
401
402 <div style="width: 250px; height: 180px; margin: 5px; padding: 5px; border: #CCC 2px solid;">
403 <h3><?php esc_html_e( 'Please make a donation if you like my work or would like to further the development of this plugin.', 'simple-ticker' ); ?></h3>
404 <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>
405 <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>
406 </div>
407
408 <?php
409
410 }
411
412 /** ==================================================
413 * Settings register
414 *
415 * @since 1.00
416 */
417 public function register_settings() {
418
419 $woo_sales_text_tag = '%regular_price% %sale_price% %dis_rate_price% %dis_rate_percent% %to_date% %interval_day% %interval_time%';
420 $simple_ticker_tbl = array(
421 'speed' => 150,
422 'insert_body_open' => false,
423 'insert' => 'none',
424 'ticker1' => array(
425 'text' => '',
426 'url' => '',
427 'color' => '#ff0000',
428 ),
429 'ticker2' => array(
430 'text' => '',
431 'url' => '',
432 'color' => '#ffff00',
433 ),
434 'ticker3' => array(
435 'text' => '',
436 'url' => '',
437 'color' => '#008000',
438 ),
439 'sticky_posts' => array(
440 'display' => true,
441 'title_color' => '#ff0000',
442 'content_color' => '#000000',
443 ),
444 'woo_sales' => array(
445 'display' => false,
446 'color' => '#000000',
447 'text' => $woo_sales_text_tag,
448 ),
449 );
450
451 if ( get_option( 'simple_ticker' ) ) {
452 $simple_ticker_settings = get_option( 'simple_ticker' );
453 if ( ! array_key_exists( 'speed', $simple_ticker_settings ) ) {
454 /* ver 2.00 later */
455 $simple_ticker_settings['speed'] = 150;
456 update_option( 'simple_ticker', $simple_ticker_settings );
457 }
458 if ( ! array_key_exists( 'insert', $simple_ticker_settings ) ) {
459 /* ver 2.04 later */
460 $simple_ticker_settings['insert'] = 'none';
461 update_option( 'simple_ticker', $simple_ticker_settings );
462 }
463 if ( ! array_key_exists( 'insert_body_open', $simple_ticker_settings ) ) {
464 /* ver 3.00 later */
465 $simple_ticker_settings['insert_body_open'] = false;
466 update_option( 'simple_ticker', $simple_ticker_settings );
467 }
468 if ( ! array_key_exists( 'woo_sales', $simple_ticker_settings ) ) {
469 /* ver 2.00 later */
470 $simple_ticker_settings['woo_sales']['display'] = false;
471 $simple_ticker_settings['woo_sales']['color'] = '#000000';
472 $simple_ticker_settings['woo_sales']['text'] = $woo_sales_text_tag;
473 update_option( 'simple_ticker', $simple_ticker_settings );
474 }
475 if ( ! array_key_exists( 'url', $simple_ticker_settings['ticker1'] ) ) {
476 /* ver 3.01 later */
477 $simple_ticker_settings['ticker1']['url'] = null;
478 update_option( 'simple_ticker', $simple_ticker_settings );
479 }
480 if ( ! array_key_exists( 'url', $simple_ticker_settings['ticker2'] ) ) {
481 /* ver 3.01 later */
482 $simple_ticker_settings['ticker2']['url'] = null;
483 update_option( 'simple_ticker', $simple_ticker_settings );
484 }
485 if ( ! array_key_exists( 'url', $simple_ticker_settings['ticker3'] ) ) {
486 /* ver 3.01 later */
487 $simple_ticker_settings['ticker3']['url'] = null;
488 update_option( 'simple_ticker', $simple_ticker_settings );
489 }
490 /* 3.02 later */
491 if ( strpos( $simple_ticker_settings['ticker1']['color'], '#' ) === false ) {
492 $simple_ticker_settings['ticker1']['color'] = '#' . $simple_ticker_settings['ticker1']['color'];
493 update_option( 'simple_ticker', $simple_ticker_settings );
494 }
495 if ( strpos( $simple_ticker_settings['ticker2']['color'], '#' ) === false ) {
496 $simple_ticker_settings['ticker2']['color'] = '#' . $simple_ticker_settings['ticker2']['color'];
497 update_option( 'simple_ticker', $simple_ticker_settings );
498 }
499 if ( strpos( $simple_ticker_settings['ticker3']['color'], '#' ) === false ) {
500 $simple_ticker_settings['ticker3']['color'] = '#' . $simple_ticker_settings['ticker3']['color'];
501 update_option( 'simple_ticker', $simple_ticker_settings );
502 }
503 if ( strpos( $simple_ticker_settings['sticky_posts']['title_color'], '#' ) === false ) {
504 $simple_ticker_settings['sticky_posts']['title_color'] = '#' . $simple_ticker_settings['sticky_posts']['title_color'];
505 update_option( 'simple_ticker', $simple_ticker_settings );
506 }
507 if ( strpos( $simple_ticker_settings['sticky_posts']['content_color'], '#' ) === false ) {
508 $simple_ticker_settings['sticky_posts']['content_color'] = '#' . $simple_ticker_settings['sticky_posts']['content_color'];
509 update_option( 'simple_ticker', $simple_ticker_settings );
510 }
511 if ( strpos( $simple_ticker_settings['woo_sales']['color'], '#' ) === false ) {
512 $simple_ticker_settings['woo_sales']['color'] = '#' . $simple_ticker_settings['woo_sales']['color'];
513 update_option( 'simple_ticker', $simple_ticker_settings );
514 }
515 } else {
516 update_option( 'simple_ticker', $simple_ticker_tbl );
517 }
518
519 }
520
521 /** ==================================================
522 * Update wp_options table.
523 *
524 * @since 1.00
525 */
526 private function options_updated() {
527
528 if ( isset( $_POST['Default'] ) && ! empty( $_POST['Default'] ) ) {
529 if ( check_admin_referer( 'simpleticker_settings', 'simpleticker_tabs' ) ) {
530 $woo_sales_text_tag_def = '%regular_price% %sale_price% %dis_rate_price% %dis_rate_percent% %to_date% %interval_day% %interval_time%';
531 $simple_ticker_reset_tbl = array(
532 'speed' => 150,
533 'insert_body_open' => false,
534 'insert' => 'none',
535 'ticker1' => array(
536 'text' => '',
537 'url' => '',
538 'color' => '#ff0000',
539 ),
540 'ticker2' => array(
541 'text' => '',
542 'url' => '',
543 'color' => '#ffff00',
544 ),
545 'ticker3' => array(
546 'text' => '',
547 'url' => '',
548 'color' => '#008000',
549 ),
550 'sticky_posts' => array(
551 'display' => true,
552 'title_color' => '#ff0000',
553 'content_color' => '#000000',
554 ),
555 'woo_sales' => array(
556 'display' => false,
557 'color' => '#000000',
558 'text' => $woo_sales_text_tag_def,
559 ),
560 );
561 update_option( 'simple_ticker', $simple_ticker_reset_tbl );
562 echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Settings' ) . ' --> ' . __( 'Default' ) ) . '</li></ul></div>';
563 }
564 }
565
566 if ( isset( $_POST['SaveSimpt'] ) && ! empty( $_POST['SaveSimpt'] ) ) {
567 if ( check_admin_referer( 'simpleticker_settings', 'simpleticker_tabs' ) ) {
568 $simple_ticker_settings = get_option( 'simple_ticker' );
569 if ( ! empty( $_POST['simple_ticker_speed'] ) ) {
570 $simple_ticker_settings['speed'] = intval( $_POST['simple_ticker_speed'] );
571 }
572 if ( ! empty( $_POST['insert_body_open'] ) ) {
573 $simple_ticker_settings['insert_body_open'] = true;
574 } else {
575 $simple_ticker_settings['insert_body_open'] = false;
576 }
577 if ( ! empty( $_POST['simple_ticker_insert'] ) ) {
578 $simple_ticker_settings['insert'] = sanitize_text_field( wp_unslash( $_POST['simple_ticker_insert'] ) );
579 }
580 if ( ! empty( $_POST['simpleticker_ticker1_text'] ) ) {
581 $simple_ticker_settings['ticker1']['text'] = apply_filters( 'smptck_html_text', sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker1_text'] ) ) );
582 } else {
583 $simple_ticker_settings['ticker1']['text'] = null;
584 }
585 if ( ! empty( $_POST['simpleticker_ticker1_url'] ) ) {
586 $simple_ticker_settings['ticker1']['url'] = esc_url_raw( wp_unslash( $_POST['simpleticker_ticker1_url'] ) );
587 } else {
588 $simple_ticker_settings['ticker1']['url'] = null;
589 }
590 if ( ! empty( $_POST['simpleticker_ticker1_color'] ) ) {
591 $simple_ticker_settings['ticker1']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker1_color'] ) );
592 }
593 if ( ! empty( $_POST['simpleticker_ticker2_text'] ) ) {
594 $simple_ticker_settings['ticker2']['text'] = apply_filters( 'smptck_html_text', sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker2_text'] ) ) );
595 } else {
596 $simple_ticker_settings['ticker2']['text'] = null;
597 }
598 if ( ! empty( $_POST['simpleticker_ticker2_url'] ) ) {
599 $simple_ticker_settings['ticker2']['url'] = esc_url_raw( wp_unslash( $_POST['simpleticker_ticker2_url'] ) );
600 } else {
601 $simple_ticker_settings['ticker2']['url'] = null;
602 }
603 if ( ! empty( $_POST['simpleticker_ticker2_color'] ) ) {
604 $simple_ticker_settings['ticker2']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker2_color'] ) );
605 }
606 if ( ! empty( $_POST['simpleticker_ticker3_text'] ) ) {
607 $simple_ticker_settings['ticker3']['text'] = apply_filters( 'smptck_html_text', sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker3_text'] ) ) );
608 } else {
609 $simple_ticker_settings['ticker3']['text'] = null;
610 }
611 if ( ! empty( $_POST['simpleticker_ticker3_url'] ) ) {
612 $simple_ticker_settings['ticker3']['url'] = esc_url_raw( wp_unslash( $_POST['simpleticker_ticker3_url'] ) );
613 } else {
614 $simple_ticker_settings['ticker3']['url'] = null;
615 }
616 if ( ! empty( $_POST['simpleticker_ticker3_color'] ) ) {
617 $simple_ticker_settings['ticker3']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker3_color'] ) );
618 }
619 if ( ! empty( $_POST['simpleticker_sticky_posts'] ) ) {
620 $simple_ticker_settings['sticky_posts']['display'] = true;
621 } else {
622 $simple_ticker_settings['sticky_posts']['display'] = false;
623 }
624 if ( ! empty( $_POST['simpleticker_sticky_posts_titlecolor'] ) ) {
625 $simple_ticker_settings['sticky_posts']['title_color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_sticky_posts_titlecolor'] ) );
626 }
627 if ( ! empty( $_POST['simpleticker_sticky_posts_contentcolor'] ) ) {
628 $simple_ticker_settings['sticky_posts']['content_color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_sticky_posts_contentcolor'] ) );
629 }
630 if ( ! empty( $_POST['simpleticker_woo_sales'] ) ) {
631 $simple_ticker_settings['woo_sales']['display'] = true;
632 } else {
633 $simple_ticker_settings['woo_sales']['display'] = false;
634 }
635 if ( ! empty( $_POST['simpleticker_woo_sales_color'] ) ) {
636 $simple_ticker_settings['woo_sales']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_woo_sales_color'] ) );
637 }
638 if ( ! empty( $_POST['simpleticker_woo_sales_text'] ) ) {
639 $simple_ticker_settings['woo_sales']['text'] = wp_strip_all_tags( wp_unslash( $_POST['simpleticker_woo_sales_text'] ) );
640 }
641 update_option( 'simple_ticker', $simple_ticker_settings );
642 echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html__( 'Settings' ) . ' --> ' . esc_html__( 'Changes saved.' ) . '</li></ul></div>';
643 }
644 }
645
646 }
647
648 }
649
650
651