Filters for shortcode tags
This commit is contained in:
parent
1b1332d278
commit
8ce3b8dd57
|
@ -19,7 +19,7 @@
|
|||
|
||||
var a=this;d.onRenderMenu.add(function(c,b){
|
||||
|
||||
a.addImmediate(b, ed.getLang('woocommerce.order_tracking'),"[woocommerce_order_tracking]" );
|
||||
a.addImmediate(b, ed.getLang('woocommerce.order_tracking'), '[' + ed.getLang('woocommerce.order_tracking_shortcode') + ']' );
|
||||
a.addImmediate(b, ed.getLang('woocommerce.price_button'), '[add_to_cart id="" sku=""]');
|
||||
a.addImmediate(b, ed.getLang('woocommerce.product_by_sku'), '[product id="" sku=""]');
|
||||
a.addImmediate(b, ed.getLang('woocommerce.products_by_sku'), '[products ids="" skus=""]');
|
||||
|
@ -33,15 +33,7 @@
|
|||
|
||||
b.addSeparator();
|
||||
|
||||
a.addImmediate(b, ed.getLang('woocommerce.shop_messages'), '[woocommerce_messages]');
|
||||
|
||||
b.addSeparator();
|
||||
|
||||
c=b.addMenu({title:ed.getLang('woocommerce.pages')});
|
||||
a.addImmediate(c, ed.getLang('woocommerce.cart'),"[woocommerce_cart]" );
|
||||
a.addImmediate(c, ed.getLang('woocommerce.checkout'),"[woocommerce_checkout]" );
|
||||
a.addImmediate(c, ed.getLang('woocommerce.my_account'),"[woocommerce_my_account]" );
|
||||
|
||||
a.addImmediate(b, ed.getLang('woocommerce.shop_messages'), '[' + ed.getLang('woocommerce.shop_messages_shortcode') + ']');
|
||||
});
|
||||
return d
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
(function(){tinymce.create("tinymce.plugins.WooCommerceShortcodes",{init:function(e,t){},createControl:function(e,t){var n=tinymce.activeEditor;if(e=="woocommerce_shortcodes_button"){e=t.createMenuButton("woocommerce_shortcodes_button",{title:n.getLang("woocommerce.insert"),icons:!1});var r=this;e.onRenderMenu.add(function(e,t){r.addImmediate(t,n.getLang("woocommerce.order_tracking"),"[woocommerce_order_tracking]");r.addImmediate(t,n.getLang("woocommerce.price_button"),'[add_to_cart id="" sku=""]');r.addImmediate(t,n.getLang("woocommerce.product_by_sku"),'[product id="" sku=""]');r.addImmediate(t,n.getLang("woocommerce.products_by_sku"),'[products ids="" skus=""]');r.addImmediate(t,n.getLang("woocommerce.product_categories"),'[product_categories number=""]');r.addImmediate(t,n.getLang("woocommerce.products_by_cat_slug"),'[product_category category="" per_page="12" columns="4" orderby="date" order="desc"]');t.addSeparator();r.addImmediate(t,n.getLang("woocommerce.recent_products"),'[recent_products per_page="12" columns="4" orderby="date" order="desc"]');r.addImmediate(t,n.getLang("woocommerce.featured_products"),'[featured_products per_page="12" columns="4" orderby="date" order="desc"]');t.addSeparator();r.addImmediate(t,n.getLang("woocommerce.shop_messages"),"[woocommerce_messages]");t.addSeparator();e=t.addMenu({title:n.getLang("woocommerce.pages")});r.addImmediate(e,n.getLang("woocommerce.cart"),"[woocommerce_cart]");r.addImmediate(e,n.getLang("woocommerce.checkout"),"[woocommerce_checkout]");r.addImmediate(e,n.getLang("woocommerce.my_account"),"[woocommerce_my_account]")});return e}return null},addImmediate:function(e,t,n){e.add({title:t,onclick:function(){tinyMCE.activeEditor.execCommand("mceInsertContent",!1,n)}})}});tinymce.PluginManager.add("WooCommerceShortcodes",tinymce.plugins.WooCommerceShortcodes)})();
|
||||
(function(){tinymce.create("tinymce.plugins.WooCommerceShortcodes",{init:function(e,t){},createControl:function(e,t){var n=tinymce.activeEditor;if(e=="woocommerce_shortcodes_button"){e=t.createMenuButton("woocommerce_shortcodes_button",{title:n.getLang("woocommerce.insert"),icons:!1});var r=this;e.onRenderMenu.add(function(e,t){r.addImmediate(t,n.getLang("woocommerce.order_tracking"),"["+n.getLang("woocommerce.order_tracking_shortcode")+"]");r.addImmediate(t,n.getLang("woocommerce.price_button"),'[add_to_cart id="" sku=""]');r.addImmediate(t,n.getLang("woocommerce.product_by_sku"),'[product id="" sku=""]');r.addImmediate(t,n.getLang("woocommerce.products_by_sku"),'[products ids="" skus=""]');r.addImmediate(t,n.getLang("woocommerce.product_categories"),'[product_categories number=""]');r.addImmediate(t,n.getLang("woocommerce.products_by_cat_slug"),'[product_category category="" per_page="12" columns="4" orderby="date" order="desc"]');t.addSeparator();r.addImmediate(t,n.getLang("woocommerce.recent_products"),'[recent_products per_page="12" columns="4" orderby="date" order="desc"]');r.addImmediate(t,n.getLang("woocommerce.featured_products"),'[featured_products per_page="12" columns="4" orderby="date" order="desc"]');t.addSeparator();r.addImmediate(t,n.getLang("woocommerce.shop_messages"),"["+n.getLang("woocommerce.shop_messages_shortcode")+"]")});return e}return null},addImmediate:function(e,t,n){e.add({title:t,onclick:function(){tinyMCE.activeEditor.execCommand("mceInsertContent",!1,n)}})}});tinymce.PluginManager.add("WooCommerceShortcodes",tinymce.plugins.WooCommerceShortcodes)})();
|
|
@ -11,11 +11,9 @@ $strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{
|
|||
recent_products: "' . esc_js( __( 'Recent products', 'woocommerce' ) ) . '",
|
||||
featured_products: "' . esc_js( __( 'Featured products', 'woocommerce' ) ) . '",
|
||||
shop_messages: "' . esc_js( __( 'Shop Messages', 'woocommerce' ) ) . '",
|
||||
pages: "' . esc_js( __( 'Pages', 'woocommerce' ) ) . '",
|
||||
cart: "' . esc_js( __( 'Cart', 'woocommerce' ) ) . '",
|
||||
checkout: "' . esc_js( __( 'Checkout', 'woocommerce' ) ) . '",
|
||||
order_tracking: "' . esc_js( __( 'Order tracking', 'woocommerce' ) ) . '",
|
||||
my_account: "' . esc_js( __( 'My Account', 'woocommerce' ) ) . '",
|
||||
edit_address: "' . esc_js( __( 'Edit Address', 'woocommerce' ) ) . '",
|
||||
shop_messages_shortcode: "' . esc_js( apply_filters( "shop_messages_shortcode_tag", 'woocommerce_shop_messages' ) ) . '",
|
||||
order_tracking_shortcode: "' . esc_js( apply_filters( "woocommerce_order_tracking_shortcode_tag", 'woocommerce_order_tracking' ) ) . '"
|
||||
}
|
||||
}})';
|
|
@ -42,7 +42,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
|||
|
||||
array(
|
||||
'title' => __( 'My Account Page', 'woocommerce' ),
|
||||
'desc' => __( 'Page contents: [woocommerce_my_account]', 'woocommerce' ),
|
||||
'desc' => __( 'Page contents:', 'woocommerce' ) . ' [' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']',
|
||||
'id' => 'woocommerce_myaccount_page_id',
|
||||
'type' => 'single_select_page',
|
||||
'default' => '',
|
||||
|
|
|
@ -110,7 +110,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
|||
|
||||
array(
|
||||
'title' => __( 'Cart Page', 'woocommerce' ),
|
||||
'desc' => __( 'Page contents: [woocommerce_cart]', 'woocommerce' ),
|
||||
'desc' => __( 'Page contents:', 'woocommerce' ) . ' [' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']',
|
||||
'id' => 'woocommerce_cart_page_id',
|
||||
'type' => 'single_select_page',
|
||||
'default' => '',
|
||||
|
@ -121,7 +121,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
|||
|
||||
array(
|
||||
'title' => __( 'Checkout Page', 'woocommerce' ),
|
||||
'desc' => __( 'Page contents: [woocommerce_checkout]', 'woocommerce' ),
|
||||
'desc' => __( 'Page contents:', 'woocommerce' ) . ' [' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']',
|
||||
'id' => 'woocommerce_checkout_page_id',
|
||||
'type' => 'single_select_page',
|
||||
'default' => '',
|
||||
|
|
|
@ -287,15 +287,15 @@
|
|||
),
|
||||
__( 'Cart', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_cart_page_id',
|
||||
'shortcode' => '[woocommerce_cart]'
|
||||
'shortcode' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']'
|
||||
),
|
||||
__( 'Checkout', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_checkout_page_id',
|
||||
'shortcode' => '[woocommerce_checkout]'
|
||||
'shortcode' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']'
|
||||
),
|
||||
__( 'My Account', 'woocommerce' ) => array(
|
||||
'option' => 'woocommerce_myaccount_page_id',
|
||||
'shortcode' => '[woocommerce_my_account]'
|
||||
'shortcode' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']'
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -213,17 +213,17 @@ class WC_Install {
|
|||
'cart' => array(
|
||||
'name' => _x( 'cart', 'page_slug', 'woocommerce' ),
|
||||
'title' => __( 'Cart', 'woocommerce' ),
|
||||
'content' => '[woocommerce_cart]'
|
||||
'content' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']'
|
||||
),
|
||||
'checkout' => array(
|
||||
'name' => _x( 'checkout', 'page_slug', 'woocommerce' ),
|
||||
'title' => __( 'Checkout', 'woocommerce' ),
|
||||
'content' => '[woocommerce_checkout]'
|
||||
'content' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']'
|
||||
),
|
||||
'myaccount' => array(
|
||||
'name' => _x( 'my-account', 'page_slug', 'woocommerce' ),
|
||||
'title' => __( 'My Account', 'woocommerce' ),
|
||||
'content' => '[woocommerce_my_account]'
|
||||
'content' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']'
|
||||
)
|
||||
) );
|
||||
|
||||
|
|
|
@ -14,25 +14,34 @@ class WC_Shortcodes {
|
|||
* Init shortcodes
|
||||
*/
|
||||
public function init() {
|
||||
add_shortcode( 'product', __CLASS__ . '::product' );
|
||||
add_shortcode( 'product_page', __CLASS__ . '::product_page_shortcode' );
|
||||
add_shortcode( 'product_category', __CLASS__ . '::product_category' );
|
||||
add_shortcode( 'product_categories', __CLASS__ . '::product_categories' );
|
||||
add_shortcode( 'add_to_cart', __CLASS__ . '::product_add_to_cart' );
|
||||
add_shortcode( 'add_to_cart_url', __CLASS__ . '::product_add_to_cart_url' );
|
||||
add_shortcode( 'products', __CLASS__ . '::products' );
|
||||
add_shortcode( 'recent_products', __CLASS__ . '::recent_products' );
|
||||
add_shortcode( 'sale_products', __CLASS__ . '::sale_products' );
|
||||
add_shortcode( 'best_selling_products', __CLASS__ . '::best_selling_products' );
|
||||
add_shortcode( 'top_rated_products', __CLASS__ . '::top_rated_products' );
|
||||
add_shortcode( 'featured_products', __CLASS__ . '::featured_products' );
|
||||
add_shortcode( 'product_attribute', __CLASS__ . '::product_attribute' );
|
||||
add_shortcode( 'related_products', __CLASS__ . '::related_products_shortcode' );
|
||||
add_shortcode( 'woocommerce_messages', __CLASS__ . '::messages_shortcode' );
|
||||
add_shortcode( 'woocommerce_cart', __CLASS__ . '::cart' );
|
||||
add_shortcode( 'woocommerce_checkout', __CLASS__ . '::checkout' );
|
||||
add_shortcode( 'woocommerce_order_tracking', __CLASS__ . '::order_tracking' );
|
||||
add_shortcode( 'woocommerce_my_account', __CLASS__ . '::my_account' );
|
||||
// Define shortcodes
|
||||
$shortcodes = array(
|
||||
'product' => __CLASS__ . '::product',
|
||||
'product_page' => __CLASS__ . '::product_page',
|
||||
'product_category' => __CLASS__ . '::product_category',
|
||||
'product_categories' => __CLASS__ . '::product_categories',
|
||||
'add_to_cart' => __CLASS__ . '::product_add_to_cart',
|
||||
'add_to_cart_url' => __CLASS__ . '::product_add_to_cart_url',
|
||||
'products' => __CLASS__ . '::products',
|
||||
'recent_products' => __CLASS__ . '::recent_products',
|
||||
'sale_products' => __CLASS__ . '::sale_products',
|
||||
'best_selling_products' => __CLASS__ . '::best_selling_products',
|
||||
'top_rated_products' => __CLASS__ . '::top_rated_products',
|
||||
'featured_products' => __CLASS__ . '::featured_products',
|
||||
'product_attribute' => __CLASS__ . '::product_attribute',
|
||||
'related_products' => __CLASS__ . '::related_products',
|
||||
'shop_messages' => __CLASS__ . '::shop_messages',
|
||||
'woocommerce_order_tracking' => __CLASS__ . '::order_tracking',
|
||||
'woocommerce_cart' => __CLASS__ . '::cart',
|
||||
'woocommerce_checkout' => __CLASS__ . '::checkout',
|
||||
'woocommerce_my_account' => __CLASS__ . '::my_account',
|
||||
);
|
||||
|
||||
foreach ( $shortcodes as $shortcode => $function )
|
||||
add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function );
|
||||
|
||||
// Alias for pre 2.1 compatibility
|
||||
add_shortcode( 'woocommerce_messages', __CLASS__ . '::shop_messages' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -772,7 +781,7 @@ class WC_Shortcodes {
|
|||
* @param array $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function product_page_shortcode( $atts ) {
|
||||
public static function product_page( $atts ) {
|
||||
if ( empty( $atts ) ) return;
|
||||
|
||||
if ( ! isset( $atts['id'] ) && ! isset( $atts['sku'] ) ) return;
|
||||
|
@ -824,7 +833,7 @@ class WC_Shortcodes {
|
|||
* @param array $atts
|
||||
* @return string
|
||||
*/
|
||||
public static function messages_shortcode() {
|
||||
public static function shop_messages() {
|
||||
ob_start();
|
||||
|
||||
wc_print_messages();
|
||||
|
@ -927,7 +936,7 @@ class WC_Shortcodes {
|
|||
return '<div class="woocommerce">' . ob_get_clean() . '</div>';
|
||||
}
|
||||
|
||||
public static function related_products_shortcode( $atts ) {
|
||||
public static function related_products( $atts ) {
|
||||
|
||||
$atts = shortcode_atts( array(
|
||||
'posts_per_page' => '2',
|
||||
|
|
Loading…
Reference in New Issue