PluginProbe
Simple Ticker / 1.0
Simple Ticker v1.0
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 / req / SimpleTickerAdmin.php

SimpleTickerAdmin.php in Simple Ticker 1.0, at req/SimpleTickerAdmin.php

407 lines 15.9 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 Copyright (c) 2016- Katsushi Kawamori (email : dodesyoswift312@gmail.com)
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; version 2 of the License.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 class SimpleTickerAdmin {
23
24 /* ==================================================
25 * Add a "Settings" link to the plugins page
26 * @since 1.0
27 */
28 function settings_link( $links, $file ) {
29 static $this_plugin;
30 if ( empty($this_plugin) ) {
31 $this_plugin = SIMPLETICKER_PLUGIN_BASE_FILE;
32 }
33 if ( $file == $this_plugin ) {
34 $links[] = '<a href="'.admin_url('options-general.php?page=SimpleTicker').'">'.__( 'Settings').'</a>';
35 }
36 return $links;
37 }
38
39 /* ==================================================
40 * Settings page
41 * @since 1.0
42 */
43 function plugin_menu() {
44 add_options_page( 'Simple Ticker Options', 'Simple Ticker', 'manage_options', 'SimpleTicker', array($this, 'plugin_options') );
45 }
46
47 /* ==================================================
48 * Add Css and Script
49 * @since 1.0
50 */
51 function load_custom_wp_admin_style() {
52 if ($this->is_my_plugin_screen()) {
53 wp_enqueue_style( 'jquery-responsiveTabs', SIMPLETICKER_PLUGIN_URL.'/css/responsive-tabs.css' );
54 wp_enqueue_style( 'jquery-responsiveTabs-style', SIMPLETICKER_PLUGIN_URL.'/css/style.css' );
55 wp_enqueue_script('jquery');
56 wp_enqueue_script( 'jquery-responsiveTabs', SIMPLETICKER_PLUGIN_URL.'/js/jquery.responsiveTabs.min.js' );
57 wp_enqueue_script( 'jquery-jscolor', SIMPLETICKER_PLUGIN_URL.'/js/jscolor.min.js' );
58 }
59 }
60
61 /* ==================================================
62 * Add Script on footer
63 * @since 1.0
64 */
65 function load_custom_wp_admin_style2() {
66 if ($this->is_my_plugin_screen()) {
67 echo $this->add_jscss();
68 }
69 }
70
71 /* ==================================================
72 * For only admin style
73 * @since 1.0
74 */
75 function is_my_plugin_screen() {
76 $screen = get_current_screen();
77 if (is_object($screen) && $screen->id == 'settings_page_SimpleTicker') {
78 return TRUE;
79 } else {
80 return FALSE;
81 }
82 }
83
84 /* ==================================================
85 * Settings page
86 * @since 1.0
87 */
88 function plugin_options() {
89
90 if ( !current_user_can( 'manage_options' ) ) {
91 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
92 }
93
94
95 if( !empty($_POST) ) {
96 $post_nonce_field = 'simpleticker_tabs';
97 if ( isset($_POST[$post_nonce_field]) && $_POST[$post_nonce_field] ) {
98 if ( check_admin_referer( 'simpleticker_settings', $post_nonce_field ) ) {
99 $this->options_updated(intval($_POST['simpleticker_admin_tabs']));
100 }
101 }
102 }
103
104 $scriptname = admin_url('options-general.php?page=SimpleTicker');
105
106 $simpleticker_option = get_option('simple_ticker');
107
108 ?>
109
110 <div class="wrap">
111 <h2>Simple Ticker</h2>
112
113 <div id="simpleticker-admin-tabs">
114 <ul>
115 <li><a href="#simpleticker-admin-tabs-1"><?php _e('How to use', 'simple-ticker'); ?></a></li>
116 <li><a href="#simpleticker-admin-tabs-2"><?php _e('Settings'); ?></a></li>
117 <li><a href="#simpleticker-admin-tabs-3"><?php _e('Donate to this plugin &#187;'); ?></a></li>
118 <!--
119 <li><a href="#simpleticker-admin-tabs-4">FAQ</a></li>
120 -->
121 </ul>
122 <div id="simpleticker-admin-tabs-1">
123 <div class="wrap">
124
125 <h2><?php _e('How to use', 'simple-ticker'); ?></h2>
126
127 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
128 <h3><?php _e('Set the widget', 'simple-ticker'); ?></h3>
129 <?php
130 $widget_html = '<a href="'.admin_url('widgets.php').'" style="text-decoration: none; word-break: break-all;">'.__('Widgets').'['.__( 'Ticker', 'simple-ticker' ).']</a>';
131 ?>
132 <div style="padding: 5px 20px; font-weight: bold;"><?php echo sprintf(__('Please set the %1$s.', 'simple-ticker'), $widget_html); ?></div>
133 </div>
134
135 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
136 <h3><?php _e('Set up a shortcode', 'simple-ticker'); ?></h3>
137
138 <div style="padding: 5px 20px; font-weight: bold;"><?php _e('Example', 'simple-ticker'); ?></div>
139 <div style="padding: 5px 25px;"><?php _e('to the post or pages', 'simple-ticker'); ?></div>
140 <div style="padding: 5px 35px;"><code>[simpleticker]</code></div>
141 <div style="padding: 5px 35px;"><code>[simpleticker ticker1_text="Ticker test!!" ticker1_color="#008000" sticky_posts_display=FALSE]</code></div>
142 <div style="padding: 5px 25px;"><?php _e('to the template of the theme', 'simple-ticker'); ?></div>
143 <div style="padding: 5px 35px;"><code>&lt;?php echo do_shortcode('[simpleticker]'); ?&gt</code></div>
144 <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>
145
146 <div style="padding: 5px 20px; font-weight: bold;"><?php _e('Description of each attribute', 'simple-ticker'); ?></div>
147
148 <div style="padding: 5px 35px;"><?php _e('Text of ticker', 'simple-ticker'); ?> : <code>ticker1_text</code> <code>ticker2_text</code> <code>ticker3_text</code></div>
149 <div style="padding: 5px 35px;"><?php _e('Color of ticker', 'simple-ticker'); ?> : <code>ticker1_color</code> <code>ticker2_color</code> <code>ticker3_color</code></div>
150 <div style="padding: 5px 35px;"><?php _e('Boolean value of sticky_posts', 'simple-ticker'); ?> : <code>sticky_posts_display</code></div>
151 <div style="padding: 5px 35px;"><?php _e('Title color of sticky_posts', 'simple-ticker'); ?> : <code>sticky_posts_title_color</code></div>
152 <div style="padding: 5px 35px;"><?php _e('Content color of sticky_posts', 'simple-ticker'); ?> : <code>sticky_posts_content_color</code></div>
153
154 <?php
155 $settings_html = '<a href="'.$scriptname.'#simpleticker-admin-tabs-2" style="text-decoration: none; word-break: break-all;">'.__('Settings', 'simple-ticker').'</a>';
156 ?>
157 <div style="padding: 5px 20px; font-weight: bold;"><?php echo 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); ?></div>
158 </div>
159
160 </div>
161 </div>
162
163 <div id="simpleticker-admin-tabs-2">
164 <div class="wrap">
165
166 <h2><?php _e('Settings'); ?></h2>
167
168 <form method="post" action="<?php echo $scriptname.'#simpleticker-admin-tabs-2'; ?>">
169 <?php wp_nonce_field('simpleticker_settings', 'simpleticker_tabs'); ?>
170
171 <div class="submit">
172 <input type="submit" class="button" name="Submit" value="<?php _e('Save Changes') ?>" />
173 <input type="submit" class="button" name="Default" value="<?php _e('Default') ?>" />
174 </div>
175
176 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
177
178 <div style="display: block; padding:5px 5px;">
179 <h3><?php _e('Own Ticker', 'simple-ticker'); ?></h3>
180 <div style="display: block; padding:5px 20px;">
181 <?php _e('Ticker1', 'simple-ticker'); ?> :
182 <div style="display: block; padding:5px 35px;">
183 <div>
184 <?php _e('Text', 'simple-ticker'); ?> :
185 <textarea name="simpleticker_ticker1_text" rows="4" cols="40" style="vertical-align: top"><?php echo $simpleticker_option['ticker1']['text']; ?></textarea>
186 </div>
187 <div>
188 <?php _e('Color', 'simple-ticker'); ?> :
189 <input type="text" class="jscolor" name="simpleticker_ticker1_color" value="<?php echo $simpleticker_option['ticker1']['color']; ?>" size="10" />
190 </div>
191 </div>
192 </div>
193 <div style="display: block; padding:5px 20px;">
194 <?php _e('Ticker2', 'simple-ticker'); ?> :
195 <div style="display: block; padding:5px 35px;">
196 <div>
197 <?php _e('Text', 'simple-ticker'); ?> :
198 <textarea name="simpleticker_ticker2_text" rows="4" cols="40" style="vertical-align: top"><?php echo $simpleticker_option['ticker2']['text']; ?></textarea>
199 </div>
200 <div>
201 <?php _e('Color', 'simple-ticker'); ?> :
202 <input type="text" class="jscolor" name="simpleticker_ticker2_color" value="<?php echo $simpleticker_option['ticker2']['color']; ?>" size="10" />
203 </div>
204 </div>
205 </div>
206 <div style="display: block; padding:5px 20px;">
207 <?php _e('Ticker3', 'simple-ticker'); ?> :
208 <div style="display: block; padding:5px 35px;">
209 <div>
210 <?php _e('Text', 'simple-ticker'); ?> :
211 <textarea name="simpleticker_ticker3_text" rows="4" cols="40" style="vertical-align: top"><?php echo $simpleticker_option['ticker3']['text']; ?></textarea>
212 </div>
213 <div>
214 <?php _e('Color', 'simple-ticker'); ?> :
215 <input type="text" class="jscolor" name="simpleticker_ticker3_color" value="<?php echo $simpleticker_option['ticker3']['color']; ?>" size="10" />
216 </div>
217 </div>
218 </div>
219 </div>
220 </div>
221 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
222 <div style="display: block; padding:5px 5px;">
223 <h3><?php _e('Sticky Posts', 'simple-ticker'); ?></h3>
224 <div style="display: block; padding:5px 20px;">
225 <input type="checkbox" name="simpleticker_sticky_posts" value="1" <?php checked('1', $simpleticker_option['sticky_posts']['display']); ?> />
226 <?php _e('Include sticky_posts', 'simple-ticker'); ?>
227 </div>
228 <div style="display: block; padding:5px 35px;">
229 <?php _e('Title color', 'simple-ticker'); ?> :
230 <input type="text" class="jscolor" name="simpleticker_sticky_posts_titlecolor" value="<?php echo $simpleticker_option['sticky_posts']['title_color']; ?>" size="10" />
231 </div>
232 <div style="display: block; padding:5px 35px;">
233 <?php _e('Content color', 'simple-ticker'); ?> :
234 <input type="text" class="jscolor" name="simpleticker_sticky_posts_contentcolor" value="<?php echo $simpleticker_option['sticky_posts']['content_color']; ?>" size="10" />
235 </div>
236 </div>
237 </div>
238
239 <div class="submit">
240 <input type="hidden" name="simpleticker_admin_tabs" value="2" />
241 <input type="submit" class="button" name="Submit" value="<?php _e('Save Changes') ?>" />
242 </div>
243
244 </form>
245
246 </div>
247 </div>
248
249 <div id="simpleticker-admin-tabs-3">
250 <div class="wrap">
251 <?php
252 $plugin_datas = get_file_data( SIMPLETICKER_PLUGIN_BASE_DIR.'/simpleticker.php', array('version' => 'Version') );
253 $plugin_version = __('Version:').' '.$plugin_datas['version'];
254 ?>
255 <h4 style="margin: 5px; padding: 5px;">
256 <?php echo $plugin_version; ?> |
257 <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/simple-ticker" target="_blank"><?php _e('Support Forums') ?></a> |
258 <a style="text-decoration: none;" href="https://wordpress.org/support/view/plugin-reviews/simple-ticker" target="_blank"><?php _e('Reviews', 'simple-ticker') ?></a>
259 </h4>
260 <div style="width: 250px; height: 170px; margin: 5px; padding: 5px; border: #CCC 2px solid;">
261 <h3><?php _e('Please make a donation if you like my work or would like to further the development of this plugin.', 'simple-ticker'); ?></h3>
262 <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>
263 <a style="margin: 5px; padding: 5px;" href='https://pledgie.com/campaigns/28307' target="_blank"><img alt='Click here to lend your support to: Various Plugins for WordPress and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/28307.png?skin_name=chrome' border='0' ></a>
264 </div>
265 </div>
266 </div>
267
268 <!--
269 <div id="simpleticker-admin-tabs-4">
270 <div class="wrap">
271 <h2>FAQ</h2>
272
273 </div>
274 </div>
275 -->
276
277 </div>
278 </div>
279 <?php
280
281 }
282
283 /* ==================================================
284 * Update wp_options table.
285 * @param string $tabs
286 * @since 1.0
287 */
288 function options_updated($tabs){
289
290
291 include_once( SIMPLETICKER_PLUGIN_BASE_DIR . '/inc/SimpleTicker.php' );
292 $simpleticker = new SimpleTicker();
293
294 $simple_ticker_reset_tbl = array(
295 'ticker1' => array(
296 'text' => '',
297 'color' => '#ff0000'
298 ),
299 'ticker2' => array(
300 'text' => '',
301 'color' => '#ffff00'
302 ),
303 'ticker3' => array(
304 'text' => '',
305 'color' => '#008000'
306 ),
307 'sticky_posts' => array(
308 'display' => TRUE,
309 'title_color' => '#ff0000',
310 'content_color' => '#000000'
311 )
312 );
313
314 switch ($tabs) {
315 case 1:
316 break;
317 case 2:
318 if ( !empty($_POST['Default']) ) {
319 update_option( 'simple_ticker', $simple_ticker_reset_tbl );
320 echo '<div class="updated"><ul><li>'.__('Settings').' --> '.__('Default').' --> '.__('Changes saved.').'</li></ul></div>';
321 } else {
322 if ( !empty($_POST['simpleticker_ticker1_text']) ) {
323 $simpleticker_ticker1_text = $_POST['simpleticker_ticker1_text'];
324 } else {
325 $simpleticker_ticker1_text = NULL;
326 }
327 if ( !empty($_POST['simpleticker_ticker2_text']) ) {
328 $simpleticker_ticker2_text = $_POST['simpleticker_ticker2_text'];
329 } else {
330 $simpleticker_ticker2_text = NULL;
331 }
332 if ( !empty($_POST['simpleticker_ticker3_text']) ) {
333 $simpleticker_ticker3_text = $_POST['simpleticker_ticker3_text'];
334 } else {
335 $simpleticker_ticker3_text = NULL;
336 }
337 if ( !empty($_POST['simpleticker_sticky_posts']) ) {
338 $simpleticker_sticky_posts = intval($_POST['simpleticker_sticky_posts']);
339 } else {
340 $simpleticker_sticky_posts = FALSE;
341 }
342 $simple_ticker_tbl = array(
343 'ticker1' => array(
344 'text' => $simpleticker->html_text($simpleticker_ticker1_text),
345 'color' => $_POST['simpleticker_ticker1_color']
346 ),
347 'ticker2' => array(
348 'text' => $simpleticker->html_text($simpleticker_ticker2_text),
349 'color' => $_POST['simpleticker_ticker2_color']
350 ),
351 'ticker3' => array(
352 'text' => $simpleticker->html_text($simpleticker_ticker3_text),
353 'color' => $_POST['simpleticker_ticker3_color']
354 ),
355 'sticky_posts' => array(
356 'display' => $simpleticker_sticky_posts,
357 'title_color' => $_POST['simpleticker_sticky_posts_titlecolor'],
358 'content_color' => $_POST['simpleticker_sticky_posts_contentcolor']
359 )
360 );
361 update_option( 'simple_ticker', $simple_ticker_tbl );
362 echo '<div class="updated"><ul><li>'.__('Settings').' --> '.__('Changes saved.').'</li></ul></div>';
363 }
364 break;
365 }
366
367 unset($simpleticker);
368
369 return;
370
371 }
372
373 /* ==================================================
374 * Add js css
375 * @since 1.0
376 */
377 function add_jscss(){
378
379 // JS
380 $simpleticker_add_jscss = <<<SIMPLETICKER
381
382 <!-- BEGIN: Simple Ticker -->
383 <script type="text/javascript">
384 jQuery('#simpleticker-admin-tabs').responsiveTabs({
385 startCollapsed: 'accordion'
386 });
387 </script>
388 <script type="text/javascript">
389 jQuery('input[type!="submit"][type!="button"]').keypress(function(e){
390 if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
391 return false;
392 }else{
393 return true;
394 }
395 });
396 </script>
397 <!-- END: Simple Ticker -->
398
399 SIMPLETICKER;
400
401 return $simpleticker_add_jscss;
402
403 }
404
405 }
406
407 ?>