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


PHP wc_get_page_id函数代码示例

本文整理汇总了PHP中wc_get_page_id函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_page_id函数的具体用法?PHP wc_get_page_id怎么用?PHP wc_get_page_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: global_get_post_id

 function global_get_post_id() {
     if (function_exists('is_woocommerce') && is_woocommerce() && is_shop()) {
         
         return wc_get_page_id('shop');
     } 
     else if (is_singular()) {
         global $post;
         
         return $post->ID;
     } 
     else if (is_home()) {
         
         $page_on_front = get_option('page_on_front');
         $show_on_front = get_option('show_on_front');
         
         if ($page_on_front == 'page' && !empty($page_on_front)) {
             global $post;
             return $post->ID;
         } 
         else {
             return false;
         }
     } 
     else {
         
         return false;
     }
 }
开发者ID:sonololo,项目名称:gorodprima,代码行数:28,代码来源:global_post_id.php

示例2: template_loader

 /**
  * Load a template.
  *
  * Handles template usage so that we can use our own templates instead of the themes.
  *
  * Templates are in the 'templates' folder. woocommerce looks for theme
  * overrides in /theme/woocommerce/ by default
  *
  * For beginners, it also looks for a woocommerce.php template first. If the user adds
  * this to the theme (containing a woocommerce() inside) this will be used for all
  * woocommerce templates.
  *
  * @param mixed $template
  * @return string
  */
 public function template_loader($template)
 {
     $find = array('woocommerce.php');
     $file = '';
     if (is_single() && get_post_type() == 'product') {
         $file = 'single-product.php';
         $find[] = $file;
         $find[] = WC_TEMPLATE_PATH . $file;
     } elseif (is_tax('product_cat') || is_tax('product_tag')) {
         $term = get_queried_object();
         $file = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = WC_TEMPLATE_PATH . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = $file;
         $find[] = WC_TEMPLATE_PATH . $file;
     } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
         $file = 'archive-product.php';
         $find[] = $file;
         $find[] = WC_TEMPLATE_PATH . $file;
     }
     if ($file) {
         $template = locate_template($find);
         $status_options = get_option('woocommerce_status_options', array());
         if (!$template || !empty($status_options['template_debug_mode']) && current_user_can('manage_options')) {
             $template = WC()->plugin_path() . '/templates/' . $file;
         }
     }
     return $template;
 }
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:44,代码来源:class-wc-template-loader.php

示例3: cuttz_add_landing_sections_meta_box

/**
 * Register a new meta box to the post or page edit screen, so that the user can add landing section
 * on a per-post or per-page basis.
 */
function cuttz_add_landing_sections_meta_box()
{
    if (!current_theme_supports('cuttz-landing-sections')) {
        return;
    }
    global $post;
    if (get_option('show_on_front') == 'page') {
        $posts_page_id = get_option('page_for_posts');
        if ($posts_page_id == $post->ID) {
            add_action('edit_form_after_title', 'cuttz_landing_section_posts_notice');
            return;
        }
    }
    if (in_array('woocommerce/woocommerce.php', get_option('active_plugins'))) {
        if ($post->ID == wc_get_page_id('shop')) {
            add_action('edit_form_after_title', 'cuttz_landing_section_shop_notice');
            return;
        }
    }
    $context = 'normal';
    $priority = 'high';
    foreach ((array) get_post_types(array('public' => true)) as $type) {
        if (post_type_supports($type, 'cuttz-landing-sections')) {
            add_meta_box('landing-sections', __('Cuttz Landing Sections', 'cuttz-framework'), 'cuttz_landing_sections_box', $type, $context, $priority);
        }
    }
}
开发者ID:garywp,项目名称:cuttz-framework,代码行数:31,代码来源:landing-sections-mgt.php

示例4: wc_update_200_permalinks

