当前位置: 首页>>代码示例>>PHP>>正文


PHP RevSliderFunctionsWP::convertPostDate方法代码示例

本文整理汇总了PHP中RevSliderFunctionsWP::convertPostDate方法的典型用法代码示例。如果您正苦于以下问题:PHP RevSliderFunctionsWP::convertPostDate方法的具体用法?PHP RevSliderFunctionsWP::convertPostDate怎么用?PHP RevSliderFunctionsWP::convertPostDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RevSliderFunctionsWP的用法示例。


在下文中一共展示了RevSliderFunctionsWP::convertPostDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_post_data

 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;
 }
开发者ID:hathbanger,项目名称:squab,代码行数:72,代码来源:slide.class.php

示例2: set_post_data


//.........这里部分代码省略.........
     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;
 }
开发者ID:ksan5835,项目名称:maadithottam,代码行数:101,代码来源:slide.class.php


注:本文中的RevSliderFunctionsWP::convertPostDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。