예제 #1
0
 public function set_post_data($text, $attr, $post_id)
 {
     $img_sizes = RevSliderBase::get_all_image_sizes();
     $title = isset($attr['title']) ? $attr['title'] : '';
     $excerpt = isset($attr['excerpt']) ? $attr['excerpt'] : '';
     $alias = isset($attr['alias']) ? $attr['alias'] : '';
     $content = isset($attr['content']) ? $attr['content'] : '';
     $link = isset($attr['link']) ? $attr['link'] : '';
     $postDate = isset($attr['postDate']) ? $attr['postDate'] : '';
     $dateModified = isset($attr['dateModified']) ? $attr['dateModified'] : '';
     $authorName = isset($attr['authorName']) ? $attr['authorName'] : '';
     $numComments = isset($attr['numComments']) ? $attr['numComments'] : '';
     $catlist = isset($attr['catlist']) ? $attr['catlist'] : '';
     $taglist = isset($attr['taglist']) ? $attr['taglist'] : '';
     $text = str_replace(array('%title%', '{{title}}'), $title, $text);
     $text = str_replace(array('%excerpt%', '{{excerpt}}'), $excerpt, $text);
     $text = str_replace(array('%alias%', '{{alias}}'), $alias, $text);
     $text = str_replace(array('%content%', '{{content}}'), $content, $text);
     $text = str_replace(array('%link%', '{{link}}'), $link, $text);
     $text = str_replace(array('%date%', '{{date}}'), $postDate, $text);
     $text = str_replace(array('%date_modified%', '{{date_modified}}'), $dateModified, $text);
     $text = str_replace(array('%author_name%', '{{author_name}}'), $authorName, $text);
     $text = str_replace(array('%num_comments%', '{{num_comments}}'), $numComments, $text);
     $text = str_replace(array('%catlist%', '{{catlist}}'), $catlist, $text);
     $text = str_replace(array('%taglist%', '{{taglist}}'), $taglist, $text);
     foreach ($img_sizes as $img_handle => $img_name) {
         $url = isset($attr['img_urls']) && isset($attr['img_urls'][$img_handle]) && isset($attr['img_urls'][$img_handle]['url']) ? $attr['img_urls'][$img_handle]['url'] : '';
         $tag = isset($attr['img_urls']) && isset($attr['img_urls'][$img_handle]) && isset($attr['img_urls'][$img_handle]['tag']) ? $attr['img_urls'][$img_handle]['tag'] : '';
         $text = str_replace(array('%featured_image_url_' . $img_handle . '%', '{{featured_image_url_' . $img_handle . '}}'), $url, $text);
         $text = str_replace(array('%featured_image_' . $img_handle . '%', '{{featured_image_' . $img_handle . '}}'), $tag, $text);
     }
     //process meta tags:
     $text = str_replace('-', '_REVSLIDER_', $text);
     $arrMatches = array();
     preg_match_all('/%meta:\\w+%/', $text, $arrMatches);
     foreach ($arrMatches as $matched) {
         foreach ($matched as $match) {
             $meta = str_replace("%meta:", "", $match);
             $meta = str_replace("%", "", $meta);
             $meta = str_replace('_REVSLIDER_', '-', $meta);
             $metaValue = get_post_meta($post_id, $meta, true);
             $text = str_replace($match, $metaValue, $text);
         }
     }
     $arrMatches = array();
     preg_match_all('/{{meta:\\w+}}/', $text, $arrMatches);
     foreach ($arrMatches as $matched) {
         foreach ($matched as $match) {
             $meta = str_replace("{{meta:", "", $match);
             $meta = str_replace("}}", "", $meta);
             $meta = str_replace('_REVSLIDER_', '-', $meta);
             $metaValue = get_post_meta($post_id, $meta, true);
             $text = str_replace($match, $metaValue, $text);
         }
     }
     $text = str_replace('_REVSLIDER_', '-', $text);
     //replace event's template
     if (RevSliderEventsManager::isEventsExists()) {
         $eventData = RevSliderEventsManager::getEventPostData($post_id);
         if (!empty($eventData)) {
             foreach ($eventData as $eventKey => $eventValue) {
                 $eventPlaceholder = "%event_" . $eventKey . "%";
                 $eventPlaceholderNew = "{{event_" . $eventKey . "}}";
                 if ($eventKey == 'start_date' || $eventKey == 'end_date') {
                     $eventValue = RevSliderFunctionsWP::convertPostDate($eventValue);
                 }
                 $text = str_replace(array($eventPlaceholder, $eventPlaceholderNew), $eventValue, $text);
             }
         }
     }
     return $text;
 }
