PluginProbe
Simple Ticker / 1.01
Simple Ticker v1.01
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 / inc / SimpleTicker.php

SimpleTicker.php in Simple Ticker 1.01, at inc/SimpleTicker.php

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