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

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

366 lines 15.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 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 wp_enqueue_script( 'simpleticker-js', SIMPLETICKER_PLUGIN_URL.'/js/jquery.simpleticker.js', array('jquery') );
59 }
60 }
61
62 /* ==================================================
63 * For only admin style
64 * @since 1.0
65 */
66 function is_my_plugin_screen() {
67 $screen = get_current_screen();
68 if (is_object($screen) && $screen->id == 'settings_page_SimpleTicker') {
69 return TRUE;
70 } else {
71 return FALSE;
72 }
73 }
74
75 /* ==================================================
76 * Settings page
77 * @since 1.0
78 */
79 function plugin_options() {
80
81 if ( !current_user_can( 'manage_options' ) ) {
82 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
83 }
84
85
86 if( !empty($_POST) ) {
87 $post_nonce_field = 'simpleticker_tabs';
88 if ( isset($_POST[$post_nonce_field]) && $_POST[$post_nonce_field] ) {
89 if ( check_admin_referer( 'simpleticker_settings', $post_nonce_field ) ) {
90 $this->options_updated(intval($_POST['simpleticker_admin_tabs']));
91 }
92 }
93 }
94
95 $scriptname = admin_url('options-general.php?page=SimpleTicker');
96
97 $simpleticker_option = get_option('simple_ticker');
98
99 ?>
100
101 <div class="wrap">
102 <h2>Simple Ticker</h2>
103
104 <div id="simpleticker-admin-tabs">
105 <ul>
106 <li><a href="#simpleticker-admin-tabs-1"><?php _e('How to use', 'simple-ticker'); ?></a></li>
107 <li><a href="#simpleticker-admin-tabs-2"><?php _e('Settings'); ?></a></li>
108 <li><a href="#simpleticker-admin-tabs-3"><?php _e('Donate to this plugin &#187;'); ?></a></li>
109 <!--
110 <li><a href="#simpleticker-admin-tabs-4">FAQ</a></li>
111 -->
112 </ul>
113 <div id="simpleticker-admin-tabs-1">
114 <div class="wrap">
115
116 <h2><?php _e('How to use', 'simple-ticker'); ?></h2>
117
118 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
119 <h3><?php _e('Set the widget', 'simple-ticker'); ?></h3>
120 <?php
121 $widget_html = '<a href="'.admin_url('widgets.php').'" style="text-decoration: none; word-break: break-all;">'.__('Widgets').'['.__( 'Ticker', 'simple-ticker' ).']</a>';
122 ?>
123 <div style="padding: 5px 20px; font-weight: bold;"><?php echo sprintf(__('Please set the %1$s.', 'simple-ticker'), $widget_html); ?></div>
124 </div>
125
126 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
127 <h3><?php _e('Set up a shortcode', 'simple-ticker'); ?></h3>
128
129 <div style="padding: 5px 20px; font-weight: bold;"><?php _e('Example', 'simple-ticker'); ?></div>
130 <div style="padding: 5px 25px;"><?php _e('to the post or pages', 'simple-ticker'); ?></div>
131 <div style="padding: 5px 35px;"><code>[simpleticker]</code></div>
132 <div style="padding: 5px 35px;"><code>[simpleticker ticker1_text="Ticker test!!" ticker1_color="#008000" sticky_posts_display=FALSE]</code></div>
133 <div style="padding: 5px 25px;"><?php _e('to the template of the theme', 'simple-ticker'); ?></div>
134 <div style="padding: 5px 35px;"><code>&lt;?php echo do_shortcode('[simpleticker]'); ?&gt</code></div>
135 <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>
136
137 <div style="padding: 5px 20px; font-weight: bold;"><?php _e('Description of each attribute', 'simple-ticker'); ?></div>
138
139 <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>
140 <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>
141 <div style="padding: 5px 35px;"><?php _e('Boolean value of sticky_posts', 'simple-ticker'); ?> : <code>sticky_posts_display</code></div>
142 <div style="padding: 5px 35px;"><?php _e('Title color of sticky_posts', 'simple-ticker'); ?> : <code>sticky_posts_title_color</code></div>
143 <div style="padding: 5px 35px;"><?php _e('Content color of sticky_posts', 'simple-ticker'); ?> : <code>sticky_posts_content_color</code></div>
144
145 <?php
146 $settings_html = '<a href="'.$scriptname.'#simpleticker-admin-tabs-2" style="text-decoration: none; word-break: break-all;">'.__('Settings', 'simple-ticker').'</a>';
147 ?>
148 <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>
149 </div>
150
151 </div>
152 </div>
153
154 <div id="simpleticker-admin-tabs-2">
155 <div class="wrap">
156
157 <h2><?php _e('Settings'); ?></h2>
158
159 <form method="post" action="<?php echo $scriptname.'#simpleticker-admin-tabs-2'; ?>">
160 <?php wp_nonce_field('simpleticker_settings', 'simpleticker_tabs'); ?>
161
162 <div class="submit">
163 <input type="submit" class="button" name="Submit" value="<?php _e('Save Changes') ?>" />
164 <input type="submit" class="button" name="Default" value="<?php _e('Default') ?>" />
165 </div>
166
167 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
168
169 <div style="display: block; padding:5px 5px;">
170 <h3><?php _e('Own Ticker', 'simple-ticker'); ?></h3>
171 <div style="display: block; padding:5px 20px;">
172 <?php _e('Ticker1', 'simple-ticker'); ?> :
173 <div style="display: block; padding:5px 35px;">
174 <div>
175 <?php _e('Text', 'simple-ticker'); ?> :
176 <textarea name="simpleticker_ticker1_text" rows="4" cols="40" style="vertical-align: top"><?php echo $simpleticker_option['ticker1']['text']; ?></textarea>
177 </div>
178 <div>
179 <?php _e('Color', 'simple-ticker'); ?> :
180 <input type="text" class="jscolor" name="simpleticker_ticker1_color" value="<?php echo $simpleticker_option['ticker1']['color']; ?>" size="10" />
181 </div>
182 </div>
183 </div>
184 <div style="display: block; padding:5px 20px;">
185 <?php _e('Ticker2', 'simple-ticker'); ?> :
186 <div style="display: block; padding:5px 35px;">
187 <div>
188 <?php _e('Text', 'simple-ticker'); ?> :
189 <textarea name="simpleticker_ticker2_text" rows="4" cols="40" style="vertical-align: top"><?php echo $simpleticker_option['ticker2']['text']; ?></textarea>
190 </div>
191 <div>
192 <?php _e('Color', 'simple-ticker'); ?> :
193 <input type="text" class="jscolor" name="simpleticker_ticker2_color" value="<?php echo $simpleticker_option['ticker2']['color']; ?>" size="10" />
194 </div>
195 </div>
196 </div>
197 <div style="display: block; padding:5px 20px;">
198 <?php _e('Ticker3', 'simple-ticker'); ?> :
199 <div style="display: block; padding:5px 35px;">
200 <div>
201 <?php _e('Text', 'simple-ticker'); ?> :
202 <textarea name="simpleticker_ticker3_text" rows="4" cols="40" style="vertical-align: top"><?php echo $simpleticker_option['ticker3']['text']; ?></textarea>
203 </div>
204 <div>
205 <?php _e('Color', 'simple-ticker'); ?> :
206 <input type="text" class="jscolor" name="simpleticker_ticker3_color" value="<?php echo $simpleticker_option['ticker3']['color']; ?>" size="10" />
207 </div>
208 </div>
209 </div>
210 </div>
211 </div>
212 <div style="width: 100%; height: 100%; margin: 5px; padding: 5px; border: #CCC 2px solid;">
213 <div style="display: block; padding:5px 5px;">
214 <h3><?php _e('Sticky Posts', 'simple-ticker'); ?></h3>
215 <div style="display: block; padding:5px 20px;">
216 <input type="checkbox" name="simpleticker_sticky_posts" value="1" <?php checked('1', $simpleticker_option['sticky_posts']['display']); ?> />
217 <?php _e('Include sticky_posts', 'simple-ticker'); ?>
218 </div>
219 <div style="display: block; padding:5px 35px;">
220 <?php _e('Title color', 'simple-ticker'); ?> :
221 <input type="text" class="jscolor" name="simpleticker_sticky_posts_titlecolor" value="<?php echo $simpleticker_option['sticky_posts']['title_color']; ?>" size="10" />
222 </div>
223 <div style="display: block; padding:5px 35px;">
224 <?php _e('Content color', 'simple-ticker'); ?> :
225 <input type="text" class="jscolor" name="simpleticker_sticky_posts_contentcolor" value="<?php echo $simpleticker_option['sticky_posts']['content_color']; ?>" size="10" />
226 </div>
227 </div>
228 </div>
229
230 <div class="submit">
231 <input type="hidden" name="simpleticker_admin_tabs" value="2" />
232 <input type="submit" class="button" name="Submit" value="<?php _e('Save Changes') ?>" />
233 </div>
234
235 </form>
236
237 </div>
238 </div>
239
240 <div id="simpleticker-admin-tabs-3">
241 <div class="wrap">
242 <?php
243 $plugin_datas = get_file_data( SIMPLETICKER_PLUGIN_BASE_DIR.'/simpleticker.php', array('version' => 'Version') );
244 $plugin_version = __('Version:').' '.$plugin_datas['version'];
245 ?>
246 <h4 style="margin: 5px; padding: 5px;">
247 <?php echo $plugin_version; ?> |
248 <a style="text-decoration: none;" href="https://wordpress.org/support/plugin/simple-ticker" target="_blank"><?php _e('Support Forums') ?></a> |
249 <a style="text-decoration: none;" href="https://wordpress.org/support/view/plugin-reviews/simple-ticker" target="_blank"><?php _e('Reviews', 'simple-ticker') ?></a>
250 </h4>
251 <div style="width: 250px; height: 170px; margin: 5px; padding: 5px; border: #CCC 2px solid;">
252 <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>
253 <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>
254 <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>
255 </div>
256 </div>
257 </div>
258
259 <!--
260 <div id="simpleticker-admin-tabs-4">
261 <div class="wrap">
262 <h2>FAQ</h2>
263
264 </div>
265 </div>
266 -->
267
268 </div>
269 </div>
270 <?php
271
272 }
273
274 /* ==================================================
275 * Update wp_options table.
276 * @param string $tabs
277 * @since 1.0
278 */
279 function options_updated($tabs){
280
281
282 include_once( SIMPLETICKER_PLUGIN_BASE_DIR . '/inc/SimpleTicker.php' );
283 $simpleticker = new SimpleTicker();
284
285 $simple_ticker_reset_tbl = array(
286 'ticker1' => array(
287 'text' => '',
288 'color' => '#ff0000'
289 ),
290 'ticker2' => array(
291 'text' => '',
292 'color' => '#ffff00'
293 ),
294 'ticker3' => array(
295 'text' => '',
296 'color' => '#008000'
297 ),
298 'sticky_posts' => array(
299 'display' => TRUE,
300 'title_color' => '#ff0000',
301 'content_color' => '#000000'
302 )
303 );
304
305 switch ($tabs) {
306 case 1:
307 break;
308 case 2:
309 if ( !empty($_POST['Default']) ) {
310 update_option( 'simple_ticker', $simple_ticker_reset_tbl );
311 echo '<div class="updated"><ul><li>'.__('Settings').' --> '.__('Default').' --> '.__('Changes saved.').'</li></ul></div>';
312 } else {
313 if ( !empty($_POST['simpleticker_ticker1_text']) ) {
314 $simpleticker_ticker1_text = $_POST['simpleticker_ticker1_text'];
315 } else {
316 $simpleticker_ticker1_text = NULL;
317 }
318 if ( !empty($_POST['simpleticker_ticker2_text']) ) {
319 $simpleticker_ticker2_text = $_POST['simpleticker_ticker2_text'];
320 } else {
321 $simpleticker_ticker2_text = NULL;
322 }
323 if ( !empty($_POST['simpleticker_ticker3_text']) ) {
324 $simpleticker_ticker3_text = $_POST['simpleticker_ticker3_text'];
325 } else {
326 $simpleticker_ticker3_text = NULL;
327 }
328 if ( !empty($_POST['simpleticker_sticky_posts']) ) {
329 $simpleticker_sticky_posts = intval($_POST['simpleticker_sticky_posts']);
330 } else {
331 $simpleticker_sticky_posts = FALSE;
332 }
333 $simple_ticker_tbl = array(
334 'ticker1' => array(
335 'text' => $simpleticker->html_text($simpleticker_ticker1_text),
336 'color' => $_POST['simpleticker_ticker1_color']
337 ),
338 'ticker2' => array(
339 'text' => $simpleticker->html_text($simpleticker_ticker2_text),
340 'color' => $_POST['simpleticker_ticker2_color']
341 ),
342 'ticker3' => array(
343 'text' => $simpleticker->html_text($simpleticker_ticker3_text),
344 'color' => $_POST['simpleticker_ticker3_color']
345 ),
346 'sticky_posts' => array(
347 'display' => $simpleticker_sticky_posts,
348 'title_color' => $_POST['simpleticker_sticky_posts_titlecolor'],
349 'content_color' => $_POST['simpleticker_sticky_posts_contentcolor']
350 )
351 );
352 update_option( 'simple_ticker', $simple_ticker_tbl );
353 echo '<div class="updated"><ul><li>'.__('Settings').' --> '.__('Changes saved.').'</li></ul></div>';
354 }
355 break;
356 }
357
358 unset($simpleticker);
359
360 return;
361
362 }
363
364 }
365
366 ?>