function wc_update_200_permalinks()
{
    // Setup default permalinks if shop page is defined
    $permalinks = get_option('woocommerce_permalinks');
    $shop_page_id = wc_get_page_id('shop');
    if (empty($permalinks) && $shop_page_id > 0) {
        $base_slug = $shop_page_id > 0 && get_post($shop_page_id) ? get_page_uri($shop_page_id) : 'shop';
        $category_base = get_option('woocommerce_prepend_shop_page_to_urls') == "yes" ? trailingslashit($base_slug) : '';
        $category_slug = get_option('woocommerce_product_category_slug') ? get_option('woocommerce_product_category_slug') : _x('product-category', 'slug', 'woocommerce');
        $tag_slug = get_option('woocommerce_product_tag_slug') ? get_option('woocommerce_product_tag_slug') : _x('product-tag', 'slug', 'woocommerce');
        if ('yes' == get_option('woocommerce_prepend_shop_page_to_products')) {
            $product_base = trailingslashit($base_slug);
        } else {
            if (($product_slug = get_option('woocommerce_product_slug')) !== false && !empty($product_slug)) {
                $product_base = trailingslashit($product_slug);
            } else {
                $product_base = trailingslashit(_x('product', 'slug', 'woocommerce'));
            }
        }
        if (get_option('woocommerce_prepend_category_to_products') == 'yes') {
            $product_base .= trailingslashit('%product_cat%');
        }
        $permalinks = array('product_base' => untrailingslashit($product_base), 'category_base' => untrailingslashit($category_base . $category_slug), 'attribute_base' => untrailingslashit($category_base), 'tag_base' => untrailingslashit($category_base . $tag_slug));
        update_option('woocommerce_permalinks', $permalinks);
    }
}
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:26,代码来源:wc-update-functions.php

示例5: prevent_caching

 /**
  * Prevent caching on dynamic pages.
  *
  * @access public
  * @return void
  */
 public static function prevent_caching()
 {
     if (false === ($wc_page_uris = get_transient('woocommerce_cache_excluded_uris'))) {
         if (wc_get_page_id('cart') < 1 || wc_get_page_id('checkout') < 1 || wc_get_page_id('myaccount') < 1) {
             return;
         }
         $wc_page_uris = array();
         // Exclude querystring when using page ID
         $wc_page_uris[] = 'p=' . wc_get_page_id('cart');
         $wc_page_uris[] = 'p=' . wc_get_page_id('checkout');
         $wc_page_uris[] = 'p=' . wc_get_page_id('myaccount');
         // Exclude permalinks
         $cart_page = get_post(wc_get_page_id('cart'));
         $checkout_page = get_post(wc_get_page_id('checkout'));
         $account_page = get_post(wc_get_page_id('myaccount'));
         if (!is_null($cart_page)) {
             $wc_page_uris[] = '/' . $cart_page->post_name;
         }
         if (!is_null($checkout_page)) {
             $wc_page_uris[] = '/' . $checkout_page->post_name;
         }
         if (!is_null($account_page)) {
             $wc_page_uris[] = '/' . $account_page->post_name;
         }
         set_transient('woocommerce_cache_excluded_uris', $wc_page_uris);
     }
     if (is_array($wc_page_uris)) {
         foreach ($wc_page_uris as $uri) {
             if (strstr($_SERVER['REQUEST_URI'], $uri)) {
                 self::nocache();
                 break;
             }
         }
     }
 }
开发者ID:anagio,项目名称:woocommerce,代码行数:41,代码来源:class-wc-cache-helper.php

