PluginProbe
Simple Ticker / 2.05
Simple Ticker v2.05
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
← All changes | lib/SimpleTicker.php +57 -29 2.022.05 View file →
@@ -22,8 +22,10 @@
22 22 $simpleticker = new SimpleTicker();
23 23
24 24 class SimpleTicker {
25 25
26 + private $simpleticker_option;
27 +
26 28 /* ==================================================
27 29 * Construct
28 30 * @since 1.06
29 31 */
@@ -28,13 +30,43 @@
28 30 * @since 1.06
29 31 */
30 32 public function __construct() {
31 33
34 + $this->simpleticker_option = get_option('simple_ticker');
35 +
32 36 add_action( 'wp_print_styles', array($this, 'load_styles') );
33 37 add_shortcode( 'simpleticker', array($this, 'simpleticker_func') );
38 + if ( $this->simpleticker_option['insert'] <> 'none' ) {
39 + add_filter( 'the_content', array($this, 'insert_post') );
40 + }
34 41
35 42 }
36 43
44 + /* ==================================================
45 + * Contents filter
46 + * @param string $content
47 + * @return string $content
48 + * @since 2.04
49 + */
50 + public function insert_post( $content ) {
51 +
52 + $custom_content = $this->read_tickers(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
53 + switch ($this->simpleticker_option['insert']) {
54 + case 'before':
55 + $content = $custom_content.$content;
56 + break;
57 + case 'after':
58 + $content .= $custom_content;
59 + break;
60 + case 'beforeafter':
61 + $content = $custom_content.$content.$custom_content;
62 + break;
63 + }
64 +
65 + return $content;
66 +
67 + }
68 +
37 69 /*
38 70 * Main
39 71 * @param string $ticker1_color
40 72 * @param string $ticker1_text
@@ -51,40 +83,38 @@
51 83 * @since 1.0
52 84 */
53 85 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, $woo_sales_display, $woo_sales_color) {
54 86
55 - $simpleticker_option = get_option('simple_ticker');
87 + if ( empty($ticker1_color) ) { $ticker1_color = '#'.$this->simpleticker_option['ticker1']['color']; }
88 + if ( empty($ticker1_text) ) { $ticker1_text = $this->simpleticker_option['ticker1']['text']; }
89 + if ( empty($ticker2_color) ) { $ticker2_color = '#'.$this->simpleticker_option['ticker2']['color']; }
90 + if ( empty($ticker2_text) ) { $ticker2_text = $this->simpleticker_option['ticker2']['text']; }
91 + if ( empty($ticker3_color) ) { $ticker3_color = '#'.$this->simpleticker_option['ticker3']['color']; }
92 + if ( empty($ticker3_text) ) { $ticker3_text = $this->simpleticker_option['ticker3']['text']; }
56 93
57 - if ( empty($ticker1_color) ) { $ticker1_color = $simpleticker_option['ticker1']['color']; }
58 - if ( empty($ticker1_text) ) { $ticker1_text = $simpleticker_option['ticker1']['text']; }
59 - if ( empty($ticker2_color) ) { $ticker2_color = $simpleticker_option['ticker2']['color']; }
60 - if ( empty($ticker2_text) ) { $ticker2_text = $simpleticker_option['ticker2']['text']; }
61 - if ( empty($ticker3_color) ) { $ticker3_color = $simpleticker_option['ticker3']['color']; }
62 - if ( empty($ticker3_text) ) { $ticker3_text = $simpleticker_option['ticker3']['text']; }
94 + if ( empty($sticky_posts_display) ) { $sticky_posts_display = $this->simpleticker_option['sticky_posts']['display']; }
95 + if ( empty($sticky_posts_title_color) ) { $sticky_posts_title_color = '#'.$this->simpleticker_option['sticky_posts']['title_color']; }
96 + if ( empty($sticky_posts_content_color) ) { $sticky_posts_content_color = '#'.$this->simpleticker_option['sticky_posts']['content_color']; }
63 97
64 - if ( empty($sticky_posts_display) ) { $sticky_posts_display = $simpleticker_option['sticky_posts']['display']; }
65 - if ( empty($sticky_posts_title_color) ) { $sticky_posts_title_color = $simpleticker_option['sticky_posts']['title_color']; }
66 - if ( empty($sticky_posts_content_color) ) { $sticky_posts_content_color = $simpleticker_option['sticky_posts']['content_color']; }
98 + if ( empty($woo_sales_display) ) { $woo_sales_display = $this->simpleticker_option['woo_sales']['display']; }
99 + if ( empty($woo_sales_color) ) { $woo_sales_color = '#'.$this->simpleticker_option['woo_sales']['color']; }
67 100
68 - if ( empty($woo_sales_display) ) { $woo_sales_display = $simpleticker_option['woo_sales']['display']; }
69 - if ( empty($woo_sales_color) ) { $woo_sales_color = $simpleticker_option['woo_sales']['color']; }
70 -
71 101 $ticker_html = NULL;
72 102
73 103 if ( !empty($ticker1_text) ) {
74 - $ticker_html .= '<div class="marquee"><div class="marquee-inner"><font color="'.$ticker1_color.'"><b>';
104 + $ticker_html .= '<div class="marquee"><div class="marquee-inner"><span style="color: '.$ticker1_color.'; font-weight: bold;">';
75 105 $ticker_html .= ' '.$ticker1_text;
76 - $ticker_html .= '</b></font></div></div>';
106 + $ticker_html .= '</span></div></div>';
77 107 }
78 108 if ( !empty($ticker2_text) ) {
79 - $ticker_html .= '<div class="marquee"><div class="marquee-inner"><font color="'.$ticker2_color.'"><b>';
109 + $ticker_html .= '<div class="marquee"><div class="marquee-inner"><span style="color: '.$ticker2_color.'; font-weight: bold;">';
80 110 $ticker_html .= ' '.$ticker2_text;
81 - $ticker_html .= '</b></font></div></div>';
111 + $ticker_html .= '</span></div></div>';
82 112 }
83 113 if ( !empty($ticker3_text) ) {
84 - $ticker_html .= '<div class="marquee"><div class="marquee-inner"><font color="'.$ticker3_color.'"><b>';
114 + $ticker_html .= '<div class="marquee"><div class="marquee-inner"><span style="color: '.$ticker3_color.'; font-weight: bold;">';
85 115 $ticker_html .= ' '.$ticker3_text;
86 - $ticker_html .= '</b></font></div></div>';
116 + $ticker_html .= '</span></div></div>';
87 117 }
88 118
89 119 if ( $sticky_posts_display == 1 ) {
90 120 $stickies = get_option( 'sticky_posts' );
@@ -96,14 +126,14 @@
96 126 $content = NULL;
97 127 $post = get_post($sticky);
98 128 $title = $post->post_title;
99 129 $content = $this->html_text($post->post_content);
100 - $ticker_html .= '<div class="marquee"><div class="marquee-inner"><font color="'.$sticky_posts_title_color.'"><b>';
130 + $ticker_html .= '<div class="marquee"><div class="marquee-inner"><span style="color: '.$sticky_posts_title_color.'; font-weight: bold;">';
101 131 $ticker_html .= ' '.$title.':';
102 - $ticker_html .= '</b></font>';
103 - $ticker_html .= '<font color="'.$sticky_posts_content_color.'"><b>';
132 + $ticker_html .= '</span>';
133 + $ticker_html .= '<span style="color: '.$sticky_posts_content_color.'; font-weight: bold;">';
104 134 $ticker_html .= $content;
105 - $ticker_html .= '</b></font></div></div>';
135 + $ticker_html .= '</span></div></div>';
106 136 }
107 137 }
108 138 }
109 139
@@ -114,9 +144,9 @@
114 144 FROM $wpdb->postmeta
115 145 WHERE meta_key LIKE '%%_sale_price%%'
116 146 ");
117 147 $ticker_html .= '<div class="marquee"><div class="marquee-inner">';
118 - $woo_sales_text_tag = $simpleticker_option['woo_sales']['text'];
148 + $woo_sales_text_tag = $this->simpleticker_option['woo_sales']['text'];
119 149 $currency = get_option('woocommerce_currency');
120 150 $currency_symbol = get_woocommerce_currency_symbol( $currency );
121 151 foreach ( $sales as $sale ){
122 152 if ( $sale->meta_key === '_sale_price' ) {
@@ -143,9 +173,9 @@
143 173 $interval_day_ux = $to_date_ux - $current_date_ux;
144 174 $woo_sales_datas['interval_day'] = intval( $interval_day_ux / (60 * 60 * 24) ).__('Days', 'simple-ticker');
145 175 $woo_sales_datas['interval_time'] = gmdate( 'H:i:s' , $interval_day_ux % (60 * 60 * 24) );
146 176 $ticker_html .= $sale_html;
147 - $ticker_html .= '<font color="'.$woo_sales_color.'"><b> : ';
177 + $ticker_html .= '<span style="color: '.$woo_sales_color.'; font-weight: bold;"> : ';
148 178 $woo_sales_text = NULL;
149 179 if ( $woo_sales_datas ) {
150 180 $woo_sales_text = $woo_sales_text_tag;
151 181 foreach($woo_sales_datas as $item => $woo_sale) {
@@ -158,9 +188,9 @@
158 188 }
159 189 }
160 190 }
161 191 $ticker_html .= $woo_sales_text;
162 - $ticker_html .= '</b></font> ';
192 + $ticker_html .= '</span> ';
163 193 }
164 194 }
165 195 }
166 196 $ticker_html .= '</div></div>';
@@ -214,11 +244,9 @@
214 244 * Load Marquee Style
215 245 * @since 2.00
216 246 */
217 247 public function load_styles() {
218 - $simpleticker_option = get_option('simple_ticker');
219 - $speed = $simpleticker_option['speed'];
220 - $woo_sales_color = $simpleticker_option['woo_sales']['color'];
248 + $speed = $this->simpleticker_option['speed'];
221 249 wp_enqueue_style( 'simpleticker', plugin_dir_url( __DIR__ ).'css/marquee.css' );
222 250 $css = '.marquee > .marquee-inner { animation-duration: '.$speed.'s; }';
223 251 wp_add_inline_style( 'simpleticker', $css );
224 252 }