コード例 #1
0
ファイル: slide.class.php プロジェクト: hathbanger/squab
 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
selected($post_sortby, 'none');
?>
><?php 
_e('Unsorted', REVSLIDER_TEXTDOMAIN);
?>
</option>
									<option value="menu_order" <?php 
selected($post_sortby, 'menu_order');
?>
><?php 
_e('Custom Order', REVSLIDER_TEXTDOMAIN);
?>
</option>
									<?php 
if (RevSliderEventsManager::isEventsExists()) {
    $arrEMSortBy = RevSliderEventsManager::getArrSortBy();
    if (!empty($arrEMSortBy)) {
        foreach ($arrEMSortBy as $event_handle => $event_name) {
            $sel = $event_handle == $post_sortby ? ' selected="selected"' : '';
            echo '<option value="' . $event_handle . '"' . $sel . '>' . $event_name . '</option>';
        }
    }
}
?>
								</select>
								<span class="tp-clearfix"></span>

								<?php 
$posts_sort_direction = RevSliderFunctions::getVal($arrFieldsParams, 'posts_sort_direction', 'DESC');
?>
								<span class="rev-new-label"><?php 
コード例 #3
0
 /**
  * 
  * get posts from categories (by the slider params).
  */
 private function getPostsFromCategories($publishedOnly = false)
 {
     $this->validateInited();
     $catIDs = $this->getParam("post_category");
     $data = RevSliderFunctionsWP::getCatAndTaxData($catIDs);
     $taxonomies = $data["tax"];
     $catIDs = $data["cats"];
     $sortBy = $this->getParam("post_sortby", self::DEFAULT_POST_SORTBY);
     $sortDir = $this->getParam("posts_sort_direction", self::DEFAULT_POST_SORTDIR);
     $maxPosts = $this->getParam("max_slider_posts", "30");
     if (empty($maxPosts) || !is_numeric($maxPosts)) {
         $maxPosts = -1;
     }
     $postTypes = $this->getParam("post_types", "any");
     //set direction for custom order
     if ($sortBy == RevSliderFunctionsWP::SORTBY_MENU_ORDER) {
         $sortDir = RevSliderFunctionsWP::ORDER_DIRECTION_ASC;
     }
     //Events integration
     $arrAddition = array();
     if ($publishedOnly == true) {
         $arrAddition["post_status"] = RevSliderFunctionsWP::STATE_PUBLISHED;
     }
     if (RevSliderEventsManager::isEventsExists()) {
         $filterType = $this->getParam("events_filter", RevSliderEventsManager::DEFAULT_FILTER);
         $arrAddition = RevSliderEventsManager::getWPQuery($filterType, $sortBy);
     }
     $slider_id = $this->getID();
     $arrPosts = RevSliderFunctionsWP::getPostsByCategory($slider_id, $catIDs, $sortBy, $sortDir, $maxPosts, $postTypes, $taxonomies, $arrAddition);
     return $arrPosts;
 }
コード例 #4
0
ファイル: slide-editor.php プロジェクト: jfbelisle/magexpress
            ?>
</td></tr>
							<tr><td><a href="javascript:UniteLayersRev.insertTemplate('wc_add_to_cart')">{{wc_add_to_cart}}</a></td><td><?php 
            _e("Add to Cart URL", REVSLIDER_TEXTDOMAIN);
            ?>
</td></tr>
							<tr><td><a href="javascript:UniteLayersRev.insertTemplate('wc_add_to_cart_button')">{{wc_add_to_cart_button}}</a></td><td><?php 
            _e("Add to Cart Button", REVSLIDER_TEXTDOMAIN);
            ?>
</td></tr>
						</table>
					<?php 
        } else {
            ?>
					<?php 
            if (RevSliderEventsManager::isEventsExists()) {
                ?>
						<table class="table_template_help" id="slide-events-template-entry" style="display: none;">
							<tr><td><a href="javascript:UniteLayersRev.insertTemplate('event_start_date')">{{event_start_date}}</a></td><td><?php 
                _e("Event start date", REVSLIDER_TEXTDOMAIN);
                ?>
</td></tr>
							<tr><td><a href="javascript:UniteLayersRev.insertTemplate('event_end_date')">{{event_end_date}}</a></td><td><?php 
                _e("Event end date", REVSLIDER_TEXTDOMAIN);
                ?>
</td></tr>
							<tr><td><a href="javascript:UniteLayersRev.insertTemplate('event_start_time')">{{event_start_time}}</a></td><td><?php 
                _e("Event start time", REVSLIDER_TEXTDOMAIN);
                ?>
</td></tr>
							<tr><td><a href="javascript:UniteLayersRev.insertTemplate('event_end_time')">{{event_end_time}}</a></td><td><?php 
コード例 #5
0
ファイル: slide.class.php プロジェクト: ksan5835/maadithottam
 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;
 }