示例6: renew_handler

 /**
  * Handle a renewal url
  */
 public function renew_handler()
 {
     if (!empty($_GET['renew_licence']) && is_user_logged_in()) {
         global $wpdb;
         $licence_key = sanitize_text_field($_GET['renew_licence']);
         $licence = $wpdb->get_row($wpdb->prepare("\n\t\t\t\tSELECT * FROM {$wpdb->prefix}wp_plugin_licencing_licences\n\t\t\t\tWHERE licence_key = %s\n\t\t\t\tAND ( user_id = %d OR user_id = 0 )\n\t\t\t", $licence_key, get_current_user_id()));
         // Renewable?
         if (!$licence) {
             wc_add_notice(__('Invalid licence', 'wp-plugin-licencing'), 'error');
             return;
         }
         if (!$licence->date_expires || strtotime($licence->date_expires) > current_time('timestamp')) {
             wc_add_notice(__('This licence does not need to be renewed yet', 'wp-plugin-licencing'), 'notice');
             return;
         }
         // Purchasable?
         $product = get_product($licence->product_id);
         if (!$product->is_purchasable()) {
             wc_add_notice(__('This product can no longer be purchased', 'wp-plugin-licencing'), 'error');
             return;
         }
         // Add to cart
         WC()->cart->empty_cart();
         WC()->cart->add_to_cart($licence->product_id, 1, '', '', array('renewing_key' => $licence_key));
         // Message
         wc_add_notice(sprintf(__('The product has been added to your cart with a %d%% discount.', 'wp-plugin-licencing'), apply_filters('wp_plugin_licencing_renewal_discount_percent', 30)), 'success');
         // Redirect to checkout
         wp_redirect(get_permalink(wc_get_page_id('checkout')));
         exit;
     }
 }
开发者ID:ChromeOrange,项目名称:wp-plugin-licencing,代码行数:34,代码来源:class-wp-plugin-licencing-renewals.php

