wc_post_content_has_shortcode

Checks whether the content passed contains a specific short code.

Description

wc_post_content_has_shortcode( (string) $tag = '' ); 

Parameters (1)

0. $tag — Optional. (string) => ''
Shortcode tag to check.

Usage

  1. if ( !function_exists( 'wc_post_content_has_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-conditional-functions.php'; 
  3.  
  4. // Shortcode tag to check. 
  5. $tag = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_post_content_has_shortcode($tag); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-conditional-functions.php  
  1. function wc_post_content_has_shortcode( $tag = '' ) { 
  2. global $post; 
  3.  
  4. return is_singular() && is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, $tag );