| 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 »' ); ?></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><?php echo do_shortcode('[simpleticker]'); ?></code></div> |
| 159 |
<div style="padding: 5px 35px;"><code><?php echo do_shortcode('[simpleticker ticker1_text="Ticker test!!" ticker1_color="#008000" sticky_posts_display=FALSE]'); ?></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 without using block or shortcode', 'simple-ticker' ); ?></h3> |
| 207 |
<h4><?php esc_html_e( 'Beginning', 'simple-ticker' ); ?></h4> |
| 208 |
<div style="display: block;padding:5px 20px"> |
| 209 |
<input type="checkbox" name="insert_body_open" value="1" <?php checked( '1', $simpleticker_option['insert_body_open'] ); ?> /> |
| 210 |
<?php esc_html_e( 'Beginning', 'simple-ticker' ); ?> |
| 211 |
</div> |
| 212 |
<h4><?php esc_html_e( 'Before and after post', 'simple-ticker' ); ?></h4> |
| 213 |
<div style="display: block;padding:5px 20px"> |
| 214 |
<input type="radio" name="simple_ticker_insert" value="none" |
| 215 |
<?php |
| 216 |
if ( 'none' === $simpleticker_option['insert'] ) { |
| 217 |
echo 'checked';} |
| 218 |
?> |
| 219 |
> |
| 220 |
<?php esc_html_e( 'none' ); ?> |
| 221 |
</div> |
| 222 |
<div style="display: block;padding:5px 20px"> |
| 223 |
<input type="radio" name="simple_ticker_insert" value="before" |
| 224 |
<?php |
| 225 |
if ( 'before' === $simpleticker_option['insert'] ) { |
| 226 |
echo 'checked';} |
| 227 |
?> |
| 228 |
> |
| 229 |
<?php esc_html_e( 'Before post', 'simple-ticker' ); ?> |
| 230 |
</div> |
| 231 |
<div style="display: block;padding:5px 20px"> |
| 232 |
<input type="radio" name="simple_ticker_insert" value="after" |
| 233 |
<?php |
| 234 |
if ( 'after' === $simpleticker_option['insert'] ) { |
| 235 |
echo 'checked';} |
| 236 |
?> |
| 237 |
> |
| 238 |
<?php esc_html_e( 'After post', 'simple-ticker' ); ?> |
| 239 |
</div> |
| 240 |
<div style="display: block;padding:5px 20px"> |
| 241 |
<input type="radio" name="simple_ticker_insert" value="beforeafter" |
| 242 |
<?php |
| 243 |
if ( 'beforeafter' === $simpleticker_option['insert'] ) { |
| 244 |
echo 'checked';} |
| 245 |
?> |
| 246 |
> |
| 247 |
<?php esc_html_e( 'Before and after post', 'simple-ticker' ); ?> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
|
| 251 |
<div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;"> |
| 252 |
|
| 253 |
<div style="display: block; padding:5px 5px;"> |
| 254 |
<h3><?php esc_html_e( 'Own Ticker', 'simple-ticker' ); ?></h3> |
| 255 |
<div style="display: block; padding:5px 20px;"> |
| 256 |
<?php esc_html_e( 'Ticker1', 'simple-ticker' ); ?> : |
| 257 |
<div style="display: block; padding:5px 35px;"> |
| 258 |
<div> |
| 259 |
<?php esc_html_e( 'Text', 'simple-ticker' ); ?> : |
| 260 |
<textarea name="simpleticker_ticker1_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker1']['text'] ); ?></textarea> |
| 261 |
</div> |
| 262 |
<div> |
| 263 |
<?php esc_html_e( 'Color', 'simple-ticker' ); ?> : |
| 264 |
<input type="text" class="jscolor" name="simpleticker_ticker1_color" value="<?php echo esc_attr( $simpleticker_option['ticker1']['color'] ); ?>" size="10" /> |
| 265 |
</div> |
| 266 |
</div> |
| 267 |
</div> |
| 268 |
<div style="display: block; padding:5px 20px;"> |
| 269 |
<?php esc_html_e( 'Ticker2', 'simple-ticker' ); ?> : |
| 270 |
<div style="display: block; padding:5px 35px;"> |
| 271 |
<div> |
| 272 |
<?php esc_html_e( 'Text', 'simple-ticker' ); ?> : |
| 273 |
<textarea name="simpleticker_ticker2_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker2']['text'] ); ?></textarea> |
| 274 |
</div> |
| 275 |
<div> |
| 276 |
<?php esc_html_e( 'Color', 'simple-ticker' ); ?> : |
| 277 |
<input type="text" class="jscolor" name="simpleticker_ticker2_color" value="<?php echo esc_attr( $simpleticker_option['ticker2']['color'] ); ?>" size="10" /> |
| 278 |
</div> |
| 279 |
</div> |
| 280 |
</div> |
| 281 |
<div style="display: block; padding:5px 20px;"> |
| 282 |
<?php esc_html_e( 'Ticker3', 'simple-ticker' ); ?> : |
| 283 |
<div style="display: block; padding:5px 35px;"> |
| 284 |
<div> |
| 285 |
<?php esc_html_e( 'Text', 'simple-ticker' ); ?> : |
| 286 |
<textarea name="simpleticker_ticker3_text" rows="4" cols="40" style="vertical-align: top"><?php echo esc_textarea( $simpleticker_option['ticker3']['text'] ); ?></textarea> |
| 287 |
</div> |
| 288 |
<div> |
| 289 |
<?php esc_html_e( 'Color', 'simple-ticker' ); ?> : |
| 290 |
<input type="text" class="jscolor" name="simpleticker_ticker3_color" value="<?php echo esc_attr( $simpleticker_option['ticker3']['color'] ); ?>" size="10" /> |
| 291 |
</div> |
| 292 |
</div> |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
</div> |
| 296 |
<div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;"> |
| 297 |
<div style="display: block; padding:5px 5px;"> |
| 298 |
<h3><?php esc_html_e( 'Sticky Posts', 'simple-ticker' ); ?></h3> |
| 299 |
<div style="display: block; padding:5px 20px;"> |
| 300 |
<input type="checkbox" name="simpleticker_sticky_posts" value="1" <?php checked( '1', $simpleticker_option['sticky_posts']['display'] ); ?> /> |
| 301 |
<?php esc_html_e( 'Include sticky_posts', 'simple-ticker' ); ?> |
| 302 |
</div> |
| 303 |
<div style="display: block; padding:5px 35px;"> |
| 304 |
<?php esc_html_e( 'Title color', 'simple-ticker' ); ?> : |
| 305 |
<input type="text" class="jscolor" name="simpleticker_sticky_posts_titlecolor" value="<?php echo esc_attr( $simpleticker_option['sticky_posts']['title_color'] ); ?>" size="10" /> |
| 306 |
</div> |
| 307 |
<div style="display: block; padding:5px 35px;"> |
| 308 |
<?php esc_html_e( 'Content color', 'simple-ticker' ); ?> : |
| 309 |
<input type="text" class="jscolor" name="simpleticker_sticky_posts_contentcolor" value="<?php echo esc_attr( $simpleticker_option['sticky_posts']['content_color'] ); ?>" size="10" /> |
| 310 |
</div> |
| 311 |
</div> |
| 312 |
</div> |
| 313 |
<div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;"> |
| 314 |
<div style="display: block; padding:5px 5px;"> |
| 315 |
<h3><?php esc_html_e( 'WooCommerce Sales', 'simple-ticker' ); ?></h3> |
| 316 |
<div style="display: block; padding:5px 20px;"> |
| 317 |
<input type="checkbox" name="simpleticker_woo_sales" value="1" <?php checked( '1', $simpleticker_option['woo_sales']['display'] ); ?> /> |
| 318 |
<?php esc_html_e( 'Include WooCommerce Sales', 'simple-ticker' ); ?> |
| 319 |
</div> |
| 320 |
<div style="display: block; padding:5px 35px;"> |
| 321 |
<?php esc_html_e( 'Color', 'simple-ticker' ); ?> : |
| 322 |
<input type="text" class="jscolor" name="simpleticker_woo_sales_color" value="<?php echo esc_attr( $simpleticker_option['woo_sales']['color'] ); ?>" size="10" /> |
| 323 |
</div> |
| 324 |
<div style="display: block; padding:5px 35px;"> |
| 325 |
<div><?php esc_html_e( 'WooCommerce Sales', 'simple-ticker' ); ?> <?php esc_html_e( 'Tags' ); ?></div> |
| 326 |
<div style="display: block; padding:5px 45px;"> |
| 327 |
<li> |
| 328 |
[<b>%regular_price%</b> : <?php esc_html_e( 'List price', 'simple-ticker' ); ?>] |
| 329 |
[<b>%sale_price%</b> : <?php esc_html_e( 'Sale price', 'simple-ticker' ); ?>] |
| 330 |
[<b>%dis_rate_price%</b> : <?php esc_html_e( 'Discount price', 'simple-ticker' ); ?>] |
| 331 |
[<b>%dis_rate_percent%</b> : <?php esc_html_e( 'Discount rate', 'simple-ticker' ); ?>] |
| 332 |
[<b>%to_date%</b> : <?php esc_html_e( 'Last day of sale', 'simple-ticker' ); ?>] |
| 333 |
[<b>%interval_day%</b> : <?php esc_html_e( 'Remaining number of selling days', 'simple-ticker' ); ?>] |
| 334 |
[<b>%interval_time%</b> : <?php esc_html_e( 'Remaining sales time', 'simple-ticker' ); ?>] |
| 335 |
</li> |
| 336 |
<li><b><?php esc_html_e( 'Please write any letters between tags. You can move and delete tags freely.', 'simple-ticker' ); ?></b></li> |
| 337 |
<div> |
| 338 |
<textarea name="simpleticker_woo_sales_text" style="width: 100%;"><?php echo esc_textarea( $simpleticker_option['woo_sales']['text'] ); ?></textarea> |
| 339 |
</div> |
| 340 |
</div> |
| 341 |
</div> |
| 342 |
</div> |
| 343 |
</div> |
| 344 |
|
| 345 |
<div class="submit"> |
| 346 |
<input type="hidden" name="simpleticker_admin_tabs" value="2" /> |
| 347 |
<input type="submit" class="button" name="Submit" value="<?php esc_attr_e( 'Save Changes' ); ?>" /> |
| 348 |
</div> |
| 349 |
|
| 350 |
</form> |
| 351 |
|
| 352 |
</div> |
| 353 |
</div> |
| 354 |
|
| 355 |
<div id="simpleticker-admin-tabs-3"> |
| 356 |
<div class="wrap"> |
| 357 |
<?php $this->credit(); ?> |
| 358 |
</div> |
| 359 |
</div> |
| 360 |
|
| 361 |
<!-- |
| 362 |
<div id="simpleticker-admin-tabs-4"> |
| 363 |
<div class="wrap"> |
| 364 |
<h2>FAQ</h2> |
| 365 |
|
| 366 |
</div> |
| 367 |
</div> |
| 368 |
--> |
| 369 |
|
| 370 |
</div> |
| 371 |
</div> |
| 372 |
<?php |
| 373 |
|
| 374 |
} |
| 375 |
|
| 376 |
/** ================================================== |
| 377 |
* Credit |
| 378 |
* |
| 379 |
* @since 1.00 |
| 380 |
*/ |
| 381 |
private function credit() { |
| 382 |
|
| 383 |
$plugin_name = null; |
| 384 |
$plugin_ver_num = null; |
| 385 |
$plugin_path = plugin_dir_path( __DIR__ ); |
| 386 |
$plugin_dir = untrailingslashit( $plugin_path ); |
| 387 |
$slugs = explode( '/', $plugin_dir ); |
| 388 |
$slug = end( $slugs ); |
| 389 |
$files = scandir( $plugin_dir ); |
| 390 |
foreach ( $files as $file ) { |
| 391 |
if ( '.' === $file || '..' === $file || is_dir( $plugin_path . $file ) ) { |
| 392 |
continue; |
| 393 |
} else { |
| 394 |
$exts = explode( '.', $file ); |
| 395 |
$ext = strtolower( end( $exts ) ); |
| 396 |
if ( 'php' === $ext ) { |
| 397 |
$plugin_datas = get_file_data( |
| 398 |
$plugin_path . $file, |
| 399 |
array( |
| 400 |
'name' => 'Plugin Name', |
| 401 |
'version' => 'Version', |
| 402 |
) |
| 403 |
); |
| 404 |
if ( array_key_exists( 'name', $plugin_datas ) && ! empty( $plugin_datas['name'] ) && array_key_exists( 'version', $plugin_datas ) && ! empty( $plugin_datas['version'] ) ) { |
| 405 |
$plugin_name = $plugin_datas['name']; |
| 406 |
$plugin_ver_num = $plugin_datas['version']; |
| 407 |
break; |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
} |
| 412 |
$plugin_version = __( 'Version:' ) . ' ' . $plugin_ver_num; |
| 413 |
/* translators: FAQ Link & Slug */ |
| 414 |
$faq = sprintf( esc_html__( 'https://wordpress.org/plugins/%s/faq', '%s' ), $slug ); |
| 415 |
$support = 'https://wordpress.org/support/plugin/' . $slug; |
| 416 |
$review = 'https://wordpress.org/support/view/plugin-reviews/' . $slug; |
| 417 |
$translate = 'https://translate.wordpress.org/projects/wp-plugins/' . $slug; |
| 418 |
$facebook = 'https://www.facebook.com/katsushikawamori/'; |
| 419 |
$twitter = 'https://twitter.com/dodesyo312'; |
| 420 |
$youtube = 'https://www.youtube.com/channel/UC5zTLeyROkvZm86OgNRcb_w'; |
| 421 |
$donate = sprintf( esc_html__( 'https://shop.riverforest-wp.info/donate/', '%s' ), $slug ); |
| 422 |
|
| 423 |
?> |
| 424 |
<span style="font-weight: bold;"> |
| 425 |
<div> |
| 426 |
<?php echo esc_html( $plugin_version ); ?> | |
| 427 |
<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> |
| 428 |
</div> |
| 429 |
<div> |
| 430 |
<a style="text-decoration: none;" href="<?php echo esc_url( $translate ); ?>" target="_blank"> |
| 431 |
<?php |
| 432 |
/* translators: Plugin translation link */ |
| 433 |
echo sprintf( esc_html__( 'Translations for %s' ), esc_html( $plugin_name ) ); |
| 434 |
?> |
| 435 |
</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> |
| 436 |
</div> |
| 437 |
</span> |
| 438 |
|
| 439 |
<div style="width: 250px; height: 180px; margin: 5px; padding: 5px; border: #CCC 2px solid;"> |
| 440 |
<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> |
| 441 |
<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> |
| 442 |
<button type="button" style="margin: 5px; padding: 5px;" onclick="window.open('<?php echo esc_url( $donate ); ?>')"><?php esc_html_e( 'Donate to this plugin »' ); ?></button> |
| 443 |
</div> |
| 444 |
|
| 445 |
<?php |
| 446 |
|
| 447 |
} |
| 448 |
|
| 449 |
/** ================================================== |
| 450 |
* Update wp_options table. |
| 451 |
* |
| 452 |
* @since 1.0 |
| 453 |
*/ |
| 454 |
private function options_updated() { |
| 455 |
|
| 456 |
if ( ! empty( $_POST ) ) { |
| 457 |
if ( isset( $_POST['simpleticker_tabs'] ) && ! empty( $_POST['simpleticker_tabs'] ) ) { |
| 458 |
if ( check_admin_referer( 'simpleticker_settings', 'simpleticker_tabs' ) ) { |
| 459 |
if ( ! empty( $_POST['simpleticker_admin_tabs'] ) ) { |
| 460 |
$tabs = intval( $_POST['simpleticker_admin_tabs'] ); |
| 461 |
} else { |
| 462 |
return; |
| 463 |
} |
| 464 |
include_once( dirname( __FILE__ ) . '/class-simpleticker.php' ); |
| 465 |
$simpleticker = new SimpleTicker(); |
| 466 |
|
| 467 |
$woo_sales_text_tag_def = '%regular_price% %sale_price% %dis_rate_price% %dis_rate_percent% %to_date% %interval_day% %interval_time%'; |
| 468 |
$simple_ticker_reset_tbl = array( |
| 469 |
'speed' => 150, |
| 470 |
'insert_body_open' => false, |
| 471 |
'insert' => 'none', |
| 472 |
'ticker1' => array( |
| 473 |
'text' => '', |
| 474 |
'color' => 'ff0000', |
| 475 |
), |
| 476 |
'ticker2' => array( |
| 477 |
'text' => '', |
| 478 |
'color' => 'ffff00', |
| 479 |
), |
| 480 |
'ticker3' => array( |
| 481 |
'text' => '', |
| 482 |
'color' => '008000', |
| 483 |
), |
| 484 |
'sticky_posts' => array( |
| 485 |
'display' => true, |
| 486 |
'title_color' => 'ff0000', |
| 487 |
'content_color' => '000000', |
| 488 |
), |
| 489 |
'woo_sales' => array( |
| 490 |
'display' => false, |
| 491 |
'color' => '000000', |
| 492 |
'text' => $woo_sales_text_tag_def, |
| 493 |
), |
| 494 |
); |
| 495 |
|
| 496 |
switch ( $tabs ) { |
| 497 |
case 1: |
| 498 |
break; |
| 499 |
case 2: |
| 500 |
if ( ! empty( $_POST['Default'] ) ) { |
| 501 |
update_option( 'simple_ticker', $simple_ticker_reset_tbl ); |
| 502 |
echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Settings' ) . ' --> ' . __( 'Default' ) . ' --> ' . __( 'Changes saved.' ) ) . '</li></ul></div>'; |
| 503 |
} else { |
| 504 |
$simple_ticker_settings = get_option( 'simple_ticker' ); |
| 505 |
if ( ! empty( $_POST['simple_ticker_speed'] ) ) { |
| 506 |
$simple_ticker_settings['speed'] = intval( $_POST['simple_ticker_speed'] ); |
| 507 |
} |
| 508 |
if ( ! empty( $_POST['insert_body_open'] ) ) { |
| 509 |
$simple_ticker_settings['insert_body_open'] = true; |
| 510 |
} else { |
| 511 |
$simple_ticker_settings['insert_body_open'] = false; |
| 512 |
} |
| 513 |
if ( ! empty( $_POST['simple_ticker_insert'] ) ) { |
| 514 |
$simple_ticker_settings['insert'] = sanitize_text_field( wp_unslash( $_POST['simple_ticker_insert'] ) ); |
| 515 |
} |
| 516 |
if ( ! empty( $_POST['simpleticker_ticker1_text'] ) ) { |
| 517 |
$simple_ticker_settings['ticker1']['text'] = $simpleticker->html_text( sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker1_text'] ) ) ); |
| 518 |
} else { |
| 519 |
$simple_ticker_settings['ticker1']['text'] = null; |
| 520 |
} |
| 521 |
if ( ! empty( $_POST['simpleticker_ticker1_color'] ) ) { |
| 522 |
$simple_ticker_settings['ticker1']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker1_color'] ) ); |
| 523 |
} |
| 524 |
if ( ! empty( $_POST['simpleticker_ticker2_text'] ) ) { |
| 525 |
$simple_ticker_settings['ticker2']['text'] = $simpleticker->html_text( sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker2_text'] ) ) ); |
| 526 |
} else { |
| 527 |
$simple_ticker_settings['ticker2']['text'] = null; |
| 528 |
} |
| 529 |
if ( ! empty( $_POST['simpleticker_ticker2_color'] ) ) { |
| 530 |
$simple_ticker_settings['ticker2']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker2_color'] ) ); |
| 531 |
} |
| 532 |
if ( ! empty( $_POST['simpleticker_ticker3_text'] ) ) { |
| 533 |
$simple_ticker_settings['ticker3']['text'] = $simpleticker->html_text( sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker3_text'] ) ) ); |
| 534 |
} else { |
| 535 |
$simple_ticker_settings['ticker3']['text'] = null; |
| 536 |
} |
| 537 |
if ( ! empty( $_POST['simpleticker_ticker3_color'] ) ) { |
| 538 |
$simple_ticker_settings['ticker3']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_ticker3_color'] ) ); |
| 539 |
} |
| 540 |
if ( ! empty( $_POST['simpleticker_sticky_posts'] ) ) { |
| 541 |
$simple_ticker_settings['sticky_posts']['display'] = true; |
| 542 |
} else { |
| 543 |
$simple_ticker_settings['sticky_posts']['display'] = false; |
| 544 |
} |
| 545 |
if ( ! empty( $_POST['simpleticker_sticky_posts_titlecolor'] ) ) { |
| 546 |
$simple_ticker_settings['sticky_posts']['title_color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_sticky_posts_titlecolor'] ) ); |
| 547 |
} |
| 548 |
if ( ! empty( $_POST['simpleticker_sticky_posts_contentcolor'] ) ) { |
| 549 |
$simple_ticker_settings['sticky_posts']['content_color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_sticky_posts_contentcolor'] ) ); |
| 550 |
} |
| 551 |
if ( ! empty( $_POST['simpleticker_woo_sales'] ) ) { |
| 552 |
$simple_ticker_settings['woo_sales']['display'] = true; |
| 553 |
} else { |
| 554 |
$simple_ticker_settings['woo_sales']['display'] = false; |
| 555 |
} |
| 556 |
if ( ! empty( $_POST['simpleticker_woo_sales_color'] ) ) { |
| 557 |
$simple_ticker_settings['woo_sales']['color'] = sanitize_text_field( wp_unslash( $_POST['simpleticker_woo_sales_color'] ) ); |
| 558 |
} |
| 559 |
if ( ! empty( $_POST['simpleticker_woo_sales_text'] ) ) { |
| 560 |
$simple_ticker_settings['woo_sales']['text'] = wp_strip_all_tags( wp_unslash( $_POST['simpleticker_woo_sales_text'] ) ); |
| 561 |
} |
| 562 |
update_option( 'simple_ticker', $simple_ticker_settings ); |
| 563 |
echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html__( 'Settings' ) . ' --> ' . esc_html__( 'Changes saved.' ) . '</li></ul></div>'; |
| 564 |
} |
| 565 |
break; |
| 566 |
} |
| 567 |
unset( $simpleticker ); |
| 568 |
} |
| 569 |
} |
| 570 |
} |
| 571 |
|
| 572 |
} |
| 573 |
|
| 574 |
} |
| 575 |
|
| 576 |
|
| 577 |
|