post_content ) ) $contents .= $post->post_content; if( isset( $widget_concat ) ) $contents .= $widget_concat; foreach( (array)$sc_mods as $key => $val ) { // 投稿内に該当するショートコードが書かれてなければショートコードそのものを登録しない //if( strpos( $post->post_content, '[' . $key ) !== false ) { if( strpos( $contents, '[' . $key ) !== false ) { // functions.php 等ですでに同名のショートコードが登録済みの場合も登録しない if( shortcode_exists( $key ) === false ) { $json = array( 'label' => '', 'php' => false, 'close' => false, 'hide' => false, 'active' => false ); $json = wp_parse_args( @json_decode( $val ), $json ); if( $json['active'] !== false && $json['hide'] === false ) { if( file_exists( SPATH . DSEP . 'shortcodes' . DSEP . $key . '.inc' ) ) { require( SPATH . DSEP . 'shortcodes' . DSEP . $key . '.inc' ); } } // ショートコード非表示設定の時 if( $json['hide'] !== false ) { add_filter( 'the_content', function( $content = null ) use( $key, $val ) { $content = preg_replace( '/\[' . $key . '[^\]]*?\].+?\[\/' . $key . '\]/ism', '', $content ); $content = preg_replace( '/\[' . $key . '[^\]]*?\]/im', '', $content ); return $content; }, 9 ); } } } } unset( $contents ); }