get_endpoint() public static method

Get WC Ajax Endpoint.
public static get_endpoint ( string $request = '' ) : string
$request string Optional
return string
 /**
  * Front end styles and scripts.
  *
  * @return void
  */
 public static function frontend_scripts()
 {
     wp_register_style('wcsatt-css', WCS_ATT()->plugin_url() . '/assets/css/wcsatt-frontend.css', false, WCS_ATT::VERSION, 'all');
     wp_enqueue_style('wcsatt-css');
     if (is_cart()) {
         wp_register_script('wcsatt-cart', WCS_ATT()->plugin_url() . '/assets/js/wcsatt-cart.js', array('jquery', 'wc-country-select', 'wc-address-i18n'), WCS_ATT::VERSION, true);
     }
     wp_enqueue_script('wcsatt-cart');
     $params = array('update_cart_option_nonce' => wp_create_nonce('wcsatt_update_cart_option'), 'wc_ajax_url' => WCS_ATT_Core_Compatibility::is_wc_version_gte_2_4() ? WC_AJAX::get_endpoint("%%endpoint%%") : WC()->ajax_url());
     wp_localize_script('wcsatt-cart', 'wcsatt_cart_params', $params);
 }
コード例 #2
0
 /**
  * Return data for script handles.
  * @access private
  * @param  string $handle
  * @return array|bool
  */
 private static function get_script_data($handle)
 {
     global $wp;
     switch ($handle) {
         case 'woocommerce':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"));
             break;
         case 'wc-geolocation':
             return array('wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'home_url' => home_url(), 'is_cart' => is_cart() ? '1' : '0', 'is_account_page' => is_account_page() ? '1' : '0', 'is_checkout' => is_checkout() ? '1' : '0', 'hash' => isset($_GET['v']) ? wc_clean($_GET['v']) : '');
             break;
         case 'wc-single-product':
             return array('i18n_required_rating_text' => esc_attr__('Please select a rating', 'woocommerce'), 'review_rating_required' => get_option('woocommerce_review_rating_required'));
             break;
         case 'wc-checkout':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'update_order_review_nonce' => wp_create_nonce('update-order-review'), 'apply_coupon_nonce' => wp_create_nonce('apply-coupon'), 'remove_coupon_nonce' => wp_create_nonce('remove-coupon'), 'option_guest_checkout' => get_option('woocommerce_enable_guest_checkout'), 'checkout_url' => WC_AJAX::get_endpoint("checkout"), 'is_checkout' => is_page(wc_get_page_id('checkout')) && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received']) ? 1 : 0, 'debug_mode' => defined('WP_DEBUG') && WP_DEBUG, 'i18n_checkout_error' => esc_attr__('Error processing checkout. Please try again.', 'woocommerce'));
             break;
         case 'wc-address-i18n':
             return array('locale' => json_encode(WC()->countries->get_country_locale()), 'locale_fields' => json_encode(WC()->countries->get_country_locale_field_selectors()), 'i18n_required_text' => esc_attr__('required', 'woocommerce'));
             break;
         case 'wc-cart':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'update_shipping_method_nonce' => wp_create_nonce("update-shipping-method"));
             break;
         case 'wc-cart-fragments':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'fragment_name' => apply_filters('woocommerce_cart_fragment_name', 'wc_fragments'));
             break;
         case 'wc-add-to-cart':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'i18n_view_cart' => esc_attr__('View Cart', 'woocommerce'), 'cart_url' => apply_filters('woocommerce_add_to_cart_redirect', WC()->cart->get_cart_url()), 'is_cart' => is_cart(), 'cart_redirect_after_add' => get_option('woocommerce_cart_redirect_after_add'));
             break;
         case 'wc-add-to-cart-variation':
             return array('i18n_no_matching_variations_text' => esc_attr__('Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce'), 'i18n_unavailable_text' => esc_attr__('Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce'));
             break;
         case 'wc-country-select':
             return array('countries' => json_encode(array_merge(WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states())), 'i18n_select_state_text' => esc_attr__('Select an option…', 'woocommerce'), 'i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching…', 'enhanced select', 'woocommerce'));
             break;
     }
     return false;
 }