示例7: maybe_setup_cart

 /**
  * Setup the cart for paying for a delayed initial payment for a subscription.
  *
  * @since 2.0
  */
 public function maybe_setup_cart()
 {
     global $wp;
     if (isset($_GET['pay_for_order']) && isset($_GET['key']) && isset($wp->query_vars['order-pay'])) {
         // Pay for existing order
         $order_key = $_GET['key'];
         $order_id = isset($wp->query_vars['order-pay']) ? $wp->query_vars['order-pay'] : absint($_GET['order_id']);
         $order = wc_get_order($wp->query_vars['order-pay']);
         if ($order->order_key == $order_key && $order->has_status(array('pending', 'failed')) && !wcs_order_contains_subscription($order, array('renewal', 'resubscribe'))) {
             $subscriptions = wcs_get_subscriptions_for_order($order, array('order_type' => 'parent'));
             if (get_current_user_id() !== $order->get_user_id()) {
                 wc_add_notice(__('That doesn\'t appear to be your order.', 'woocommerce-subscriptions'), 'error');
                 wp_safe_redirect(get_permalink(wc_get_page_id('myaccount')));
                 exit;
             } elseif (!empty($subscriptions)) {
                 // Setup cart with all the original order's line items
                 $this->setup_cart($order, array('order_id' => $order_id));
                 WC()->session->set('order_awaiting_payment', $order_id);
                 // Set cart hash for orders paid in WC >= 2.6
                 $this->set_cart_hash($order_id);
                 wp_safe_redirect(WC()->cart->get_checkout_url());
                 exit;
             }
         }
     }
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:31,代码来源:class-wcs-cart-initial-payment.php

示例8: __construct

 /**
  * Get things started
  *
  * @since 1.0
  */
 public function __construct()
 {
     $this->set_expiration_time();
     $this->set_referral_var();
     /*
      * Referrals are tracked via javascript by default
      * This fails on sites that have jQuery errors, so a fallback method is available
      * With the fallback, the template_redirect action is used
      */
     if (!$this->use_fallback_method()) {
         add_action('wp_head', array($this, 'header_scripts'));
         add_action('wp_enqueue_scripts', array($this, 'load_scripts'));
         add_action('wp_ajax_nopriv_affwp_track_visit', array($this, 'track_visit'));
         add_action('wp_ajax_affwp_track_visit', array($this, 'track_visit'));
         add_action('wp_ajax_affwp_get_affiliate_id', array($this, 'ajax_get_affiliate_id_from_login'));
         add_action('wp_ajax_nopriv_affwp_get_affiliate_id', array($this, 'ajax_get_affiliate_id_from_login'));
     } else {
         add_action('template_redirect', array($this, 'fallback_track_visit'), -9999);
     }
     add_action('init', array($this, 'rewrites'));
     if (function_exists('wc_get_page_id') && get_option('page_on_front') == wc_get_page_id('shop')) {
         add_action('pre_get_posts', array($this, 'unset_query_arg'), -1);
     } else {
         add_action('pre_get_posts', array($this, 'unset_query_arg'), 999999);
     }
     add_action('redirect_canonical', array($this, 'prevent_canonical_redirect'), 0, 2);
     add_action('wp_ajax_nopriv_affwp_track_conversion', array($this, 'track_conversion'));
     add_action('wp_ajax_affwp_track_conversion', array($this, 'track_conversion'));
 }
开发者ID:rexcarnation,项目名称:AffiliateWP,代码行数:34,代码来源:class-tracking.php

示例9: is_available

 /**
  * Check If The Gateway Is Available For Use
  *
  * @return bool
  */
 public function is_available()
 {
     if (!empty($this->enable_for_methods)) {
         // Only apply if all packages are being shipped via local pickup
         $chosen_shipping_methods = array_unique(WC()->session->get('chosen_shipping_methods'));
         $check_method = false;
         if (is_page(wc_get_page_id('checkout')) && !empty($wp->query_vars['order-pay'])) {
             $order_id = absint($wp->query_vars['order-pay']);
             $order = new WC_Order($order_id);
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
开发者ID:hoonio,项目名称:PhoneAfrika,代码行数:38,代码来源:class-wc-gateway-cod.php

示例10: login_url

 public function login_url($url)
 {
     if (!class_exists('WooCommerce')) {
         return $url;
     }
     return get_permalink(wc_get_page_id('myaccount'));
 }
开发者ID:abdullahrahim,项目名称:shadighar,代码行数:7,代码来源:class-wp-job-manager-bookmarks.php

示例11: correctShopPage

 /**
  * Correct the shop page to display products from currrent language only.
  *
  * @param \WP $wp wordpress instance
  *
  * @return bool false if the current language is the same as default
  *              language or if the "pagename" var is empty
  */
 public function correctShopPage(\WP $wp)
 {
     global $polylang;
     $shopID = wc_get_page_id('shop');
     $shopOnFront = 'page' === get_option('show_on_front') && in_array(get_option('page_on_front'), PLL()->model->post->get_translations($shopID));
     $vars = array('pagename', 'page', 'name');
     foreach ($vars as $var) {
         if (isset($wp->query_vars[$var])) {
             $shopOnFront = false;
             break;
         }
     }
     if (!$shopOnFront) {
         if (!empty($wp->query_vars['pagename'])) {
             $shopPage = get_post($shopID);
             /* Explode by / for children page */
             $page = explode('/', $wp->query_vars['pagename']);
             if (isset($shopPage->post_name) && $shopPage->post_name == $page[count($page) - 1]) {
                 unset($wp->query_vars['page']);
                 unset($wp->query_vars['pagename']);
                 $wp->query_vars['post_type'] = 'product';
             }
         }
     } else {
         $wp->query_vars['post_type'] = 'product';
     }
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:35,代码来源:Pages.php

示例12: create_the_view_all

 function create_the_view_all($post_type, $tag = '')
 {
     // Test for WooCommerce as well here...
     if ('product' == $post_type && class_exists('WooCommerce')) {
         $shop_page_id = wc_get_page_id('shop');
         $url = get_permalink($shop_page_id);
         $title = get_option('woocommerce_shop_page_title') ? get_option('woocommerce_shop_page_title') : get_the_title($shop_page_id);
         // No shop set up
         if (-1 == $shop_page_id) {
             $url = home_url('/');
             $title = 'Home';
         }
     } elseif ('post' == $post_type) {
         $blog_id = get_option('page_for_posts');
         $url = get_permalink($blog_id);
         $title = get_the_title($blog_id);
     } else {
         return;
         // Don't generate a link at all
     }
     // Deal with the tag
     $allowed_html = array('h1', 'h2', 'h3', 'h4', 'span', 'div', 'i', 'b', 'strong');
     if ($tag) {
         $tag_open = '<' . wp_kses($tag, $allowed_html) . '>';
         $tag_close = '</' . wp_kses($tag, $allowed_html) . '>';
     } else {
         $tag_open = '';
         $tag_close = '';
     }
     printf('<a href="%1$s" alt="%2$s" class="button">%3$s%4$s%5$s</a>', esc_url($url), esc_attr($title), $tag_open, __('View All', 'create'), $tag_close);
 }
开发者ID:popshuvitdude,项目名称:orchard,代码行数:31,代码来源:template-tags.php

示例13: wcs_get_users_resubscribe_link

/**
 * Returns a URL including required parameters for an authenticated user to renew a subscription
 *
 * @param  int | WC_Subscription $subscription Post ID of a 'shop_subscription' post, or instance of a WC_Subscription object
 * @return string
 * @since  2.0
 */
function wcs_get_users_resubscribe_link($subscription)
{
    $subscription_id = is_object($subscription) ? $subscription->id : $subscription;
    $resubscribe_link = add_query_arg(array('resubscribe' => $subscription_id), get_permalink(wc_get_page_id('myaccount')));
    $resubscribe_link = wp_nonce_url($resubscribe_link, $subscription_id);
    return apply_filters('wcs_users_resubscribe_link', $resubscribe_link, $subscription_id);
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:14,代码来源:wcs-resubscribe-functions.php

示例14: is_available

 /**
  * [is_available description]
  * @return boolean [description]
  */
 public function is_available()
 {
     $order = null;
     if (!$this->enable_for_virtual) {
         if (WC()->cart && !WC()->cart->needs_shipping()) {
             return false;
         }
         if (is_page(wc_get_page_id('checkout')) && 0 < get_query_var('order-pay')) {
             $order_id = absint(get_query_var('order-pay'));
             $order = wc_get_order($order_id);
             $needs_shipping = false;
             if (0 < sizeof($order->get_items())) {
                 foreach ($order->get_items() as $item) {
                     $_product = $order->get_product_from_item($item);
                     if ($_product->needs_shipping()) {
                         $needs_shipping = true;
                         break;
                     }
                 }
             }
             $needs_shipping = apply_filters('woocommerce_cart_needs_shipping', $needs_shipping);
             if ($needs_shipping) {
                 return false;
             }
         }
     }
     if (!empty($this->enable_for_methods)) {
         $chosen_shipping_methods_session = WC()->session->get('chosen_shipping_methods');
         if (isset($chosen_shipping_methods_session)) {
             $chosen_shipping_methods = array_unique($chosen_shipping_methods_session);
         } else {
             $chosen_shipping_methods = array();
         }
         $check_method = false;
         if (is_object($order)) {
             if ($order->shipping_method) {
                 $check_method = $order->shipping_method;
             }
         } elseif (empty($chosen_shipping_methods) || sizeof($chosen_shipping_methods) > 1) {
             $check_method = false;
         } elseif (sizeof($chosen_shipping_methods) == 1) {
             $check_method = $chosen_shipping_methods[0];
         }
         if (!$check_method) {
             return false;
         }
         $found = false;
         foreach ($this->enable_for_methods as $method_id) {
             if (strpos($check_method, $method_id) === 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             return false;
         }
     }
     return parent::is_available();
 }
开发者ID:justingreerbbi,项目名称:user-waller-credit-system,代码行数:63,代码来源:gateway.php

示例15: members_only_price

 function members_only_price($price)
 {
     if (is_user_logged_in()) {
         return $price;
     } else {
         return '<p style="color:' . get_option('yith_hide_price_change_color') . '"><a style="display:inline; color:' . get_option('yith_hide_price_change_color') . '" href="' . get_permalink(function_exists('wc_get_page_id') ? wc_get_page_id('myaccount') : woocommerce_get_page_id('myaccount')) . '">' . get_option('yith_hide_price_link_text') . '</a> ' . get_option('yith_hide_price_text') . '</p>';
     }
 }
开发者ID:NgocSon2412,项目名称:website_banhang,代码行数:8,代码来源:hide-price.php


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