本文整理汇总了PHP中wc_create_page函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_create_page函数的具体用法?PHP wc_create_page怎么用?PHP wc_create_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_create_page函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install_woocommerce_catalog_restrictions
function install_woocommerce_catalog_restrictions()
{
global $woocommerce, $wc_catalog_restrictions, $wpdb;
if (!WC_Catalog_Visibility_Compatibility::is_wc_version_gte_2_1()) {
include_once $woocommerce->plugin_path() . '/admin/woocommerce-admin-install.php';
}
//Clean up old rules.
$wc_term_meta_table = $wpdb->prefix . 'woocommerce_termmeta';
$wpdb->query("DELETE FROM {$wc_term_meta_table} WHERE (meta_key = '_wc_restrictions' OR meta_key = '_wc_restrictions_allowed') AND (meta_value = '');");
$wpdb->query("DELETE FROM {$wc_term_meta_table} WHERE (meta_key = '_wc_restrictions_location' OR meta_key = '_wc_restrictions_locations') AND (meta_value = '');");
//Clean up the transients
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_twccr%'");
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_twccr%'");
if (!get_option('woocommerce_choose_location_page_id')) {
if (!WC_Catalog_Visibility_Compatibility::is_wc_version_gte_2_1()) {
wc_create_page(esc_sql(_x('choose-location', 'page_slug', 'wc_catalog_restrictions')), 'woocommerce_choose_location_page_id', __('Your Location', 'wc_catalog_restrictions'), '[location_picker /]');
} else {
woocommerce_create_page(esc_sql(_x('choose-location', 'page_slug', 'wc_catalog_restrictions')), 'woocommerce_choose_location_page_id', __('Your Location', 'wc_catalog_restrictions'), '[location_picker /]');
}
}
update_option("woocommerce_catalog_restrictions_db_version", $wc_catalog_restrictions->version);
}
示例2: create_pages
/**
* Create pages that the plugin relies on, storing page id's in variables.
*/
public static function create_pages()
{
include_once dirname(__FILE__) . '/admin/wc-admin-functions.php';
$pages = apply_filters('woocommerce_create_pages', array('shop' => array('name' => _x('shop', 'Page slug', 'woocommerce'), 'title' => _x('Shop', 'Page title', 'woocommerce'), 'content' => ''), 'cart' => array('name' => _x('cart', 'Page slug', 'woocommerce'), 'title' => _x('Cart', 'Page title', 'woocommerce'), 'content' => '[' . apply_filters('woocommerce_cart_shortcode_tag', 'woocommerce_cart') . ']'), 'checkout' => array('name' => _x('checkout', 'Page slug', 'woocommerce'), 'title' => _x('Checkout', 'Page title', 'woocommerce'), 'content' => '[' . apply_filters('woocommerce_checkout_shortcode_tag', 'woocommerce_checkout') . ']'), 'myaccount' => array('name' => _x('my-account', 'Page slug', 'woocommerce'), 'title' => _x('My account', 'Page title', 'woocommerce'), 'content' => '[' . apply_filters('woocommerce_my_account_shortcode_tag', 'woocommerce_my_account') . ']')));
foreach ($pages as $key => $page) {
wc_create_page(esc_sql($page['name']), 'woocommerce_' . $key . '_page_id', $page['title'], $page['content'], !empty($page['parent']) ? wc_get_page_id($page['parent']) : '');
}
delete_transient('woocommerce_cache_excluded_uris');
}
示例3: create_pages
/**
* Create pages that the plugin relies on, storing page id's in variables.
*
* @access public
* @return void
*/
public static function create_pages()
{
$pages = apply_filters('woocommerce_create_pages', array('shop' => array('name' => _x('shop', 'Page slug', 'woocommerce'), 'title' => _x('Shop', 'Page title', 'woocommerce'), 'content' => ''), 'cart' => array('name' => _x('cart', 'Page slug', 'woocommerce'), 'title' => _x('Cart', 'Page title', 'woocommerce'), 'content' => '[' . apply_filters('woocommerce_cart_shortcode_tag', 'woocommerce_cart') . ']'), 'checkout' => array('name' => _x('checkout', 'Page slug', 'woocommerce'), 'title' => _x('Checkout', 'Page title', 'woocommerce'), 'content' => '[' . apply_filters('woocommerce_checkout_shortcode_tag', 'woocommerce_checkout') . ']'), 'myaccount' => array('name' => _x('my-account', 'Page slug', 'woocommerce'), 'title' => _x('My Account', 'Page title', 'woocommerce'), 'content' => '[' . apply_filters('woocommerce_my_account_shortcode_tag', 'woocommerce_my_account') . ']')));
foreach ($pages as $key => $page) {
wc_create_page(esc_sql($page['name']), 'woocommerce_' . $key . '_page_id', $page['title'], $page['content'], !empty($page['parent']) ? wc_get_page_id($page['parent']) : '');
}
}
示例4: woocommerce_create_page
/**
* @deprecated
*/
function woocommerce_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0)
{
_deprecated_function('woocommerce_create_page', '2.1', 'wc_create_page');
return wc_create_page($slug, $option, $page_title, $page_content, $post_parent);
}
示例5: paypal_express_checkout
/**
* PayPal Express Checkout
*
* Main action function that handles PPE actions:
* 1. 'expresscheckout' - Initiates the Express Checkout process; called by the checkout button.
* 2. 'revieworder' - Customer has reviewed the order. Saves shipping info to order.
* 3. 'payaction' - Customer has pressed "Place Order" on the review page.
*/
function paypal_express_checkout($posted = null)
{
if (!empty($posted) || isset($_GET['pp_action']) && $_GET['pp_action'] == 'expresscheckout') {
if (sizeof(WC()->cart->get_cart()) > 0) {
// The customer has initiated the Express Checkout process with the button on the cart page
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
$this->add_log('Start Express Checkout');
/**
* Check if the EC button used was the PayPal Credit button.
* This $usePayPalCredit flag will be used to adjust the SEC request accordingly.
*/
if (isset($_GET['use_paypal_credit']) && 'true' == $_GET['use_paypal_credit']) {
$usePayPalCredit = true;
} else {
$usePayPalCredit = false;
}
WC()->cart->calculate_totals();
//$paymentAmount = WC()->cart->get_total();
$paymentAmount = AngellEYE_Gateway_Paypal::number_format(WC()->cart->total);
//Check if review order page is exist, otherwise re-create it on the fly
$review_order_page_url = get_permalink(wc_get_page_id('review_order'));
if (!$review_order_page_url) {
$this->add_log(__('Review Order Page not found, re-create it. ', 'paypal-for-woocommerce'));
include_once WC()->plugin_path() . '/includes/admin/wc-admin-functions.php';
$page_id = wc_create_page(esc_sql(_x('review-order', 'page_slug', 'woocommerce')), 'woocommerce_review_order_page_id', __('Checkout → Review Order', 'paypal-for-woocommerce'), '[woocommerce_review_order]', wc_get_page_id('checkout'));
$review_order_page_url = get_permalink($page_id);
}
$returnURL = urlencode(add_query_arg('pp_action', 'revieworder', $review_order_page_url));
$cancelURL = isset($this->settings['cancel_page']) ? get_permalink($this->settings['cancel_page']) : WC()->cart->get_cart_url();
$cancelURL = apply_filters('angelleye_express_cancel_url', urlencode($cancelURL));
$resArray = $this->CallSetExpressCheckout($paymentAmount, $returnURL, $cancelURL, $usePayPalCredit, $posted);
$ack = strtoupper($resArray["ACK"]);
/**
* I've replaced the original redirect URL's here with
* what the PayPal class library returns so that options like
* "skip details" will work correctly with PayPal's review pages.
*/
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
$this->add_log('Redirecting to PayPal');
if (is_ajax()) {
$result = array('redirect' => $resArray['REDIRECTURL'], 'result' => 'success');
echo json_encode($result);
exit;
} else {
//$this->RedirectToPayPal( $resArray["TOKEN"] );
wp_redirect($resArray['REDIRECTURL']);
exit;
}
} else {
// Display a user friendly Error on the page and log details
$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
$this->add_log(__('SetExpressCheckout API call failed. ', 'paypal-for-woocommerce'));
$this->add_log(__('Detailed Error Message: ', 'paypal-for-woocommerce') . $ErrorLongMsg);
$this->add_log(__('Short Error Message: ', 'paypal-for-woocommerce') . $ErrorShortMsg);
$this->add_log(__('Error Code: ', 'paypal-for-woocommerce') . $ErrorCode);
$this->add_log(__('Error Severity Code: ', 'paypal-for-woocommerce') . $ErrorSeverityCode);
// Notice admin if has any issue from PayPal
$message = '';
if ($this->error_email_notify) {
$admin_email = get_option("admin_email");
$message .= __("SetExpressCheckout API call failed.", "paypal-for-woocommerce") . "\n\n";
$message .= __('Error Code: ', 'paypal-for-woocommerce') . $ErrorCode . "\n";
$message .= __('Error Severity Code: ', 'paypal-for-woocommerce') . $ErrorSeverityCode . "\n";
$message .= __('Short Error Message: ', 'paypal-for-woocommerce') . $ErrorShortMsg . "\n";
$message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $ErrorLongMsg . "\n";
$message .= __('User IP: ', 'paypal-for-woocommerce') . $this->get_user_ip() . "\n";
$error_email_notify_mes = apply_filters('ae_ppec_error_email_message', $message, $ErrorCode, $ErrorSeverityCode, $ErrorShortMsg, $ErrorLongMsg);
$subject = "PayPal Express Checkout Error Notification";
$error_email_notify_subject = apply_filters('ae_ppec_error_email_subject', $subject);
wp_mail($admin_email, $error_email_notify_subject, $error_email_notify_mes);
}
// Generate error message based on Error Display Type setting
if ($this->error_display_type == 'detailed') {
$sec_error_notice = $ErrorCode . ' - ' . $ErrorLongMsg;
$error_display_type_message = sprintf(__($sec_error_notice, 'paypal-for-woocommerce'));
} else {
$error_display_type_message = sprintf(__('There was a problem paying with PayPal. Please try another method.', 'paypal-for-woocommerce'));
}
$error_display_type_message = apply_filters('ae_ppec_error_user_display_message', $error_display_type_message, $ErrorCode, $ErrorLongMsg);
wc_add_notice($error_display_type_message, 'error');
if (!is_ajax()) {
wp_redirect(get_permalink(wc_get_page_id('cart')));
exit;
} else {
return;
}
}
//.........这里部分代码省略.........
示例6: create_become_a_vendor_page
public static function create_become_a_vendor_page()
{
$become_a_vendor_page = get_option('yith_wpv_become_a_vendor_page_id');
if ($become_a_vendor_page === false) {
/* wc_create_page( $slug, $option, $page_title, $page_content, $post_parent ) */
$page_id = wc_create_page('become-a-vendor', 'yith_wpv_become_a_vendor_page_id', __('Become a vendor', 'yith_wc_product_vendors'), '[yith_wcmv_become_a_vendor]', 0);
}
}
示例7: activate_paypal_for_woocommerce
/**
* Run when plugin is activated
*/
function activate_paypal_for_woocommerce()
{
// If WooCommerce is not enabled, deactivate plugin.
if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) && !is_plugin_active_for_network('woocommerce/woocommerce.php')) {
deactivate_plugins(plugin_basename(__FILE__));
} else {
global $woocommerce;
// Create review page for Express Checkout
wc_create_page(esc_sql(_x('review-order', 'page_slug', 'woocommerce')), 'woocommerce_review_order_page_id', __('Checkout → Review Order', 'paypal-for-woocommerce'), '[woocommerce_review_order]', wc_get_page_id('checkout'));
// Log activation in Angell EYE database via web service.
$log_url = $_SERVER['HTTP_HOST'];
$log_plugin_id = 1;
$log_activation_status = 1;
wp_remote_request('http://www.angelleye.com/web-services/wordpress/update-plugin-status.php?url=' . $log_url . '&plugin_id=' . $log_plugin_id . '&activation_status=' . $log_activation_status);
}
}
示例8: ywrr_create_pages
/**
* Creates the unsubscribe page
*
* @since 1.0.0
* @return void
* @author Alberto Ruggiero
*/
public function ywrr_create_pages()
{
if (!function_exists('wc_create_page')) {
return;
}
$pages = apply_filters('woocommerce_create_pages', array('unsubscribe' => array('name' => _x('unsubscribe', 'Page slug', 'ywrr'), 'title' => _x('Unsubscribe', 'Page title', 'ywrr'), 'content' => '[ywrr_unsubscribe]')));
foreach ($pages as $key => $page) {
wc_create_page(esc_sql($page['name']), 'ywrr_' . $key . '_page_id', $page['title'], $page['content'], !empty($page['parent']) ? wc_get_page_id($page['parent']) : '');
}
$unsubscribe_page = array('ID' => get_option('ywrr_unsubscribe_page_id'), 'post_status' => 'ywrr-unsubscribe');
wp_update_post($unsubscribe_page);
}
示例9: install
/**
* Install default settings & pages
*
* @since 1.0.0
* @see SV_WC_Plugin::install()
*/
protected function install()
{
// install default "content restricted" page
$title = _x('Content restricted', 'Page title', WC_Memberships::TEXT_DOMAIN);
$slug = _x('content-restricted', 'Page slug', WC_Memberships::TEXT_DOMAIN);
$content = '[wcm_content_restricted]';
wc_create_page(esc_sql($slug), 'wc_memberships_redirect_page_id', $title, $content);
// include settings so we can install defaults
include_once WC()->plugin_path() . '/includes/admin/settings/class-wc-settings-page.php';
$settings = (require_once $this->get_plugin_path() . '/includes/admin/class-wc-memberships-settings.php');
// install default settings for each section
foreach ($settings->get_sections() as $section => $label) {
foreach ($settings->get_settings($section) as $setting) {
if (isset($setting['default'])) {
update_option($setting['id'], $setting['default']);
}
}
}
}
示例10: activate_plugin
public static function activate_plugin()
{
global $wp_rewrite;
$errors = self::check_requirements();
if (empty($errors)) {
WC_BooXtream::add_rewrite_rules();
$wp_rewrite->flush_rules();
/*
* Create page for processing asynchronous request to BooXtream
*/
$slug = __('download_processing', 'woocommerce_booxtream');
$title = __('Your download is not ready yet', 'woocommerce_booxtream');
$content = '<p>' . __('We are currently processing your download, please try again in a few seconds', 'woocommerce_booxtream') . '</p>';
wc_create_page(esc_sql($slug), 'woocommerce_download_processing_page_id', $title, $content, '');
return;
}
// Suppress "Plugin activated" notice.
unset($_GET['activate']);
// this plugin's name
$name = get_file_data(__FILE__, array('Plugin Name'), 'plugin');
if (count($errors) > 0) {
printf('<div class="error"><p>%1$s</p>' . '<p><i>%2$s</i> ' . __('has been deactivated', 'woocommerce_booxtream') . '</p></div>', join('</p><p>', $errors), $name[0]);
deactivate_plugins(plugin_basename(__FILE__));
}
// this will trigger the much coveted fatal error instead of 'unexpected output'
exit;
}
示例11: paypal_express_checkout
/**
* PayPal Express Checkout
*
* Main action function that handles PPE actions:
* 1. 'expresscheckout' - Initiates the Express Checkout process; called by the checkout button.
* 2. 'revieworder' - Customer has reviewed the order. Saves shipping info to order.
* 3. 'payaction' - Customer has pressed "Place Order" on the review page.
*/
function paypal_express_checkout($posted = null)
{
if (!empty($posted) || isset($_GET['pp_action']) && $_GET['pp_action'] == 'expresscheckout') {
if (sizeof(WC()->cart->get_cart()) > 0) {
// The customer has initiated the Express Checkout process with the button on the cart page
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
$this->add_log('Start Express Checkout');
/**
* Check if the EC button used was the PayPal Credit button.
* This $usePayPalCredit flag will be used to adjust the SEC request accordingly.
*/
if (isset($_GET['use_paypal_credit']) && 'true' == $_GET['use_paypal_credit']) {
$usePayPalCredit = true;
} else {
$usePayPalCredit = false;
}
WC()->cart->calculate_totals();
//$paymentAmount = WC()->cart->get_total();
$paymentAmount = number_format(WC()->cart->total, 2, '.', '');
//Check if review order page is exist, otherwise re-create it on the fly
$review_order_page_url = get_permalink(wc_get_page_id('review_order'));
if (!$review_order_page_url) {
$this->add_log(__('Review Order Page not found, re-create it. ', 'paypal-for-woocommerce'));
include_once WC()->plugin_path() . '/includes/admin/wc-admin-functions.php';
$page_id = wc_create_page(esc_sql(_x('review-order', 'page_slug', 'woocommerce')), 'woocommerce_review_order_page_id', __('Checkout → Review Order', 'paypal-for-woocommerce'), '[woocommerce_review_order]', wc_get_page_id('checkout'));
$review_order_page_url = get_permalink($page_id);
}
$returnURL = urlencode(add_query_arg('pp_action', 'revieworder', $review_order_page_url));
$cancelURL = urlencode(WC()->cart->get_cart_url());
$resArray = $this->CallSetExpressCheckout($paymentAmount, $returnURL, $cancelURL, $usePayPalCredit, $posted);
$ack = strtoupper($resArray["ACK"]);
/**
* I've replaced the original redirect URL's here with
* what the PayPal class library returns so that options like
* "skip details" will work correctly with PayPal's review pages.
*/
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
$this->add_log('Redirecting to PayPal');
if (is_ajax()) {
$result = array('redirect' => $resArray['REDIRECTURL'], 'result' => 'success');
echo '<!--WC_START-->' . json_encode($result) . '<!--WC_END-->';
exit;
} else {
//$this->RedirectToPayPal( $resArray["TOKEN"] );
wp_redirect($resArray['REDIRECTURL']);
exit;
}
} else {
// Display a user friendly Error on the page and log details
$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
$this->add_log(__('SetExpressCheckout API call failed. ', 'paypal-for-woocommerce'));
$this->add_log(__('Detailed Error Message: ', 'paypal-for-woocommerce') . $ErrorLongMsg);
$this->add_log(__('Short Error Message: ', 'paypal-for-woocommerce') . $ErrorShortMsg);
$this->add_log(__('Error Code: ', 'paypal-for-woocommerce') . $ErrorCode);
$this->add_log(__('Error Severity Code: ', 'paypal-for-woocommerce') . $ErrorSeverityCode);
// Notice admin if has any issue from PayPal
$message = '';
if ($this->error_email_notify) {
$admin_email = get_option("admin_email");
$message .= __("SetExpressCheckout API call failed.", "paypal-for-woocommerce") . "\n\n";
$message .= __('Error Code: ', 'paypal-for-woocommerce') . $ErrorCode . "\n";
$message .= __('Error Severity Code: ', 'paypal-for-woocommerce') . $ErrorSeverityCode . "\n";
$message .= __('Short Error Message: ', 'paypal-for-woocommerce') . $ErrorShortMsg . "\n";
$message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $ErrorLongMsg . "\n";
wp_mail($admin_email, "PayPal Express Checkout Error Notification", $message);
}
// Generate error message based on Error Display Type setting
if ($this->error_display_type == 'detailed') {
$sec_error_notice = $ErrorCode . ' - ' . $ErrorLongMsg;
wc_add_notice(sprintf(__($sec_error_notice, 'paypal-for-woocommerce')), 'error');
} else {
wc_add_notice(sprintf(__('There was a problem paying with PayPal. Please try another method.', 'paypal-for-woocommerce')), 'error');
}
if (!is_ajax()) {
wp_redirect(get_permalink(wc_get_page_id('cart')));
exit;
} else {
return;
}
}
}
} elseif (isset($_GET['pp_action']) && $_GET['pp_action'] == 'revieworder') {
wc_clear_notices();
// The customer has logged into PayPal and approved order.
// Retrieve the shipping details and present the order for completion.
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
//.........这里部分代码省略.........
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:101,代码来源:wc-gateway-paypal-express-angelleye.php
示例12: create_pages
/**
* Create pages that the plugin relies on, storing page id's in variables.
*
* @access public
* @return void
*/
public static function create_pages()
{
$pages = apply_filters('woocommerce_gzd_create_pages', array('data_security' => array('name' => _x('data-security', 'Page slug', 'woocommerce-germanized'), 'title' => _x('Data Security Statement', 'Page title', 'woocommerce-germanized'), 'content' => ''), 'imprint' => array('name' => _x('imprint', 'Page slug', 'woocommerce-germanized'), 'title' => _x('Imprint', 'Page title', 'woocommerce-germanized'), 'content' => ''), 'terms' => array('name' => _x('terms', 'Page slug', 'woocommerce-germanized'), 'title' => _x('Terms & Conditions', 'Page title', 'woocommerce-germanized'), 'content' => ''), 'revocation' => array('name' => _x('revocation', 'Page slug', 'woocommerce-germanized'), 'title' => _x('Power of Revocation', 'Page title', 'woocommerce-germanized'), 'content' => ''), 'shipping_costs' => array('name' => _x('shipping-methods', 'Page slug', 'woocommerce-germanized'), 'title' => _x('Shipping Methods', 'Page title', 'woocommerce-germanized'), 'content' => ''), 'payment_methods' => array('name' => _x('payment-methods', 'Page slug', 'woocommerce-germanized'), 'title' => _x('Payment Methods', 'Page title', 'woocommerce-germanized'), 'content' => '[' . apply_filters('woocommerce_gzd_payment_methods_shortcode_tag', 'payment_methods_info') . ']')));
foreach ($pages as $key => $page) {
wc_create_page(esc_sql($page['name']), 'woocommerce_' . $key . '_page_id', $page['title'], $page['content'], !empty($page['parent']) ? wc_get_page_id($page['parent']) : '');
}
}
示例13: create_plugins_page
public static function create_plugins_page()
{
$become_a_vendor_page = get_option('yith_wpv_become_a_vendor_page_id');
if ($become_a_vendor_page === false) {
/* wc_create_page( $slug, $option, $page_title, $page_content, $post_parent ) */
$page_id = wc_create_page('become-a-vendor', 'yith_wpv_become_a_vendor_page_id', __('Become a vendor', 'yith_wc_product_vendors'), '[yith_wcmv_become_a_vendor]', 0);
}
$terms_and_conditions_page = get_option('yith_wpv_terms_and_conditions_page_id');
if ($terms_and_conditions_page === false) {
/* wc_create_page( $slug, $option, $page_title, $page_content, $post_parent ) */
$page_id = wc_create_page('Vendors Terms and conditions', 'yith_wpv_terms_and_conditions_page_id', __('Terms and Conditions for Vendors', 'yith_wc_product_vendors'), '', 0);
}
}