コード例 #3
0
 /**
  * Enqueue the scripts and styles in the page
  */
 public function enqueue_scripts()
 {
     // scripts
     $min = !(defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '.min' : '';
     wp_register_script('yith-woocompare-main', YITH_WOOCOMPARE_ASSETS_URL . '/js/woocompare' . $min . '.js', array('jquery'), $this->version, true);
     // enqueue and add localize
     wp_enqueue_script('yith-woocompare-main');
     wp_localize_script('yith-woocompare-main', 'yith_woocompare', array('ajaxurl' => version_compare(WC()->version, '2.4', '>=') ? WC_AJAX::get_endpoint("%%endpoint%%") : admin_url('admin-ajax.php', 'relative'), 'actionadd' => $this->action_add, 'actionremove' => $this->action_remove, 'actionview' => $this->action_view, 'added_label' => apply_filters('yith_woocompare_compare_added_label', __('Added', 'yith-woocommerce-compare')), 'table_title' => apply_filters('yith_woocompare_compare_table_title', __('Product Comparison', 'yith-woocommerce-compare')), 'auto_open' => get_option('yith_woocompare_auto_open', 'yes'), 'loader' => YITH_WOOCOMPARE_ASSETS_URL . '/images/loader.gif', 'button_text' => get_option('yith_woocompare_button_text')));
     // colorbox
     wp_enqueue_style('jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/css/colorbox.css');
     wp_enqueue_script('jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/js/jquery.colorbox-min.js', array('jquery'), '1.4.21', true);
     // widget
     if (is_active_widget(false, false, 'yith-woocompare-widget', true) && !is_admin()) {
         wp_enqueue_style('yith-woocompare-widget', YITH_WOOCOMPARE_ASSETS_URL . '/css/widget.css');
     }
 }
コード例 #4
0
 /**
  * Enqueue the scripts and styles in the page
  */
 public function enqueue_scripts()
 {
     // scripts
     wp_enqueue_script('yith-woocompare-main', YITH_WOOCOMPARE_ASSETS_URL . '/js/woocompare.js', array('jquery'), $this->version, true);
     wp_localize_script('yith-woocompare-main', 'yith_woocompare', array('ajaxurl' => WC_AJAX::get_endpoint("%%endpoint%%"), 'actionadd' => $this->action_add, 'actionremove' => $this->action_remove, 'actionview' => $this->action_view, 'added_label' => __('Added', 'yith-woocommerce-compare'), 'table_title' => __('Product Comparison', 'yith-woocommerce-compare'), 'auto_open' => get_option('yith_woocompare_auto_open', 'yes'), 'loader' => YITH_WOOCOMPARE_ASSETS_URL . '/images/loader.gif', 'button_text' => get_option('yith_woocompare_button_text')));
     // colorbox
     wp_enqueue_style('jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/css/colorbox.css');
     wp_enqueue_script('jquery-colorbox', YITH_WOOCOMPARE_ASSETS_URL . '/js/jquery.colorbox-min.js', array('jquery'), '1.4.21', true);
     // widget
     if (is_active_widget(false, false, 'yith-woocompare-widget', true) && !is_admin()) {
         wp_enqueue_style('yith-woocompare-widget', YITH_WOOCOMPARE_ASSETS_URL . '/css/widget.css');
     }
 }
コード例 #5
0
 /**
  * Return data for script handles.
  * @access private
  * @param  string $handle
  * @return array|bool
  */
 private static function get_script_data($handle)
 {
     global $wp;
     switch ($handle) {
         case 'woocommerce':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"));
             break;
         case 'wc-geolocation':
             return array('wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'home_url' => home_url(), 'is_available' => !(is_cart() || is_account_page() || is_checkout() || is_customize_preview()) ? '1' : '0', 'hash' => isset($_GET['version']) ? wc_clean($_GET['version']) : '');
             break;
         case 'wc-single-product':
             return array('i18n_required_rating_text' => esc_attr__('Please select a rating', 'woocommerce'), 'review_rating_required' => get_option('woocommerce_review_rating_required'), 'flexslider' => apply_filters('woocommerce_single_product_carousel_options', array('rtl' => is_rtl(), 'animation' => 'slide', 'smoothHeight' => true, 'directionNav' => false, 'controlNav' => 'thumbnails', 'slideshow' => false, 'animationSpeed' => 500)));
             break;
         case 'wc-checkout':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'update_order_review_nonce' => wp_create_nonce('update-order-review'), 'apply_coupon_nonce' => wp_create_nonce('apply-coupon'), 'remove_coupon_nonce' => wp_create_nonce('remove-coupon'), 'option_guest_checkout' => get_option('woocommerce_enable_guest_checkout'), 'checkout_url' => WC_AJAX::get_endpoint("checkout"), 'is_checkout' => is_page(wc_get_page_id('checkout')) && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received']) ? 1 : 0, 'debug_mode' => defined('WP_DEBUG') && WP_DEBUG, 'i18n_checkout_error' => esc_attr__('Error processing checkout. Please try again.', 'woocommerce'));
             break;
         case 'wc-address-i18n':
             return array('locale' => json_encode(WC()->countries->get_country_locale()), 'locale_fields' => json_encode(WC()->countries->get_country_locale_field_selectors()), 'i18n_required_text' => esc_attr__('required', 'woocommerce'));
             break;
         case 'wc-cart':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'update_shipping_method_nonce' => wp_create_nonce("update-shipping-method"), 'apply_coupon_nonce' => wp_create_nonce("apply-coupon"), 'remove_coupon_nonce' => wp_create_nonce("remove-coupon"));
             break;
         case 'wc-cart-fragments':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'fragment_name' => apply_filters('woocommerce_cart_fragment_name', 'wc_fragments'));
             break;
         case 'wc-add-to-cart':
             return array('ajax_url' => WC()->ajax_url(), 'wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'i18n_view_cart' => esc_attr__('View cart', 'woocommerce'), 'cart_url' => apply_filters('woocommerce_add_to_cart_redirect', wc_get_cart_url()), 'is_cart' => is_cart(), 'cart_redirect_after_add' => get_option('woocommerce_cart_redirect_after_add'));
             break;
         case 'wc-add-to-cart-variation':
             // We also need the wp.template for this script :)
             wc_get_template('single-product/add-to-cart/variation.php');
             return array('wc_ajax_url' => WC_AJAX::get_endpoint("%%endpoint%%"), 'i18n_no_matching_variations_text' => esc_attr__('Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce'), 'i18n_make_a_selection_text' => esc_attr__('Please select some product options before adding this product to your cart.', 'woocommerce'), 'i18n_unavailable_text' => esc_attr__('Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce'));
             break;
         case 'wc-country-select':
             return array('countries' => json_encode(array_merge(WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states())), 'i18n_select_state_text' => esc_attr__('Select an option…', 'woocommerce'), 'i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching…', 'enhanced select', 'woocommerce'));
             break;
         case 'wc-password-strength-meter':
             return array('min_password_strength' => apply_filters('woocommerce_min_password_strength', 3), 'i18n_password_error' => esc_attr__('Please enter a stronger password.', 'woocommerce'), 'i18n_password_hint' => esc_attr__('The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).', 'woocommerce'));
             break;
     }
     return false;
 }