PluginProbe
Simple Ticker / 1.07
Simple Ticker v1.07
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 / SimpleTicker.php

SimpleTicker.php in Simple Ticker 1.07, at lib/SimpleTicker.php

148 lines 4.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 Simple Ticker
6 * @subpackage SimpleTicker
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 $simpleticker = new SimpleTicker();
23
24 class SimpleTicker {
25
26 /* ==================================================
27 * Construct
28 * @since 1.06
29 */
30 public function __construct() {
31
32 add_shortcode( 'simpleticker', array($this, 'simpleticker_func'));
33
34 }
35
36 /*
37 * Main
38 * @param string $ticker1_color
39 * @param string $ticker1_text
40 * @param string $ticker2_color
41 * @param string $ticker2_text
42 * @param string $ticker3_color
43 * @param string $ticker3_text
44 * @param bool $sticky_posts_display
45 * @param string $sticky_posts_title_color
46 * @param string $sticky_posts_content_color
47 * @return string $ticker_html
48 * @since 1.0
49 */
50 public function read_tickers($ticker1_color, $ticker1_text, $ticker2_color, $ticker2_text, $ticker3_color, $ticker3_text, $sticky_posts_display, $sticky_posts_title_color, $sticky_posts_content_color) {
51
52 $simpleticker_option = get_option('simple_ticker');
53
54 if ( empty($ticker1_color) ) { $ticker1_color = $simpleticker_option['ticker1']['color']; }
55 if ( empty($ticker1_text) ) { $ticker1_text = $simpleticker_option['ticker1']['text']; }
56 if ( empty($ticker2_color) ) { $ticker2_color = $simpleticker_option['ticker2']['color']; }
57 if ( empty($ticker2_text) ) { $ticker2_text = $simpleticker_option['ticker2']['text']; }
58 if ( empty($ticker3_color) ) { $ticker3_color = $simpleticker_option['ticker3']['color']; }
59 if ( empty($ticker3_text) ) { $ticker3_text = $simpleticker_option['ticker3']['text']; }
60
61 if ( empty($sticky_posts_display) ) { $sticky_posts_display = $simpleticker_option['sticky_posts']['display']; }
62 if ( empty($sticky_posts_title_color) ) { $sticky_posts_title_color = $simpleticker_option['sticky_posts']['title_color']; }
63 if ( empty($sticky_posts_content_color) ) { $sticky_posts_content_color = $simpleticker_option['sticky_posts']['content_color']; }
64
65
66 $ticker_html = NULL;
67
68 if ( !empty($ticker1_text) ) {
69 $ticker_html .= '<div><marquee><font color='.$ticker1_color.'><b>';
70 $ticker_html .= ' '.$ticker1_text;
71 $ticker_html .= '</b></font></marquee></div>';
72 }
73 if ( !empty($ticker2_text) ) {
74 $ticker_html .= '<div><marquee><font color='.$ticker2_color.'><b>';
75 $ticker_html .= ' '.$ticker2_text;
76 $ticker_html .= '</b></font></marquee></div>';
77 }
78 if ( !empty($ticker3_text) ) {
79 $ticker_html .= '<div><marquee><font color='.$ticker3_color.'><b>';
80 $ticker_html .= ' '.$ticker3_text;
81 $ticker_html .= '</b></font></marquee></div>';
82 }
83
84 if ( $sticky_posts_display == 1 ) {
85 $stickies = get_option( 'sticky_posts' );
86 if ( !empty($stickies) ) {
87 rsort( $stickies );
88 foreach ( $stickies as $sticky ) {
89 $post = NULL;
90 $title = NULL;
91 $content = NULL;
92 $post = get_post($sticky);
93 $title = $post->post_title;
94 $content = $this->html_text($post->post_content);
95 $ticker_html .= '<div><marquee><font color='.$sticky_posts_title_color.'><b>';
96 $ticker_html .= ' '.$title.':';
97 $ticker_html .= '</b></font>';
98 $ticker_html .= '<font color='.$sticky_posts_content_color.'><b>';
99 $ticker_html .= $content;
100 $ticker_html .= '</b></font></marquee></div>';
101 }
102 }
103 }
104
105 return $ticker_html;
106
107 }
108
109 /* ==================================================
110 * short code
111 * @param array $atts
112 * @return string $this->read_tickers()
113 */
114 public function simpleticker_func( $atts ) {
115
116 extract(shortcode_atts(array(
117 'ticker1_color' => '',
118 'ticker1_text' => '',
119 'ticker2_color' => '',
120 'ticker2_text' => '',
121 'ticker3_color' => '',
122 'ticker3_text' => '',
123 'sticky_posts_display' => '',
124 'sticky_posts_title_color' => '',
125 'sticky_posts_content_color' => ''
126 ), $atts));
127
128 return $this->read_tickers($ticker1_color, $this->html_text($ticker1_text), $ticker2_color, $this->html_text($ticker2_text), $ticker3_color, $this->html_text($ticker3_text), $sticky_posts_display, $sticky_posts_title_color, $sticky_posts_content_color);
129
130 }
131
132 /*
133 * @param string $html
134 * @return string $text
135 * @since 1.0
136 */
137 public function html_text($html) {
138
139 $text = strip_tags($html);
140 $text = str_replace(array("\r", "\n"), '', $text);
141
142 return $text;
143
144 }
145
146 }
147
148 ?>