[wp-trac] [WordPress Trac] #34566: no_texturize_shortcodes filter does not catch all situations

WordPress Trac noreply at wordpress.org
Tue Nov 3 11:19:33 UTC 2015


#34566: no_texturize_shortcodes filter does not catch all situations
--------------------------+-----------------------------
 Reporter:  codex-m       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Formatting    |    Version:  4.3.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 {{{#!php
 <?php
 $shortcode_regex='\[[\/\[]?(?:embed|wp_caption|caption|gallery|playlist|audio|video|wpv\-wooaddcart|wpv\-wooaddcartbox|wpv\-wooremovecart|wpv\-woo\-carturl|wpv\-woo\-breadcrumb|wpv\-woo\-show\-upsell\-items|wpv\-woo\-productcategory\-images|wpv\-woo\-products\-rating\-listing|wpv\-woo\-single\-products\-rating|wpv\-woo\-related_products|wpv\-woo\-list_attributes|wpv\-woo\-buy\-or\-select|wpv\-woo\-product\-price|wpv\-woo\-product\-image|wpv\-woo\-buy\-options|wpv\-add\-to\-cart\-message|wpv\-woo\-display\-tabs|wpv\-woo\-onsale|wpv\-woo\-product\-meta|wpv\-woo\-cart\-count|wpv\-woo\-reviews|wpv\-post\-title|wpv\-post\-link|wpv\-post\-url|wpv\-post\-body|wpv\-post\-excerpt|wpv\-post\-date|wpv\-post\-author|wpv\-post\-featured\-image|wpv\-post\-id|wpv\-post\-slug|wpv\-post\-type|wpv\-post\-format|wpv\-post\-status|wpv\-post\-comments\-number|wpv\-post\-class|wpv\-post\-edit\-link|wpv\-post\-field|wpv\-for\-each|wpv\-comment\-title|wpv\-comment\-body|wpv\-comment\-author|wpv\-comment\-d
 ate|wpv\-taxonomy\-title|wpv\-taxonomy\-link|wpv\-taxonomy\-url|wpv\-taxonomy\-slug|wpv\-taxonomy\-id|wpv\-taxonomy\-description|wpv\-taxonomy\-post\-count|wpv\-taxonomy\-archive|wpv\-bloginfo|wpv\-search\-term|wpv\-archive\-title|wpv\-archive\-link|wpv\-current\-user|wpv\-user|wpv\-login\-form|wpv\-post\-taxonomy|wpv\-filter\-order|wpv\-filter\-types\-select|wpv\-filter\-search\-box|wpml\-lang\-switcher|wpml\-lang\-footer|wpml\-sidebar|yoast\-breadcrumbs|wpv\-attribute|wpv\-filter\-meta\-html|wpv\-heading|wpv\-layout\-start|wpv\-layout\-end|wpv\-layout\-row|wpv\-layout\-meta\-html|wpv\-no\-taxonomy\-found|wpv\-orderby|wpv\-order|wpv\-filter\-start|wpv\-filter\-end|wpv\-filter\-submit|wpv\-post\-count|wpv\-items\-count|wpv\-found\-count|wpv\-posts\-found|wpv\-no\-posts\-found|wpv\-items\-found|wpv\-no\-items\-found|wpv\-control|wpv\-control\-set|wpv\-control\-item|wpv\-filter\-controls|wpv\-filter\-spinner|wpv\-filter\-reset|wpv\-pager\-current\-page|wpv\-archive\-pager\-prev\-page|
 wpv\-archive\-pager\-next\-page|wpv\-if|types|product|product_page|product_category|product_categories|add_to_cart|add_to_cart_url|products|recent_products|sale_products|best_selling_products|top_rated_products|featured_products|product_attribute|related_products|shop_messages|woocommerce_order_tracking|woocommerce_cart|woocommerce_checkout|woocommerce_my_account|woocommerce_messages|wpv\-conditional|wpv\-noautop|wpv\-autop|wpv\-pagination|wpv\-pager\-num\-page|wpv\-pager\-total\-pages|wpv\-pager\-prev\-page|wpv\-pager\-next\-page|wpv\-pager\-nav\-dropdown|wpv\-pager\-nav\-links|wpv\-theme\-option|wpv\-view|wpv\-form\-view|wpml\-string)(?![\w-])(?:[^\[\]<>]+|<[^\[\]>]*>)*+\]\]?';

 $curl='[wpv-woo-buy-or-select add_to_cart_text="test"
 link_to_product_text="read more >>" show_quantity_in_button="no"
 show_variation_options="no"]';

 $x=preg_match( '/^' . $shortcode_regex . '$/', $curl );
 print_r($x);

 }}}

 Discussion: I have excluded wpv-woo-buy-or-select from processing using
 no_texturize_shortcodes filter found in includes/formatting.php
 reference:
 https://codex.wordpress.org/Plugin_API/Filter_Reference/no_texturize_shortcodes

 Issue: If the shortcode has an attribute value with pointy brackets,
 wptexturize is still applied. Example

 link_to_product_text="read more >>"

 The print_r($x) above results to '0' instead of 1. I'm expecting it to be
 1 so it can be detected as shortcode and then excluded.

 Take note that if I removed the pointy brackets like this:

 link_to_product_text="read more >>"

 1 is returned so it is detecting as shortcode.

 Thanks.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34566>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list