post_type == "post" ){ $message = << ※注意:Japaaanで既に公開済みの記事と似通った内容は公開を見送らせていただきます。さらに深堀りした内容、別視点からの内容等でしたら問題ありません。
生成AIツールを用いた記事作成は禁止しております。AIチェッカーにより該当の可能性が見られた場合、確認をお願いすることがございます。予めご了承ください。 EOF; echo $message; } } add_action( 'edit_form_top', org_caution_title_head ); add_filter('wp_calculate_image_srcset_meta', '__return_null'); //Wordpressが読み込むjQueryを読み込ませないように。 //ただし管理画面では読み込む(管理画面の機能が使えなくなるから) add_action('wp_print_scripts','notimport_script',100); function notimport_script() { if (!is_admin()) { wp_deregister_script('jquery'); } } //管理画面にJavascript埋め込み function my_admin_footer_script() { echo ''.PHP_EOL; } add_action('admin_print_footer_scripts', 'my_admin_footer_script'); //Wordpress製のjqueryを読み込まない //ビュー数が取得できなくなっちゃうから、無効に function my_delete_local_jquery() { wp_deregister_script('jquery'); } //add_action( 'wp_enqueue_scripts', 'my_delete_local_jquery' ); /* wp-block-library-cssを消す */ add_action('wp_enqueue_scripts', function() { wp_deregister_style('wp-block-library'); }); //管理画面:投稿一覧の項目削除 function delete_column($columns) { global $current_user; $columns['views'] = '話題ポイント'; unset($columns['comments']); unset($columns['tags']); if( in_array( 'writer', $current_user->roles ) ) { unset($columns['categories']); } return $columns; } add_filter( 'manage_posts_columns', 'delete_column'); //関連記事をランダムで取得 function get_recommend_posts($conf=false){ global $post; $reco_posts = array(); if(! $conf['row']) $conf['row'] = 2; $ids = array(85035,102736,63405,58584,59542,85131,102003,105013); $recos = new WP_Query(array( 'post_type'=> array('post'), 'posts_per_page'=>$conf['row'], 'has_password'=>false, 'post__in'=>$ids, 'orderby'=>'rand' )); if($recos->have_posts()){while ( $recos->have_posts() ) { $recos->the_post(); $thumbnail_id = get_post_meta($post->ID,'_thumbnail_id', true); $thumbnail = wp_get_attachment_image_src( $thumbnail_id , '1280x720' ); $reco_posts[] = array( 'id'=>get_the_ID(), 'title'=>get_the_title(), 'permalink'=>get_the_permalink(), 'thumbnail'=>$thumbnail[0] ); }} wp_reset_postdata(); return $reco_posts; } //ダッシュボードのカラム数変更 function custom_screen_layout_columns( $columns ) { $columns['dashboard'] = 1; return $columns; } //add_filter( 'screen_layout_columns', 'custom_screen_layout_columns' ); //ダッシュボードに独自ウィジェット表示 //add_action('wp_dashboard_setup', 'original_widgets'); function original_widgets() { wp_add_dashboard_widget('point_stat', '人気ポイントランキング(直近2週間の記事)', 'my_dashboard_widget_info'); } function my_dashboard_widget_info() { ?> get_results(" select f1.post_id as post_id, f1.meta_value as view, f2.meta_value as share, f1.meta_value+f2.meta_value as ttl, (f1.meta_value+(f2.meta_value*1.5)) as ttl2, post.post_date as postdate, post_title as title , user.display_name as user_name, user.user_login as user_login from wp_postmeta as f1 left join wp_postmeta as f2 on f1.post_id = f2.post_id left join wp_posts as post on f1.post_id = post.ID left join wp_users as user on post.post_author = user.ID where f1.meta_key='views' and f2.meta_key='scc_share_count_total' AND post.post_status = 'publish' AND post.post_date > '{$week2}' AND post.post_type in('post', 'step') order by ttl desc limit 30 "); $cnt=1; foreach ($results as $value) { ?>
順位 タイトル ポイント
by 0pt
'area', 'field' => 'slug', 'terms' => array($params['area']), 'operator' => 'AND', 'include_children' => false ); } if($params['cat']) { $tax_query[] = array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array($params['cat']), 'operator' => 'AND', 'include_children' => false ); } if($params['type']) { $tax_query[] = array( 'taxonomy' => 'type', 'field' => 'slug', 'terms' => array($params['type']), 'operator' => 'AND', 'include_children' => false ); } if($tax_query) { // // $query->set('tax_query', // array_merge(array( // 'relation' => 'AND' // ),$tax_query) // ); $query->set( 'tax_query', $tax_query ); } //print_r($query); return $query; } } // サイトの基本設定を読み込み global $bconf; $bconf = new WP_Query(array( 'name'=> 'config_basic', 'post_type'=> array('page'), 'posts_per_page'=>1, 'post_status'=>'private' )); $bconf = $bconf->posts[0]; $bconf = get_fields($bconf->ID); // サイトの基本設定を読み込みここまで //管理者編集フォームにスタイルを適用 add_editor_style("editor-style.css"); add_theme_support( 'editor-styles' ); //順序設定を有効に add_post_type_support( 'post', 'page-attributes' ); //画像自動リサイズプラグイン導入&アイキャッチを有効化 add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 800, 9999 ); include_once('include/plugin/filosofo-image/filosofo-custom-image-sizes.php'); // Custom image size plugin //オリジナルショートタグの整形 include_once('include/function-shorttag.php'); //WP本体のギャラリーのCSSをオフ add_filter( 'use_default_gallery_style', '__return_false' ); //絵文字機能のスクリプト読み込み削除 remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); function is_multi() { if(get_query_var('filter_area') OR get_query_var('filter_cat') OR get_query_var('filter_type')) { return true; } else { return false; } } function query_vars_pathinfo($vars){ $vars[] = "filter_area"; $vars[] = "filter_cat"; $vars[] = "filter_type"; return $vars; } add_filter('query_vars','query_vars_pathinfo'); function my_rewrite_rules_array( $rules ) { $new_rules = array( //エリアのみ 'area/([a-z]+)/?$' => 'index.php?filter_area=$matches[1]', 'area/([a-z]+)/page/([0-9]+)/?$' => 'index.php?filter_area=$matches[1]&paged=$matches[2]', //エリアとカテゴリ 'area/([a-z]+)/cat/([a-z]+)/?$' => 'index.php?filter_area=$matches[1]&filter_cat=$matches[2]', 'area/([a-z]+)/cat/([a-z]+)/page/([0-9]+)/?$' => 'index.php?filter_area=$matches[1]&filter_cat=$matches[2]&paged=$matches[3]', //エリアとタイプ 'area/([a-z]+)/type/([a-z]+)/?$' => 'index.php?filter_area=$matches[1]&filter_type=$matches[2]', 'area/([a-z]+)/type/([a-z]+)/page/([0-9]+)/?$' => 'index.php?filter_area=$matches[1]&filter_type=$matches[2]&paged=$matches[3]', //エリアとカテゴリとタイプ 'area/([a-z]+)/cat/([a-z]+)/type/([a-z]+)/?$' => 'index.php?filter_area=$matches[1]&filter_cat=$matches[2]&filter_type=$matches[3]', 'area/([a-z]+)/cat/([a-z]+)/type/([a-z]+)/page/([0-9]+)/?$' => 'index.php?filter_area=$matches[1]&filter_cat=$matches[2]&filter_type=$matches[3]&paged=$matches[4]', //カテゴリとタイプ(カテゴリのみは通常のカテゴリアーカイブを使用) 'cat/([a-z]+)/type/([a-z]+)/?$' => 'index.php?filter_cat=$matches[1]&filter_type=$matches[2]', 'cat/([a-z]+)/type/([a-z]+)/page/([0-9]+)/?$' => 'index.php?filter_cat=$matches[1]&filter_type=$matches[2]&paged=$matches[3]', //タイプのみ 'type/([a-z]+)/?$' => 'index.php?filter_type=$matches[1]', 'type/([a-z]+)/page/([0-9]+)/?$' => 'index.php?filter_type=$matches[1]&paged=$matches[2]', ); return $new_rules + $rules; } add_filter( 'rewrite_rules_array', 'my_rewrite_rules_array' ); global $current_user; get_currentuserinfo(); if(!is_admin() OR ( is_admin() AND ( $current_user->user_level == 10 ) ) ) { //タイプを実装 $args = array( 'label' => 'コラム', 'labels' => array( 'name' => 'コラム', 'search_items' => 'コラムを検索', 'popular_items' => 'よく使われているタイプ', 'all_items' => 'すべてのコラム', 'parent_item' => '親のコラム', 'edit_item' => 'コラムの編集', 'update_item' => '更新', 'add_new_item' => 'コラムを追加', 'new_item_name' => '新しいコラム', ), 'public' => true, 'show_ui' => true, 'hierarchical' => true,//fales→通常投稿のタグのような扱いになります。 'show_tagcloud' => true, 'show_in_rest' => true ); register_taxonomy('special', array('step', 'post'), $args); //タイプを実装 $args = array( 'label' => 'タイプ', 'labels' => array( 'name' => 'タイプ', 'search_items' => 'タイプを検索', 'popular_items' => 'よく使われているタイプ', 'all_items' => 'すべてのタイプ', 'parent_item' => '親のタイプ', 'edit_item' => 'タイプの編集', 'update_item' => '更新', 'add_new_item' => 'タイプを追加', 'new_item_name' => '新しいタイプ', ), 'public' => true, 'show_ui' => true, 'hierarchical' => true,//fales→通常投稿のタグのような扱いになります。 'show_tagcloud' => true, //'show_in_rest' => true ); register_taxonomy('type', array('step', 'post'), $args); //都道府県を実装 $args = array( 'label' => 'エリア', 'labels' => array( 'name' => 'エリア', 'search_items' => 'エリアを検索', 'popular_items' => 'よく使われているエリア', 'all_items' => 'すべてのエリア', 'parent_item' => '親のエリア', 'edit_item' => 'エリアの編集', 'update_item' => '更新', 'add_new_item' => 'エリアを追加', 'new_item_name' => '新しいエリア', ), 'public' => true, 'show_ui' => true, 'hierarchical' => true,//fales→通常投稿のタグのような扱いになります。 'show_tagcloud' => true, 'show_in_rest' => true ); register_taxonomy('area', array('step', 'post'), $args); //都道府県を実装 $args = array( 'label' => 'メインタグ', 'labels' => array( 'name' => 'メインタグ', 'search_items' => 'メインタグを検索', 'popular_items' => 'よく使われているメインタグ', 'all_items' => 'すべてのメインタグ', 'parent_item' => '親のメインタグ', 'edit_item' => 'メインタグの編集', 'update_item' => '更新', 'add_new_item' => 'メインタグを追加', 'new_item_name' => '新しいメインタグ', ), 'public' => true, 'show_ui' => true, 'hierarchical' => true,//fales→通常投稿のタグのような扱いになります。 'show_tagcloud' => true, 'show_in_rest' => true ); register_taxonomy('keyword', array('step', 'post'), $args); } //投稿タイプステップ(まとめ)を有効に add_action( 'init', 'create_step' ); function create_step() { $labels = array( 'name' => _x('ステップ', 'Step General Name', 'gdl_back_office'), 'singular_name' => _x('ステップ', 'Step Singular Name', 'gdl_back_office'), 'add_new' => _x('新規追加', 'Add New Step Name', 'gdl_back_office'), 'add_new_item' => __('新規追加', 'gdl_back_office'), 'edit_item' => __('投稿を編集', 'gdl_back_office'), 'new_item' => __('新しい投稿', 'gdl_back_office'), 'view_item' => __('投稿を表示', 'gdl_back_office'), 'search_items' => __('投稿を検索', 'gdl_back_office'), 'not_found' => __('投稿はありません', 'gdl_back_office'), 'not_found_in_trash' => __('ゴミ箱に投稿はありません', 'gdl_back_office'), 'parent_item_colon' => '' ); $capability_type = 'post_step'; $capabilities = array( 'edit_' . $capability_type, 'edit_' . $capability_type . 's', 'edit_others_' . $capability_type . 's', 'publish_' . $capability_type . 's', 'read_' . $capability_type, 'read_private_' . $capability_type . 's', 'delete_' . $capability_type); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post_step', 'capabilities'=>$capabilities, 'map_meta_cap'=>true, 'hierarchical' => false, 'menu_position' => 5, 'has_archive' => true, 'supports' => array('title','editor','author','thumbnail','excerpt','comments','custom-fields'), 'rewrite' => array('slug' => 'step', 'with_front' => false), 'taxonomies' => array('category','post_tag'), 'exclude_from_search'=>false ); register_post_type( 'step' , $args); } //人気ランキングのHTML表示カスタマイズ function my_custom_popular_post_html( $mostpopular, $instance ){ global $post; global $box; $ranking_no = 0; $list_cnt=0; foreach( $mostpopular as $p ) { $ranking_no++; $list_cnt++; $post = get_post($p->id); setup_postdata($post); $post->ranking = $ranking_no; if($box=='box_d') {get_template_part( 'template', 'list3'); } else{ get_template_part( 'template', 'list1'); } if($list_cnt==6 AND is_mobile() AND ( $box!='box_d' )){ echo '
 
'; } if($list_cnt==6 AND (! is_mobile()) AND ( $box!='box_d' )){ echo '
 
'; } } $ranking_no = 0; } add_filter( 'wpp_custom_html', 'my_custom_popular_post_html', 10, 2 ); //抜粋のHTML変換を無効に remove_filter('the_excerpt', 'wpautop'); //抜粋の表示文字数を変更 function new_excerpt_length( $length ) {return 50;} add_filter( 'excerpt_mblength', 'new_excerpt_length' ); //more の文字列を変更 function new_excerpt_more($more) {return '...';} add_filter('excerpt_more', 'new_excerpt_more'); //ビジュアルエディタのボタンをカスタマイズ function set_tinymce_blockformats( $initArray ) { // default : "p,pre,address,h1,h2,h3,h4,h5,h6" $initArray['theme_advanced_blockformats'] = "h1,h2,p"; return $initArray; } add_filter( 'tiny_mce_before_init', 'set_tinymce_blockformats' ); //投稿フォームのカテゴリの並びを自動並び替えしないように function ps_wp_terms_checklist_args( $args, $post_id ){ if ( $args['checked_ontop'] !== false ){ $args['checked_ontop'] = false; } return $args; } add_filter('wp_terms_checklist_args', 'ps_wp_terms_checklist_args' ,10,2); //ヘッダーのタグを追加・削除 remove_action( 'wp_head','feed_links',2); remove_action( 'wp_head','feed_links_extra',3); remove_action( 'wp_head','rsd_link'); //ヘッダー部分のCSS消去 add_action('wp_print_styles','lm_dequeue_header_styles'); function lm_dequeue_header_styles(){ wp_dequeue_style('yarppWidgetCss'); } //フッター部分のCSS消去 add_action('get_footer','lm_dequeue_footer_styles'); function lm_dequeue_footer_styles(){ wp_dequeue_style('yarppRelatedCss'); } //サムネイルを有効にした場合に呼び出されるCSS消去 add_action('wp_print_styles','lm_dequeue_header_styles1'); function lm_dequeue_header_styles1(){ wp_dequeue_style('yarpp-thumbnails-yarpp-thumbnail'); } add_action('get_footer','lm_dequeue_footer_styles1'); function lm_dequeue_footer_styles1(){ wp_dequeue_style('yarpp-thumbnails-yarpp-thumbnail'); } //モバイル判定 function is_mobile() { $useragents = array( 'iPhone', // iPhone 'iPod', // iPod touch 'Android.*Mobile', // 1.5+ Android Only mobile 'Windows.*Phone', // Windows Phone 'dream', // Pre 1.5 Android 'CUPCAKE', // 1.5+ Android 'blackberry9500', // Storm 'blackberry9530', // Storm 'blackberry9520', // Storm v2 'blackberry9550', // Storm v2 'blackberry9800', // Torch 'webOS', // Palm Pre Experimental 'incognito', // Other iPhone browser 'webmate' // Other iPhone browser ); $pattern = '/'.implode('|', $useragents).'/i'; return preg_match($pattern, $_SERVER['HTTP_USER_AGENT']); } //タブレット判定 function is_tablet(){ $useragents = array( 'iPad' ); $pattern = '/'.implode('|', $useragents).'/i'; return preg_match($pattern, $_SERVER['HTTP_USER_AGENT']); } //RSSにアイキャッチ画像挿入 function do_post_thumbnail_feeds($content) { global $post; if(get_post_type($post->ID)=='step'){ $content = get_post_meta($post->ID, 'summary', true) . $content; } if(has_post_thumbnail($post->ID)) { $thumbnail_id = get_post_meta($post->ID,'_thumbnail_id', true); $thumbnail = wp_get_attachment_image_src( $thumbnail_id , "640x340" ); $content = '
' . $content; } return $content; } add_filter('the_excerpt_rss', 'do_post_thumbnail_feeds'); add_filter('the_content_feed', 'do_post_thumbnail_feeds'); //RSS配信にプレスリリース記事を含めない function rssfilter($query) { if ($query->is_feed AND (get_query_var('feed') != 'feed')) { //feed=feedの場合は、デフォルトのrssということ。 $query->set('cat','-4289'); //4289 はJapaaanPRのカテゴリID } return $query; } add_filter('pre_get_posts','rssfilter'); //RSSにステップ投稿タイプを含める function custom_post_rss_set($query) { if(is_feed()) { $post_type = $query->get( 'post_type' ); if ( empty( $post_type ) ) { $query->set('post_type', Array( 'post', 'step' ) ); } $query->set( 'has_password', false ); return $query; } } add_filter('pre_get_posts', 'custom_post_rss_set'); //記事配信用 オリジナルRSS add_action( 'do_feed_gunosy', 'do_feed_gunosy' ); function do_feed_gunosy() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/gunosy.php'; load_template( $feed_template ); } add_action( 'do_feed_getnews', 'do_feed_getnews' ); function do_feed_getnews() { // die(); add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/getnews.php'; load_template( $feed_template ); } add_action( 'do_feed_dmmnews', 'do_feed_dmmnews' ); function do_feed_dmmnews() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/dmmnews.php'; load_template( $feed_template ); } add_action( 'do_feed_excite', 'do_feed_excite' ); function do_feed_excite() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/excite.php'; load_template( $feed_template ); } add_action( 'do_feed_lineat', 'do_feed_lineat' ); function do_feed_lineat() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/lineat.php'; load_template( $feed_template ); } add_action( 'do_feed_smart', 'do_feed_smart' ); function do_feed_smart() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/smart.php'; load_template( $feed_template ); } /* add_action( 'do_feed_nd', 'do_feed_nd' ); function do_feed_nd() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/nd.php'; load_template( $feed_template ); } */ //add_action( 'do_feed_livedoor', 'do_feed_livedoor' ); function do_feed_livedoor() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/livedoor.php'; load_template( $feed_template ); } add_action( 'do_feed_niconico', 'do_feed_niconico' ); function do_feed_niconico() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/niconico.php'; load_template( $feed_template ); } add_action( 'do_feed_dcm', 'do_feed_dcm' ); function do_feed_dcm() { add_action( 'the_post', 'no_pageing_hook' ); $feed_template = get_template_directory() . '/feeds/dcm.php'; load_template( $feed_template ); } // tiny_mceにスタイルを追加 function my_tiny_mce_before_init( $init_array ) { $init_array['theme_advanced_styles'] = "文字を小さく=small"; return $init_array; } add_filter( 'tiny_mce_before_init', 'my_tiny_mce_before_init' ); //検索対象をstepとpostに。 function my_posts_per_page($query) { if( is_search() ) { $query->set( 'post_type', array('post', 'step') ); } } add_action( 'pre_get_posts', 'my_posts_per_page' ); /* PRE_GET_POSTS */ function customize_main_query ( $query ) { if ( ! is_admin() || $query->is_main_query() ) { //管理画面以外 かつ メインクエリー if ( $query->is_archive() ) { $query->set( 'has_password', false ); } } } add_action( 'pre_get_posts', 'customize_main_query' ); // PRE_GET_POSTSにフック // ユーザー名とか、タグ名・カテゴリ名も検索対象に function custom_search($search, $wp_query) { global $wpdb; //サーチページ以外だったら終了 if (!$wp_query->is_search) return $search; if (!isset($wp_query->query_vars)) return $search; $search_words = explode(' ', isset($wp_query->query_vars['s']) ? $wp_query->query_vars['s'] : ''); if ( count($search_words) > 0 ) { $search = ''; $search .= "AND post_type in ('post', 'step') "; foreach ( $search_words as $word ) { if ( !empty($word) ) { $search_word = $wpdb->escape("%{$word}%"); $search .= " AND ( {$wpdb->posts}.post_title LIKE '{$search_word}' OR {$wpdb->posts}.post_content LIKE '{$search_word}' OR {$wpdb->posts}.post_author IN ( SELECT distinct ID FROM {$wpdb->users} WHERE display_name LIKE '{$search_word}' ) OR {$wpdb->posts}.ID IN ( SELECT distinct r.object_id FROM {$wpdb->term_relationships} AS r INNER JOIN {$wpdb->term_taxonomy} AS tt ON r.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE t.name LIKE '{$search_word}' OR t.slug LIKE '{$search_word}' OR tt.description LIKE '{$search_word}' ) OR {$wpdb->posts}.ID IN ( SELECT distinct post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '{$search_word}' ) ) "; } } } return $search; } add_filter('posts_search','custom_search', 10, 2); //更新時にcard情報を取得して本体にデータ送信 function send_card_info($post_id) { $post = get_post($post_id); $body = $post->post_content; $thumbnail_id = get_post_meta($post_id,'_thumbnail_id', true); $thumbnail = wp_get_attachment_image_src( $thumbnail_id , '1280x720' ); $thumbnail = $thumbnail[0]; if(preg_match_all( "/\[card id=\"?([0-9]+)\"?/", $body, $ids )) { foreach($ids[1] as $card_id) { $data['data'] = array( //トラックバック送信データ 'card_id' => $card_id, 'id' => $post_id, 'url' => 'https://mag.japaaan.com/archives/'.$post_id, 'title' => $post->post_title, 'image' => $thumbnail, ); $headers = array( //'User-Agent: Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)' ); $options = array( 'http' => array( 'method' => 'POST', 'content' => http_build_query($data), 'header' => implode("\r\n", $headers) ) ); $options['ssl']['verify_peer']=false; $options['ssl']['verify_peer_name']=false; $res[$card_id] = file_get_contents('https://www.japaaan.com/connect/add', false, stream_context_create($options)); //print_r($data); } } return $post_id; } add_action( 'publish_post', 'send_card_info', 1 ,6); //管理画面のヘッダーを変更 function admin_favicon() { echo ''; } add_action('admin_head', 'admin_favicon'); //改ページを無効にする関数 function no_pageing_hook( $post ) { global $pages, $multipage, $numpages; $multipage = 0; $content = str_replace("\n\n", '', $post->post_content); $content = str_replace("\n", '', $content); $content = str_replace("\n", '', $content); $pages = array( str_replace('', '', $content) ); $numpages = 1; } //不明... if ( current_user_can('contributor') && !current_user_can('upload_files') ){ add_action('admin_init', 'allow_contributor_uploads'); } function allow_contributor_uploads() { $contributor = get_role('contributor'); $contributor->add_cap('upload_files'); } //ampのデータを修正 function xyz_amp_modify_json_metadata( $metadata, $post ) { $metadata['publisher']['logo'] = array( '@type' => 'ImageObject', 'url' => 'https://mag.japaaan.com/wp-content/themes/kuniyoshi/images/amplogo.png', 'height' => 59, 'width' => 256, ); return $metadata; } add_filter( 'amp_post_template_metadata', 'xyz_amp_modify_json_metadata', 10, 2 ); //adsenseを表示しない記事 function is_deny_adsense($req_id=null) { $deny_adsense[] = '/archives/74950'; $deny_adsense[] = '/archives/70896'; $deny_adsense[] = '/archives/67225'; $deny_adsense[] = '/archives/58584'; $deny_adsense[] = '/archives/58584/2'; $deny_adsense[] = '/archives/58198'; $deny_adsense[] = '/archives/13255'; $deny_adsense[] = '/archives/56545'; $deny_adsense[] = '/archives/55147'; $deny_adsense[] = '/archives/53584'; $deny_adsense[] = '/archives/59542'; $deny_adsense[] = '/archives/59542/2'; $deny_adsense[] = '/archives/57556'; $deny_adsense[] = '/archives/57556/2'; $deny_adsense[] = '/archives/64919'; $deny_adsense[] = '/archives/65826'; $deny_adsense[] = '/archives/65826/2'; $deny_adsense[] = '/archives/77929'; $deny_adsense[] = '/archives/77929/2'; $deny_adsense[] = '/archives/72239'; $deny_adsense[] = '/archives/72239/2'; $deny_adsense[] = '/archives/81655'; $deny_adsense[] = '/archives/65786'; $deny_adsense[] = '/archives/65826/haye4-0019-027'; $deny_adsense[] = '/archives/special/love'; $deny_adsense[] = '/archives/tag/%e8%b1%86%e7%9f%a5%e8%ad%98'; $deny_adsense[] = '/archives/59542/utamakura_%e6%ad%8c%e3%81%be%e3%81%8f%e3%82%89_poem_of_the_pillow'; $deny_adsense = []; // if(is_user_logged_in()) echo $_SERVER['REQUEST_URI']; if(array_search($_SERVER['REQUEST_URI'], $deny_adsense ) !== FALSE ){ return true; } else return false; } function my_img_caption_shortcode( $attr, $content = null ) { // New-style shortcode with the caption inside the shortcode with the link and image tags. if ( ! isset( $attr['caption'] ) ) { if ( preg_match( '#((?:]+>\s*)?]+>(?:\s*)?)(.*)#is', $content, $matches ) ) { $content = $matches[1]; $attr['caption'] = trim( $matches[2] ); } } elseif ( strpos( $attr['caption'], '<' ) !== false ) { $attr['caption'] = wp_kses( $attr['caption'], 'post' ); } /** * Filters the default caption shortcode output. * * If the filtered output isn't empty, it will be used instead of generating * the default caption template. * * @since 2.6.0 * * @see img_caption_shortcode() * * @param string $output The caption output. Default empty. * @param array $attr Attributes of the caption shortcode. * @param string $content The image element, possibly wrapped in a hyperlink. */ $output = apply_filters( 'img_caption_shortcode', '', $attr, $content ); if ( $output != '' ) { return $output; } $atts = shortcode_atts( array( 'id' => '', 'caption_id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '', 'class' => '', ), $attr, 'caption' ); $atts['width'] = (int) $atts['width']; if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) { return $content; } $id = $caption_id = $describedby = ''; if ( $atts['id'] ) { $atts['id'] = sanitize_html_class( $atts['id'] ); $id = 'id="' . esc_attr( $atts['id'] ) . '" '; if($atts['id']) {$media_permalink = get_permalink( str_replace("attachment_", "", $atts['id']) );} } if ( $atts['caption_id'] ) { $atts['caption_id'] = sanitize_html_class( $atts['caption_id'] ); } elseif ( $atts['id'] ) { $atts['caption_id'] = 'caption-' . str_replace( '_', '-', $atts['id'] ); } if ( $atts['caption_id'] ) { $caption_id = 'id="' . esc_attr( $atts['caption_id'] ) . '" '; $describedby = 'aria-describedby="' . esc_attr( $atts['caption_id'] ) . '" '; } $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); $html5 = current_theme_supports( 'html5', 'caption' ); // HTML5 captions never added the extra 10px to the image width $width = $html5 ? $atts['width'] : ( 10 + $atts['width'] ); /** * Filters the width of an image's caption. * * By default, the caption is 10 pixels greater than the width of the image, * to prevent post content from running up against a floated image. * * @since 3.7.0 * * @see img_caption_shortcode() * * @param int $width Width of the caption in pixels. To remove this inline style, * return zero. * @param array $atts Attributes of the caption shortcode. * @param string $content The image element, possibly wrapped in a hyperlink. */ $caption_width = apply_filters( 'img_caption_shortcode_width', $width, $atts, $content ); $style = ''; if ( $caption_width ) { //$style = 'style="width: ' . (int) $caption_width . 'px" '; } if ( $html5 ) { $html = sprintf( '
%s%s
', $id, $describedby, $style, esc_attr( $class ), do_shortcode( $content ), sprintf( '
%s
', $caption_id, $atts['caption'] ) ); } else { //画像のパーマリンクが取得できていて、キャプションにリンクタグが仕込まれていなければ、キャプションにリンクを付ける。 if($media_permalink AND (strpos($atts['caption'],'href=') === false) ){ if (is_feed() AND ((get_query_var('feed') == 'lineat') OR (get_query_var('feed') == 'dcm'))) { //lineat なら $html = sprintf( '
%s
', $id, $style, esc_attr( $class ), str_replace( '%s%s
', $id, $style, esc_attr( $class ), str_replace( '%s

', $caption_id, $media_permalink, $atts['caption'] ) ); } } else { $html = sprintf( '
%s%s
', $id, $style, esc_attr( $class ), str_replace( '%s

', $caption_id, $atts['caption'] ) ); } } return $html; } add_shortcode('caption', 'my_img_caption_shortcode'); //寄稿者の管理画面のメニューを変更 function remove_menus() { global $current_user; if( in_array( 'writer', $current_user->roles ) ) { remove_menu_page('edit.php?post_type=webdesign'); // 固定ページ remove_menu_page('edit.php?post_type=space'); // 固定ページ remove_menu_page('edit.php?post_type=store'); // 固定ページ remove_menu_page('edit-comments.php'); // コメント remove_menu_page('tools.php'); // ツール remove_menu_page('wpcf7'); // 問い合わせプラグイン remove_menu_page('options-general.php'); // 設定ページ //ダッシュボードの項目 remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); //概要 remove_meta_box( 'wpp_trending_dashboard_widget', 'dashboard', 'normal' ); //人気記事 } } add_action('admin_menu', 'remove_menus', 100); // add_action( 'init', function() { // // JSファイルを事前に登録する // wp_register_script( // // 登録するJSファイルの登録名 // 'my-filter-js', // // 登録するJSファイル // plugins_url( 'my-filter.js', __FILE__ ), // // 依存しているスクリプト(wp-includes/script-loader.php 内で登録されている) // array( 'wp-rich-text', 'wp-element', 'wp-editor', 'wp-compose', 'wp-data' ) // ); // }); // add_action( 'enqueue_block_editor_assets', function() { // // 登録したJSファイルを読み込む // wp_enqueue_script( 'my-filter-js' ); // }); ?>