🚀 Advanced Web Server Manager
Complete File Manager & Terminal - Standalone Version
By Sid Gifari | Gifari Industries
Current path:
/
/
home
/
users
/
2
/
fujibow
/
web
/
fujibow.co.jp
/
wp
/
wp-content
/
themes
/
wp-theme
✏️
Editing: functions.php
<?php // RSS2 add_theme_support('automatic-feed-links'); // サムネイル(アイキャッチ)画像表示 add_theme_support('post-thumbnails'); // 投稿スラッグの自動生成 function auto_post_slug($slug, $post_ID, $post_status, $post_type) { if (preg_match('/(%[0-9a-f]{2})+/', $slug)) { $slug = utf8_uri_encode($post_type) . '-' . $post_ID; } return $slug; } add_filter('wp_unique_post_slug', 'auto_post_slug', 10, 4); // 固定ページにカテゴリ追加 add_action('init', 'add_categories_for_pages'); function add_categories_for_pages() { register_taxonomy_for_object_type('category', 'page'); } add_action('pre_get_posts', 'nobita_merge_page_categories_at_category_archive'); function nobita_merge_page_categories_at_category_archive($query) { if ($query->is_category== true && $query->is_main_query()) { $query->set('post_type', array('post', 'page', 'nav_menu_item')); } } // // カスタムメニュー // // カスタムメニュー設定(ひとつ) // register_nav_menu('gloval-nav', 'グローバルナビ'); // カスタムメニュー設定(複数) register_nav_menus(array( 'header-nav' => 'ヘッダーナビ', 'concept-nav' => 'コンセプトナビ', 'member-nav' => 'メンバーナビ', 'about-nav' => 'アバウトナビ' )); // // ソースから余分なタグを削除 // // カスタムメニューの余分なクラスを削除 add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); function my_css_attributes_filter($var) { return is_array($var) ? array_intersect($var, array('current-menu-item')): ''; } // 投稿画像の縦横サイズ削除 function remove_width_attribute($html) { $html = preg_replace('/(width|height)="\d*"\s/', "", $html); return $html; } add_filter('post_thumbnail_html', 'remove_width_attribute', 10); add_filter('image_send_to_editor', 'remove_width_attribute', 10); // 投稿にp,brタグを追加させない add_action('init', function() { remove_filter('the_excerpt', 'wpautop'); remove_filter('the_content', 'wpautop'); }); add_filter('tiny_mce_before_init', function($init) { $init['wpautop'] = false; $init[‘apply_source_formatting’] = true; return $init; }); // headから削除 remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'rel_canonical'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'parent_post_rel_link', 10, 0); remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'wp_shortlink_wp_head'); // 4.2で追加された絵文字スクリプトの削除 function disable_emoji() { remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('admin_print_scripts', 'print_emoji_detection_script'); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action('admin_print_styles', 'print_emoji_styles'); remove_filter('the_content_feed', 'wp_staticize_emoji'); remove_filter('comment_text_rss', 'wp_staticize_emoji'); remove_filter('wp_mail', 'wp_staticize_emoji_for_email'); } add_action('init', 'disable_emoji'); //remove admin bar function site_remove_admin_bar(){ return false; } add_filter( 'show_admin_bar', 'site_remove_admin_bar' , 1000 ); function custom_setup() { global $google_map_id; global $assets; $assets = get_template_directory_uri().'/assets'; } add_action( 'after_setup_theme', custom_setup ); function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); // function extend_tiny_mce_before_init( $mce_init ) { // $mce_init['cache_suffix'] = 'v='.time(); // return $mce_init; // } // add_filter( 'tiny_mce_before_init', 'extend_tiny_mce_before_init' ); // add_editor_style( 'assets/css/common.css' ); // add_editor_style( 'assets/css/style.css' ); // add_filter( 'tiny_mce_before_init', 'custom_tiny_mce_body_class' ); // function custom_tiny_mce_body_class( $settings ){ // global $post; // $current_screen = get_current_screen(); // if( $current_screen->post_type == 'post' ){ // $settings['body_class'] = 'article'; // }else{ // $settings['body_class'] = 'content'; // } // $settings['valid_elements'] = '*[*]'; // $settings['extended_valid_elements'] = '*[*]'; // return $settings; // } // add_filter( 'mce_buttons', 'remove_mce_buttons' ); // function remove_mce_buttons( $buttons ) { // $remove = array( // 'formatselect', // フォーマット // 'bold', // 太字 // 'italic', // イタリック // 'bullist', // 番号なしリスト // 'numlist', // 番号付きリスト // 'blockquote', // 引用 // 'alignleft', // 左寄せ // 'aligncenter', // 中央揃え // 'alignright', // 右寄せ // 'link', // リンクの挿入/編集 // 'unlink', // リンクの削除 // 'wp_more', // 「続きを読む」タグを挿入 // 'wp_adv', // ツールバー切り替え // 'dfw' // 集中執筆モード // ); // return array_diff( $buttons, $remove ); // } // add_filter( 'mce_buttons_2', 'remove_mce_buttons_2' ); // function remove_mce_buttons_2( $buttons ) { // $remove = array( // 'strikethrough', // 打ち消し // 'hr', // 横ライン // 'forecolor', // テキスト色 // 'pastetext', // テキストとしてペースト // 'removeformat', // 書式設定をクリア // 'charmap', // 特殊文字 // 'outdent', // インデントを減らす // 'indent', // インデントを増やす // 'undo', // 取り消し // 'redo', // やり直し // 'wp_help' // キーボードショートカット // ); // return array_diff( $buttons, $remove ); // } // add_filter( 'tiny_mce_before_init', 'custom_tiny_mce_style_formats' ); // function custom_tiny_mce_style_formats( $settings ) { // $style_formats = array( // array( // 'title' => 'インデント', // 'block' => 'div', // 'classes' => 'indent', // 'wrapper' => true, // ), // array( // 'title' => '矢印リンク', // 'selector' => '*', // 'classes' => 'link', // 'wrapper' => false, // ), // array( // 'title' => 'タイトル付リスト囲み', // 'block' => 'dl', // 'classes' => '', // 'wrapper' => false, // ), // array( // 'title' => 'タイトル付リストタイトル', // 'inline' => 'dt', // 'classes' => '', // 'wrapper' => true, // ), // array( // 'title' => 'タイトル付リスト説明', // 'inline' => 'dd', // 'classes' => '', // 'wrapper' => true, // ), // array( // 'title' => 'ライン', // 'selector' => '*', // 'classes' => 'ul', // 'wrapper' => false, // ), // array( // 'title' => 'divタグ', // 'block' => 'div', // 'classes' => '', // 'wrapper' => false, // ), // ); // $settings[ 'style_formats' ] = json_encode( $style_formats ); // return $settings; // } // add_filter( 'mce_buttons', 'add_original_styles_button' ); // function add_original_styles_button( $buttons ) { // array_splice( $buttons, 1, 0, 'styleselect' ); // return $buttons; // } // function my_excerpt_length($length) { // return 150; // } // add_filter('excerpt_length', 'my_excerpt_length'); // function new_excerpt_more($more) { // return ''; // } // add_filter('excerpt_more', 'new_excerpt_more'); //レスポンシブなページネーションを作成する function responsive_pagination($pages = '', $range = 4){ $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages){ $pages = 1; } } if(1 != $pages) { echo '<ul>'; for ($i=1; $i <= $pages; $i++) { if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) { echo ($paged == $i)? '<li><span>'.$i.'</span></li>':'<li><a href="'.get_pagenum_link($i).'">'.$i.'</a></li>'; } } echo '</ul>'; } } // root page function get_page_parent( $parent_id , $object = true , $root = true ) { if( $parent_id == false ) { return false; } if( $object == true ) { while( $parent_id ) { $page = get_post( $parent_id ); $result[] = $page; $parent_id = $page->post_parent; } } else { while( $parent_id ) { $page_id = get_post_field( 'post_parent' , $parent_id ); $result[] = $parent_id; $parent_id = $page_id; } } $result = array_reverse( $result ); if( $root == true) { $result = $result[0]; } return $result; } if( function_exists('acf_add_options_page') ) { acf_add_options_page(); } function my_mail( $Mail, $values, $Data ) { $address = get_field($values['type'],'option'); if($address){ $Mail->to = $address; } return $Mail; } add_filter( 'mwform_admin_mail_mw-wp-form-72', 'my_mail', 10, 3 ); // function my_mwform_before_send_reply_mail( $Mail_admin, $Data ) { // echo $Data; // } // add_action( 'mwform_before_send_admin_mail_mw-wp-form-73', 'my_mwform_before_send_admin_mail', 10, 2 ); ?>
💾 Save Changes
❌ Cancel