_upload_dir = $wp_upload_dir['basedir'] . DSEP; $this->_cache_dir = $wp_upload_dir['basedir'] . DSEP . 'luxe-blogcard' . DSEP; $this->_cache_url = $wp_upload_dir['baseurl'] . '/luxe-blogcard/'; /* foreach( (array)glob( $this->_cache_dir . '*' ) as $val ) { if( is_file( $val ) === true ) { $wp_filesystem->delete( $val ); } } */ } // 投稿の書き換え public function thk_replace_blogcard( $content ) { global $luxe; // URL 直書きをブログカード化する場合の処理 if( isset( $luxe['blogcard_embedded'] ) ) { // 相手サイトが Embed 対応 if( stripos( $content, 'blockquote' ) !== false && stripos( $content, 'wp-embedded-content' ) !== false ) { preg_match_all( '/
' . $replace . '
'; // 置換 $content = str_replace( $val, $replace, $content ); } } } unset( $m ); // アイフレーム消す $content = preg_replace('/<(amp\-)*i'.'frame.+?wp-embedded-content.+?<\/(amp\-)*i'.'frame>/ism', '', $content ); } // 相手サイトが Embed 非対応 preg_match_all( '/^()?(\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|])?(
)?(<\/p>)?\n/im', $content, $m );
if( isset( $m[0] ) && isset( $m[2] ) ) {
foreach( $m[0] as $key => $val ) {
if( !empty( $m[2][$key] ) ) {
$content = str_replace( $val, '