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


PHP wc_get_page_permalink函数代码示例

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


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

示例1: wc_template_redirect

/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    // When default permalinks are enabled, redirect shop page to post type archive url
    if (!empty($_GET['page_id']) && '' === get_option('permalink_structure') && $_GET['page_id'] == wc_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && WC()->cart->is_empty() && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        wp_redirect(wc_get_page_permalink('cart'));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        wp_redirect(str_replace('&', '&', wp_logout_url(wc_get_page_permalink('myaccount'))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && 1 === $wp_query->found_posts) {
        $product = wc_get_product($wp_query->post);
        if ($product && $product->is_visible()) {
            wp_safe_redirect(get_permalink($product->id), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
开发者ID:DustinHartzler,项目名称:woocommerce,代码行数:32,代码来源:wc-template-functions.php

示例2: wc_template_redirect

/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    if (!empty($_GET['page_id']) && '' === get_option('permalink_structure') && wc_get_page_id('shop') == $_GET['page_id']) {
        // When default permalinks are enabled, redirect shop page to post type archive url
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && wc_get_page_id('checkout') !== wc_get_page_id('cart') && WC()->cart->is_empty() && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        // When on the checkout with an empty cart, redirect to cart page
        wc_add_notice(__('Checkout is not available whilst your cart is empty.', 'woocommerce'), 'notice');
        wp_redirect(wc_get_page_permalink('cart'));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        // Logout
        wp_redirect(str_replace('&', '&', wp_logout_url(wc_get_page_permalink('myaccount'))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && 1 === absint($wp_query->found_posts)) {
        // Redirect to the product page if we have a single product
        $product = wc_get_product($wp_query->post);
        if ($product && $product->is_visible()) {
            wp_safe_redirect(get_permalink($product->get_id()), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        // Ensure payment gateways are loaded early
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Checkout pages handling
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:38,代码来源:wc-template-functions.php

示例3: wc_checkout_is_https

 /**
  * Backports wc_checkout_is_https() to 2.4.x
  *
  * @since  4.3.0-beta
  * @return bool
  */
 public static function wc_checkout_is_https()
 {
     if (self::is_wc_version_gte_2_5()) {
         return wc_checkout_is_https();
     } else {
         return wc_site_is_https() || 'yes' === get_option('woocommerce_force_ssl_checkout') || class_exists('WordPressHTTPS') || strstr(wc_get_page_permalink('checkout'), 'https:');
     }
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:14,代码来源:class-sv-wc-plugin-compatibility.php

示例4: get_url

 /**
  * @param $page
  */
 function get_url($page)
 {
     switch ($page) {
         case 'sign_out':
             return wc_get_endpoint_url('customer-logout', '', wc_get_page_permalink('myaccount'));
         case 'edit_account_url':
             return wc_customer_edit_account_url();
     }
 }
开发者ID:hoangsoft90,项目名称:hw-hoangweb-plugin,代码行数:12,代码来源:hw-woo-customer.php

示例5: test_get_remove_url

 /**
  * Test get_remove_url
  *
  * @since 2.3
  */
 public function test_get_remove_url()
 {
     // Get the cart page id
     $cart_page_url = wc_get_page_permalink('cart');
     // Test cart item key
     $cart_item_key = 'test';
     // Do the check
     $this->assertEquals(apply_filters('woocommerce_get_remove_url', $cart_page_url ? wp_nonce_url(add_query_arg('remove_item', $cart_item_key, $cart_page_url), 'woocommerce-cart') : ''), WC()->cart->get_remove_url($cart_item_key));
 }
开发者ID:noahjohn9259,项目名称:woocommerce,代码行数:14,代码来源:cart.php

示例6: wc_get_page_permalink

 /**
  * Get the page permalink
  *
  * Backports wc_page_page_permalink to WC 2.3.3 and lower
  *
  * @link https://github.com/woothemes/woocommerce/pull/7438
  *
  * @since 4.0.0
  * @param string $page page - myaccount, edit_address, shop, cart, checkout, pay, view_order, terms
  * @return string
  */
 public static function wc_get_page_permalink($page)
 {
     if (self::is_wc_version_gt('2.3.3')) {
         return wc_get_page_permalink($page);
     } else {
         $permalink = get_permalink(wc_get_page_id($page));
         return apply_filters('woocommerce_get_' . $page . '_page_permalink', $permalink);
     }
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:20,代码来源:class-sv-wc-plugin-compatibility.php

示例7: maybe_remove_or_add_item_to_subscription

 /**
  * Process the remove or re-add a line item from a subscription request.
  *
  * @since 2.0
  */
 public static function maybe_remove_or_add_item_to_subscription()
 {
     if (isset($_GET['subscription_id']) && (isset($_GET['remove_item']) || isset($_GET['undo_remove_item'])) && isset($_GET['_wpnonce'])) {
         $subscription = wcs_is_subscription($_GET['subscription_id']) ? wcs_get_subscription($_GET['subscription_id']) : false;
         $undo_request = isset($_GET['undo_remove_item']) ? true : false;
         $item_id = $undo_request ? $_GET['undo_remove_item'] : $_GET['remove_item'];
         if (false === $subscription) {
             wc_add_notice(sprintf(_x('Subscription #%d does not exist.', 'hash before subscription ID', 'woocommerce-subscriptions'), $_GET['subscription_id']), 'error');
             wp_safe_redirect(wc_get_page_permalink('myaccount'));
             exit;
         }
         if (self::validate_remove_items_request($subscription, $item_id, $undo_request)) {
             if ($undo_request) {
                 // handle undo request
                 $removed_item = WC()->session->get('removed_subscription_items', array());
                 if (!empty($removed_item[$item_id]) && $subscription->id == $removed_item[$item_id]) {
                     // restore the item
                     wc_update_order_item($item_id, array('order_item_type' => 'line_item'));
                     unset($removed_item[$item_id]);
                     WC()->session->set('removed_subscription_items', $removed_item);
                     // restore download permissions for this item
                     $line_items = $subscription->get_items();
                     $line_item = $line_items[$item_id];
                     $_product = $subscription->get_product_from_item($line_item);
                     $product_id = wcs_get_canonical_product_id($line_item);
                     if ($_product && $_product->exists() && $_product->is_downloadable()) {
                         $downloads = $_product->get_files();
                         foreach (array_keys($downloads) as $download_id) {
                             wc_downloadable_file_permission($download_id, $product_id, $subscription, $line_item['qty']);
                         }
                     }
                     // translators: 1$: product name, 2$: product id
                     $subscription->add_order_note(sprintf(_x('Customer added "%1$s" (Product ID: #%2$d) via the My Account page.', 'used in order note', 'woocommerce-subscriptions'), wcs_get_line_item_name($line_item), $product_id));
                 } else {
                     wc_add_notice(__('Your request to undo your previous action was unsuccessful.', 'woocommerce-subscriptions'));
                 }
             } else {
                 // handle remove item requests
                 WC()->session->set('removed_subscription_items', array($item_id => $subscription->id));
                 // remove download access for the item
                 $line_items = $subscription->get_items();
                 $line_item = $line_items[$item_id];
                 $product_id = wcs_get_canonical_product_id($line_item);
                 WCS_Download_Handler::revoke_downloadable_file_permission($product_id, $subscription->id, $subscription->get_user_id());
                 // remove the line item from subscription but preserve its data in the DB
                 wc_update_order_item($item_id, array('order_item_type' => 'line_item_removed'));
                 // translators: 1$: product name, 2$: product id
                 $subscription->add_order_note(sprintf(_x('Customer removed "%1$s" (Product ID: #%2$d) via the My Account page.', 'used in order note', 'woocommerce-subscriptions'), wcs_get_line_item_name($line_item), $product_id));
                 // translators: placeholders are 1$: item name, and, 2$: opening and, 3$: closing link tags
                 wc_add_notice(sprintf(__('You have successfully removed "%1$s" from your subscription. %2$sUndo?%3$s', 'woocommerce-subscriptions'), $line_item['name'], '<a href="' . esc_url(self::get_undo_remove_url($subscription->id, $item_id, $subscription->get_view_order_url())) . '" >', '</a>'));
             }
         }
         $subscription->calculate_totals();
         wp_safe_redirect($subscription->get_view_order_url());
         exit;
     }
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:62,代码来源:class-wcs-remove-item.php

示例8: get_return_url

 /**
  * Get the return url (thank you page).
  *
  * @param WC_Order $order
  * @return string
  */
 public function get_return_url($order = null)
 {
     if ($order) {
         $return_url = $order->get_checkout_order_received_url();
     } else {
         $return_url = wc_get_endpoint_url('order-received', '', wc_get_page_permalink('checkout'));
     }
     if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') {
         $return_url = str_replace('http:', 'https:', $return_url);
     }
     return apply_filters('woocommerce_get_return_url', $return_url, $order);
 }
开发者ID:estrategasdigitales,项目名称:venone,代码行数:18,代码来源:abstract-wc-payment-gateway.php

示例9: flatsome_continue_shopping

    function flatsome_continue_shopping()
    {
        ?>
 
     <a class="button-continue-shopping button alt-button small"  href="<?php 
        echo wc_get_page_permalink('shop');
        ?>
">
        &#8592; <?php 
        echo __('Continue Shopping', 'woocommerce');
        ?>
</a> 
     <?php 
    }
开发者ID:allurewebsolutions,项目名称:wordpress-starter-kit,代码行数:14,代码来源:template-tags-checkout.php

示例10: user_autologout

function user_autologout()
{
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $user_id = $current_user->ID;
        $approved_status = get_user_meta($user_id, 'wp-approve-user', true);
        //if the user hasn't been approved yet by WP Approve User plugin, destroy the cookie to kill the session and log them out
        if ($approved_status == 1) {
            return wc_get_page_permalink('myaccount');
            //return $redirect_url;
        } else {
            return get_edit_billing_address_url();
            // wp_logout();
            // return get_permalink( wc_get_page_id( 'myaccount' ) ) . "?approved=false";
        }
    }
}
开发者ID:taeche,项目名称:SoDoEx,代码行数:17,代码来源:functions.php

示例11: wc_add_to_cart_message

/**
 * Add to cart messages.
 *
 * @access public
 * @param int|array $product_id
 */
function wc_add_to_cart_message($product_id)
{
    if (is_array($product_id)) {
        $titles = array();
        foreach ($product_id as $id) {
            $titles[] = get_the_title($id);
        }
        $added_text = sprintf(__('Added %s to your cart.', 'woocommerce'), wc_format_list_of_items($titles));
    } else {
        $added_text = sprintf(__('&quot;%s&quot; was successfully added to your cart.', 'woocommerce'), get_the_title($product_id));
    }
    // Output success messages
    if (get_option('woocommerce_cart_redirect_after_add') == 'yes') {
        $return_to = apply_filters('woocommerce_continue_shopping_redirect', wp_get_referer() ? wp_get_referer() : home_url());
        $message = sprintf('<p class="[ text-center ]"> %3$s <br /><br /><a href="%s" class="[ button button--primary ][ no-margin ][ pull-none ][ wc-forward ]">%s</a></p>', $return_to, __('Continue Shopping', 'woocommerce'), $added_text);
    } else {
        $message = sprintf('<p class="[ text-center ]"> %3$s <br /><br /><a href="%s" class="[ button button--primary ][ no-margin ][ pull-none ][ wc-forward ]">%s</a></p>', wc_get_page_permalink('cart'), __('View Cart', 'woocommerce'), $added_text);
    }
    wc_add_notice(apply_filters('wc_add_to_cart_message', $message, $product_id));
}
开发者ID:pcuervo,项目名称:ur-imprint,代码行数:26,代码来源:wc-cart-functions.php

示例12: woocommerce_social_login_link_account_buttons

 /**
  * Pluggable function to render social login "link your account" buttons
  *
  * @since 1.1.0
  * @param string $return_url Return url, defaults my account page
  */
 function woocommerce_social_login_link_account_buttons($return_url = null)
 {
     if (!is_user_logged_in()) {
         return;
     }
     // If no return_url, use the my account page
     if (!$return_url) {
         $return_url = wc_get_page_permalink('myaccount');
     }
     // Enqueue styles and scripts
     wc_social_login()->frontend->load_styles_scripts();
     $available_providers = array();
     // determine available providers for user
     foreach (wc_social_login()->get_available_providers() as $provider) {
         if (!get_user_meta(get_current_user_id(), '_wc_social_login_' . $provider->get_id() . '_profile', true)) {
             $available_providers[] = $provider;
         }
     }
     // load the template
     wc_get_template('global/social-login-link-account.php', array('available_providers' => $available_providers, 'return_url' => $return_url), '', wc_social_login()->get_plugin_path() . '/templates/');
 }
开发者ID:pcuervo,项目名称:dabba,代码行数:27,代码来源:wc-social-login-template-functions.php

示例13: wc_add_to_cart_message

/**
 * Add to cart messages.
 *
 * @access public
 * @param int|array $product_id
 */
function wc_add_to_cart_message($product_id)
{
    $titles = array();
    if (is_array($product_id)) {
        foreach ($product_id as $id) {
            $titles[] = get_the_title($id);
        }
    } else {
        $titles[] = get_the_title($product_id);
    }
    $titles = array_filter($titles);
    $added_text = sprintf(_n('%s has been added to your cart.', '%s have been added to your cart.', sizeof($titles), 'woocommerce'), wc_format_list_of_items($titles));
    // Output success messages
    if ('yes' === get_option('woocommerce_cart_redirect_after_add')) {
        $return_to = apply_filters('woocommerce_continue_shopping_redirect', wp_get_referer() ? wp_get_referer() : home_url());
        $message = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', esc_url($return_to), esc_html__('Continue Shopping', 'woocommerce'), esc_html($added_text));
    } else {
        $message = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', esc_url(wc_get_page_permalink('cart')), esc_html__('View Cart', 'woocommerce'), esc_html($added_text));
    }
    wc_add_notice(apply_filters('wc_add_to_cart_message', $message, $product_id));
}
开发者ID:randyriolis,项目名称:woocommerce,代码行数:27,代码来源:wc-cart-functions.php

示例14: esc_url

        ?>
</p>

		<p>
			<a href="<?php 
        echo esc_url($order->get_checkout_payment_url());
        ?>
" class="button pay"><?php 
        _e('Pay', WC_QD_TXT);
        ?>
</a>
			<?php 
        if (is_user_logged_in()) {
            ?>
			<a href="<?php 
            echo esc_url(wc_get_page_permalink('myaccount'));
            ?>
" class="button pay"><?php 
            _e('My Account', WC_QD_TXT);
            ?>
</a>
			<?php 
        }
        ?>
		</p>

	<?php 
    } else {
        ?>

		<p><?php 
开发者ID:bestmazzo,项目名称:woocomerce-quick-donation,代码行数:31,代码来源:donation-thankyou.php

示例15: add_payment_method

 /**
  * Show the add payment method page
  */
 private static function add_payment_method()
 {
     if (!is_user_logged_in()) {
         wp_safe_redirect(wc_get_page_permalink('myaccount'));
         exit;
     } else {
         do_action('before_woocommerce_add_payment_method');
         wc_add_notice(__('Add a new payment method.', 'woocommerce'), 'notice');
         wc_print_notices();
         // Add payment method form
         wc_get_template('myaccount/form-add-payment-method.php');
         wc_print_notices();
         do_action('after_woocommerce_add_payment_method');
     }
 }
开发者ID:nightbook,项目名称:woocommerce,代码行数:18,代码来源:class-wc-shortcode-my-account.php


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