0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | if(!function_exists('jma_yt_detect_shortcode')){ function jma_yt_detect_shortcode( $needle = '', $post_item = 0 ){ if($post_item){ if(is_object($post_item)) $post = $post_item; else $post = get_post($post_item); }else{ global $post; } if(is_array($needle)) $pattern = get_shortcode_regex($needle); elseif(is_string($needle)) $pattern = get_shortcode_regex(array($needle)); else $pattern = get_shortcode_regex(); preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ); if(//if shortcode(s) to be searched for were passed and not found $return false array_key_exists( 2, $matches ) && count( $matches[2] ) ){ $return = $matches; }else{ $return = false; } return $return; } } |