예제 #2
0
$video_volume = RevSliderFunctions::getVal($slideParams, 'video_volume', '100');
$video_start_at = RevSliderFunctions::getVal($slideParams, 'video_start_at', '');
$video_end_at = RevSliderFunctions::getVal($slideParams, 'video_end_at', '');
$video_arguments = RevSliderFunctions::getVal($slideParams, 'video_arguments', RevSliderGlobals::DEFAULT_YOUTUBE_ARGUMENTS);
$video_arguments_vim = RevSliderFunctions::getVal($slideParams, 'video_arguments_vimeo', RevSliderGlobals::DEFAULT_VIMEO_ARGUMENTS);
/* NEW KEN BURN INPUTS */
$kbStartOffsetX = intval(RevSliderFunctions::getVal($slideParams, 'kb_start_offset_x', $def_kb_start_offset_x));
$kbStartOffsetY = intval(RevSliderFunctions::getVal($slideParams, 'kb_start_offset_y', $def_kb_start_offset_y));
$kbEndOffsetX = intval(RevSliderFunctions::getVal($slideParams, 'kb_end_offset_x', $def_kb_end_offset_x));
$kbEndOffsetY = intval(RevSliderFunctions::getVal($slideParams, 'kb_end_offset_y', $def_kb_end_offset_y));
$kbStartRotate = intval(RevSliderFunctions::getVal($slideParams, 'kb_start_rotate', $def_kb_start_rotate));
$kbEndRotate = intval(RevSliderFunctions::getVal($slideParams, 'kb_end_rotate', $def_kb_start_rotate));
/* END OF NEW KEN BURN INPUTS*/
$bgRepeat = RevSliderFunctions::getVal($slideParams, 'bg_repeat', $def_bg_repeat);
$slideBGExternal = RevSliderFunctions::getVal($slideParams, "slide_bg_external", "");
$img_sizes = RevSliderBase::get_all_image_sizes($slider_type);
$bg_image_size = RevSliderFunctions::getVal($slideParams, 'image_source_type', $def_image_source_type);
$style_wrapper = '';
$class_wrapper = '';
switch ($bgType) {
    case "trans":
        $divLayersClass = "slide_layers";
        $class_wrapper = "trans_bg";
        break;
    case "solid":
        $style_wrapper .= "background-color:" . $slideBGColor . ";";
        break;
    case "image":
        switch ($slider_type) {
            case 'posts':
                $imageUrl = RS_PLUGIN_URL . 'public/assets/assets/sources/post.png';
" class="label" origtitle=""><?php 
_e('Animation Duration', REVSLIDER_TEXTDOMAIN);
?>
</span>
										<input type="text" class="text-sidebar withlabel" id="def-transition_duration" name="def-transition_duration" value="<?php 
echo $def_trans_dur;
?>
">
										<span><?php 
_e('ms', REVSLIDER_TEXTDOMAIN);
?>
</span>
										<div class="clear"></div>

										<?php 
$img_sizes = RevSliderBase::get_all_image_sizes();
$bg_image_size = RevSliderFunctions::getVal($arrFieldsParams, 'def-image_source_type', 'full');
?>
										<input type="checkbox" class="rs-ingore-save rs-reset-slide-setting" name="reset-image_source_type" /> <span id="label_def-image_source_type" class="label" origtitle="<?php 
_e("Default main image source size by creating a new slide.", REVSLIDER_TEXTDOMAIN);
?>
" ><?php 
_e('Image Source Size', REVSLIDER_TEXTDOMAIN);
?>
</span>
										<select name="def-image_source_type">
											<?php 
foreach ($img_sizes as $imghandle => $imgSize) {
    $sel = $bg_image_size == $imghandle ? ' selected="selected"' : '';
    echo '<option value="' . $imghandle . '"' . $sel . '>' . $imgSize . '</option>';
}
예제 #4
0
 public function set_post_data($text, $attr, $post_id)
 {
     $img_sizes = RevSliderBase::get_all_image_sizes();
     $title = isset($attr['title']) ? $attr['title'] : '';
     $excerpt = isset($attr['excerpt']) ? $attr['excerpt'] : '';
     $alias = isset($attr['alias']) ? $attr['alias'] : '';
     $content = isset($attr['content']) ? $attr['content'] : '';
     $link = isset($attr['link']) ? $attr['link'] : '';
     $postDate = isset($attr['postDate']) ? $attr['postDate'] : '';
     $dateModified = isset($attr['dateModified']) ? $attr['dateModified'] : '';
     $authorName = isset($attr['authorName']) ? $attr['authorName'] : '';
     $numComments = isset($attr['numComments']) ? $attr['numComments'] : '';
     $catlist = isset($attr['catlist']) ? $attr['catlist'] : '';
     $catlist_raw = isset($attr['catlist_raw']) ? $attr['catlist_raw'] : '';
     $taglist = isset($attr['taglist']) ? $attr['taglist'] : '';
     //add filter for addon metas
     $text = apply_filters('rev_slider_insert_meta', $text, $post_id);
     $text = str_replace(array('%title%', '{{title}}'), $title, $text);
     $text = str_replace(array('%excerpt%', '{{excerpt}}'), $excerpt, $text);
     $text = str_replace(array('%alias%', '{{alias}}'), $alias, $text);
     $text = str_replace(array('%content%', '{{content}}'), $content, $text);
     $text = str_replace(array('%link%', '{{link}}'), $link, $text);
     $text = str_replace(array('%date%', '{{date}}'), $postDate, $text);
     $text = str_replace(array('%date_modified%', '{{date_modified}}'), $dateModified, $text);
     $text = str_replace(array('%author_name%', '{{author_name}}'), $authorName, $text);
     $text = str_replace(array('%num_comments%', '{{num_comments}}'), $numComments, $text);
     $text = str_replace(array('%catlist%', '{{catlist}}'), $catlist, $text);
     $text = str_replace(array('%catlist_raw%', '{{catlist_raw}}'), $catlist_raw, $text);
     $text = str_replace(array('%taglist%', '{{taglist}}'), $taglist, $text);
     foreach ($img_sizes as $img_handle => $img_name) {
         $url = isset($attr['img_urls']) && isset($attr['img_urls'][$img_handle]) && isset($attr['img_urls'][$img_handle]['url']) ? $attr['img_urls'][$img_handle]['url'] : '';
         $tag = isset($attr['img_urls']) && isset($attr['img_urls'][$img_handle]) && isset($attr['img_urls'][$img_handle]['tag']) ? $attr['img_urls'][$img_handle]['tag'] : '';
         $text = str_replace(array('%featured_image_url_' . $img_handle . '%', '{{featured_image_url_' . $img_handle . '}}'), $url, $text);
         $text = str_replace(array('%featured_image_' . $img_handle . '%', '{{featured_image_' . $img_handle . '}}'), $tag, $text);
     }
     //process meta tags:
     $text = str_replace('-', '_REVSLIDER_', $text);
     $arrMatches = array();
     preg_match_all('/%meta:\\w+%/', $text, $arrMatches);
     foreach ($arrMatches as $matched) {
         foreach ($matched as $match) {
             $meta = str_replace("%meta:", "", $match);
             $meta = str_replace("%", "", $meta);
             $meta = str_replace('_REVSLIDER_', '-', $meta);
             $metaValue = get_post_meta($post_id, $meta, true);
             $text = str_replace($match, $metaValue, $text);
         }
     }
     $arrMatches = array();
     preg_match_all('/{{meta:\\w+}}/', $text, $arrMatches);
     foreach ($arrMatches as $matched) {
         foreach ($matched as $match) {
             $meta = str_replace("{{meta:", "", $match);
             $meta = str_replace("}}", "", $meta);
             $meta = str_replace('_REVSLIDER_', '-', $meta);
             $metaValue = get_post_meta($post_id, $meta, true);
             $text = str_replace($match, $metaValue, $text);
         }
     }
     $arrMatches = array();
     preg_match_all("/{{content:\\w+[\\:]\\w+}}/", $text, $arrMatches);
     foreach ($arrMatches as $matched) {
         foreach ($matched as $match) {
             //now check length and type
             $meta = str_replace("{{content:", "", $match);
             $meta = str_replace("}}", "", $meta);
             $meta = str_replace('_REVSLIDER_', '-', $meta);
             $vals = explode(':', $meta);
             if (count($vals) !== 2) {
                 continue;
             }
             //not correct values
             $vals[1] = intval($vals[1]);
             //get real number
             if ($vals[1] === 0 || $vals[1] < 0) {
                 continue;
             }
             //needs to be at least 1
             if ($vals[0] == 'words') {
                 $metaValue = explode(' ', strip_tags($content), $vals[1] + 1);
                 if (is_array($metaValue) && count($metaValue) > $vals[1]) {
                     array_pop($metaValue);
                 }
                 $metaValue = implode(' ', $metaValue);
             } elseif ($vals[0] == 'chars') {
                 $metaValue = substr(strip_tags($content), 0, $vals[1]);
             } else {
                 continue;
             }
             $text = str_replace($match, $metaValue, $text);
         }
     }
     $text = str_replace('_REVSLIDER_', '-', $text);
     //replace event's template
     if (RevSliderEventsManager::isEventsExists()) {
         $eventData = RevSliderEventsManager::getEventPostData($post_id);
         if (!empty($eventData)) {
             foreach ($eventData as $eventKey => $eventValue) {
                 $eventPlaceholder = "%event_" . $eventKey . "%";
                 $eventPlaceholderNew = "{{event_" . $eventKey . "}}";
                 if ($eventKey == 'start_date' || $eventKey == 'end_date') {
                     $eventValue = RevSliderFunctionsWP::convertPostDate($eventValue);
                 }
                 $text = str_replace(array($eventPlaceholder, $eventPlaceholderNew), $eventValue, $text);
             }
         }
     }
     if (RevSliderWooCommerce::isWooCommerceExists()) {
         $product = get_product($post_id);
         $wc_full_price = $product->get_price_html();
         $wc_price = wc_price($product->get_price());
         $wc_price_no_cur = $product->get_price();
         $wc_stock = $product->get_total_stock();
         $wc_rating = $product->get_rating_html();
         $wc_star_rating = '<div class="rs-starring">';
         preg_match_all('#<strong class="rating">.*?</span>#', $wc_rating, $match);
         if (!empty($match) && isset($match[0]) && isset($match[0][0])) {
             $wc_star_rating .= str_replace($match[0][0], '', $wc_rating);
         }
         $wc_star_rating .= '</div>';
         $wc_categories = $product->get_categories(',');
         $wc_add_to_cart = $product->add_to_cart_url();
         $wc_add_to_cart_button = '';
         $wc_sku = $product->get_sku();
         $wc_stock_quantity = $product->get_stock_quantity();
         $wc_rating_count = $product->get_rating_count();
         $wc_review_count = $product->get_review_count();
         $wc_tags = $product->get_tags();
         if (strpos($text, 'wc_add_to_cart_button') !== false) {
             $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
             $ajax_cart_en = get_option('woocommerce_enable_ajax_add_to_cart') == 'yes' ? true : false;
             $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
             $frontend_script_path = $assets_path . 'js/frontend/';
             if ($ajax_cart_en) {
                 wp_enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array('jquery'), WC_VERSION, true);
                 global $wc_is_localized;
                 if ($wc_is_localized === false) {
                     //load it only one time
                     wp_localize_script('wc-add-to-cart', 'wc_add_to_cart_params', apply_filters('wc_add_to_cart_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'), 'i18n_view_cart' => esc_attr__('View Cart', 'woocommerce'), 'cart_url' => get_permalink(wc_get_page_id('cart')), 'is_cart' => is_cart(), 'cart_redirect_after_add' => get_option('woocommerce_cart_redirect_after_add'))));
                     $wc_is_localized = true;
                 }
             }
             $wc_add_to_cart_button = apply_filters('woocommerce_loop_add_to_cart_link', sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button %s product_type_%s">%s</a>', esc_url($product->add_to_cart_url()), esc_attr($product->id), esc_attr($product->get_sku()), $product->is_purchasable() ? 'add_to_cart_button' : '', esc_attr($product->product_type), esc_html($product->add_to_cart_text())), $product);
         }
         $text = str_replace(array('%wc_full_price%', '{{wc_full_price}}'), $wc_full_price, $text);
         $text = str_replace(array('%wc_price%', '{{wc_price}}'), $wc_price, $text);
         $text = str_replace(array('%wc_price_no_cur%', '{{wc_price_no_cur}}'), $wc_price_no_cur, $text);
         $text = str_replace(array('%wc_stock%', '{{wc_stock}}'), $wc_stock, $text);
         $text = str_replace(array('%wc_rating%', '{{wc_rating}}'), $wc_rating, $text);
         $text = str_replace(array('%wc_star_rating%', '{{wc_star_rating}}'), $wc_star_rating, $text);
         $text = str_replace(array('%wc_categories%', '{{wc_categories}}'), $wc_categories, $text);
         $text = str_replace(array('%wc_add_to_cart%', '{{wc_add_to_cart}}'), $wc_add_to_cart, $text);
         $text = str_replace(array('%wc_add_to_cart_button%', '{{wc_add_to_cart_button}}'), $wc_add_to_cart_button, $text);
         $text = str_replace(array('%wc_sku%', '{{wc_sku}}'), $wc_sku, $text);
         $text = str_replace(array('%wc_stock_quantity%', '{{wc_stock_quantity}}'), $wc_stock_quantity, $text);
         $text = str_replace(array('%wc_rating_count%', '{{wc_rating_count}}'), $wc_rating_count, $text);
         $text = str_replace(array('%wc_review_count%', '{{wc_review_count}}'), $wc_review_count, $text);
         $text = str_replace(array('%wc_tags%', '{{wc_tags}}'), $wc_tags, $text);
     }
     return $text;
 }