'; $ticker_html .= ' '.$ticker1_text; $ticker_html .= '
'; } if ( !empty($ticker2_text) ) { $ticker_html .= '
'; $ticker_html .= ' '.$ticker2_text; $ticker_html .= '
'; } if ( !empty($ticker3_text) ) { $ticker_html .= '
'; $ticker_html .= ' '.$ticker3_text; $ticker_html .= '
'; } if ( $sticky_posts_display == 1 ) { $stickies = get_option( 'sticky_posts' ); if ( !empty($stickies) ) { rsort( $stickies ); foreach ( $stickies as $sticky ) { $post = NULL; $title = NULL; $content = NULL; $post = get_post($sticky); $title = $post->post_title; $content = $this->html_text($post->post_content); $ticker_html .= '
'; $ticker_html .= ' '.$title.':'; $ticker_html .= ''; $ticker_html .= ''; $ticker_html .= $content; $ticker_html .= '
'; } } } if ( $woo_sales_display == 1 && class_exists( 'WooCommerce' ) ) { global $wpdb; $sales = $wpdb->get_results(" SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE meta_key LIKE '%%_sale_price%%' "); $ticker_html .= '
'; $woo_sales_text_tag = $simpleticker_option['woo_sales']['text']; $currency = get_option('woocommerce_currency'); $currency_symbol = get_woocommerce_currency_symbol( $currency ); foreach ( $sales as $sale ){ if ( $sale->meta_key === '_sale_price' ) { if ( !empty( $sale->meta_value ) ) { $woo_sales_datas = array(); $sale_product = get_the_title( $sale->post_id ); $sale_link = get_permalink( $sale->post_id ); $sale_html = ''.$sale_product.''; $regular_price = get_post_meta( $sale->post_id, '_regular_price', TRUE ); $sale_price = get_post_meta( $sale->post_id, '_sale_price', TRUE ); $to_date_ux = get_post_meta( $sale->post_id, '_sale_price_dates_to', TRUE ); $current_date_ux = time(); $woo_sales_datas['regular_price'] = sprintf( get_woocommerce_price_format(), $currency_symbol, $regular_price ); $woo_sales_datas['sale_price'] = sprintf( get_woocommerce_price_format(), $currency_symbol, $sale_price ); $dis_amount = sprintf( get_woocommerce_price_format(), $currency_symbol, intval($regular_price - $sale_price) ); $dis_rate = intval((($regular_price - $sale_price) / $regular_price) * 100); $woo_sales_datas['dis_rate_price'] = sprintf(__('%1$s %2$s', 'simple-ticker'), $dis_amount, __('OFF', 'countdown-woocommerce-sale')); $woo_sales_datas['dis_rate_percent'] = sprintf(__('%1$d% %2$s', 'simple-ticker'), $dis_rate, __('OFF', 'countdown-woocommerce-sale')); $woo_sales_datas['to_date'] = date_i18n( "Y-m-d H:i:s", $to_date_ux, FALSE ); $interval_day_ux = $to_date_ux - $current_date_ux; $woo_sales_datas['interval_day'] = intval( $interval_day_ux / (60 * 60 * 24) ).__('Days', 'simple-ticker'); $woo_sales_datas['interval_time'] = gmdate( 'H:i:s' , $interval_day_ux % (60 * 60 * 24) ); $ticker_html .= $sale_html; $ticker_html .= ' : '; $woo_sales_text = NULL; if ( $woo_sales_datas ) { $woo_sales_text = $woo_sales_text_tag; foreach($woo_sales_datas as $item => $woo_sale) { $woo_sales_text = str_replace('%'.$item.'%', $woo_sale, $woo_sales_text); } preg_match_all('/%(.*?)%/', $woo_sales_text, $woo_sales_text_per_match); foreach($woo_sales_text_per_match as $key1) { foreach($key1 as $key2) { $woo_sales_text = str_replace('%'.$key2.'%', '', $woo_sales_text); } } } $ticker_html .= $woo_sales_text; $ticker_html .= ' '; } } } $ticker_html .= '
'; } return $ticker_html; } /* ================================================== * short code * @param array $atts * @return string $this->read_tickers() */ public function simpleticker_func( $atts ) { extract(shortcode_atts(array( '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' => '' ), $atts)); 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, $woo_sales_display, $woo_sales_color); } /* * @param string $html * @return string $text * @since 1.0 */ public function html_text($html) { $text = strip_tags($html); $text = str_replace(array("\r", "\n"), '', $text); return $text; } /* ================================================== * Load Marquee Style * @since 2.00 */ public function load_styles() { $simpleticker_option = get_option('simple_ticker'); $speed = $simpleticker_option['speed']; $woo_sales_color = $simpleticker_option['woo_sales']['color']; wp_enqueue_style( 'simpleticker', plugin_dir_url( __DIR__ ).'css/marquee.css' ); $css = '.marquee > .marquee-inner { animation-duration: '.$speed.'s; }'; wp_add_inline_style( 'simpleticker', $css ); } } ?>