Commit 4ebae9d0 by Orine Matsui

サーバのDL反映

parent 3d11edaa
<?php
/* ===============================================================================
総合設定ファイル
=============================================================================== */
/* ディレクトリ設定
------------------------------------------------------------------------------- */
$templatepath = get_template_directory();
define('T_LIBS', $templatepath . '/libs/');
define('T_THEME', get_template_directory_uri());
/* 管理エディターのスタイルシートを登録します
/*---------------------------------------------------------*/
add_action( 'admin_init', 'my_theme_add_editor_style' );
function my_theme_add_editor_style() {
add_editor_style( 'assets/css/content.css' );
}
/* カスタム投稿
------------------------------------------------------------------------------- */
add_action('init', 'create_post_type');
function create_post_type()
{
register_post_type('news', [ // 投稿タイプ名の定義
'labels' => [
'name' => 'ニュース', // 管理画面上で表示する投稿タイプ名
'singular_name' => 'news', // カスタム投稿の識別名
],
'public' => true, // 投稿タイプをpublicにするか
'has_archive' => true, // アーカイブ機能ON/OFF
'menu_position' => 4, // 管理画面上での配置場所
'show_in_rest' => true, // 5系から出てきた新エディタ「Gutenberg」を有効にする
'supports' => array('title', 'editor', 'thumbnail'),
'slug' => 'news',
'rewrite' => array('slug' => 'news', 'with_front' => false),
'taxonomy' => 'news_tax',
]);
$args = array(
'label' => __('カテゴリー', 'achievement'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'news', 'with_front' => false),
);
register_taxonomy('news_tax', 'news', $args);
register_post_type('case', [
'labels' => [
'name' => 'お客様事例',
'singular_name' => 'case',
],
'public' => true,
'has_archive' => true,
'menu_position' => 3,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'case'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'case', 'with_front' => false),
);
register_taxonomy('case_tax', 'case', $args);
register_post_type('trainer', [
'labels' => [
'name' => '講師紹介',
'singular_name' => 'trainer',
],
'public' => true,
'has_archive' => true,
'menu_position' => 7,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'trainer'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'trainer', 'with_front' => false),
);
register_taxonomy('trainer_tax', 'trainer', $args);
register_post_type('experience', [
'labels' => [
'name' => '講演会',
'singular_name' => 'experience',
],
'public' => true,
'has_archive' => true,
'menu_position' => 8,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'experience'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'experience', 'with_front' => false),
);
register_taxonomy('experience_tax', 'experience', $args);
register_post_type('faq', [
'labels' => [
'name' => 'よくある質問',
'singular_name' => 'faq',
],
'public' => true,
'has_archive' => true,
'menu_position' => 9,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'faq'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'faq', 'with_front' => false),
);
register_taxonomy('faq_tax', 'faq', $args);
register_post_type('seminar', [
'labels' => [
'name' => 'セミナー',
'singular_name' => 'seminar',
],
'public' => true,
'has_archive' => true,
'menu_position' => 10,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'seminar'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'seminar', 'with_front' => false),
);
register_taxonomy('seminar_tax', 'seminar', $args);
}
add_theme_support('post-thumbnails');
set_post_thumbnail_size(600, 346, true);
/*【管理画面】ACF Options Page の設定 */
if (function_exists('acf_add_options_page')) {
acf_add_options_page(array(
'page_title' => 'UpdateText', // ページタイトル
'menu_title' => '一括更新テキスト', // メニュータイトル
'menu_slug' => 'update-text', // メニュースラッグ
'capability' => 'edit_posts',
'redirect' => false
));
}
// 「講演会」本文エディタ削除
function my_remove_post_support()
{
remove_post_type_support('experience', 'editor');
}
add_action('init', 'my_remove_post_support');
/*===================================
mark new post
===================================*/
function mark_new_post($days)
{
$today = date_i18n('U');
$entry_day = get_the_time('U');
$post_day = date('U', ($today - $entry_day)) / 86400;
if ($days > $post_day) :
echo '<p class="c-list1__tag"><span>会社情報</span></p>';
endif;
}
//auto check taxonomy custom post news
function mfields_set_default_object_terms($post_id, $post)
{
if ('publish' === $post->post_status && $post->post_type === 'news') {
$defaults = array(
'news_tax' => array('info')
);
$taxonomies = get_object_taxonomies($post->post_type);
foreach ((array)$taxonomies as $taxonomy) {
$terms = wp_get_post_terms($post_id, $taxonomy);
if (empty($terms) && array_key_exists($taxonomy, $defaults)) {
wp_set_object_terms($post_id, $defaults[$taxonomy], $taxonomy);
}
}
}
}
add_action('save_post', 'mfields_set_default_object_terms', 100, 2);
// function tax_news($termlink, $term, $taxonomy)
// {
// if ('news_tax' == $taxonomy)
// return home_url() . '/news/' . $term->slug;
// return $termlink;
// }
// add_filter('term_link', 'tax_news', 10, 3);
// add_filter('request', 'rudr_change_term_request', 1, 1);
// add_filter('term_link', 'rudr_term_permalink', 10, 3);
// function rudr_change_term_request($query)
// {
// $tax_name = 'news_tax';
// if ($query['attachment']) :
// $include_children = true;
// $name = $query['attachment'];
// else :
// $include_children = false;
// $name = $query['name'];
// endif;
// $term = get_term_by('slug', $name, $tax_name);
// if (isset($name) && $term && !is_wp_error($term)) :
// if ($include_children) {
// unset($query['attachment']);
// $parent = $term->parent;
// while ($parent) {
// $parent_term = get_term($parent, $tax_name);
// $name = $parent_term->slug . '/' . $name;
// $parent = $parent_term->parent;
// }
// } else {
// unset($query['name']);
// }
// endif;
// return $query;
// }
// function rudr_term_permalink($url, $term, $taxonomy)
// {
// $taxonomy_name = 'news_tax';
// $taxonomy_slug = 'news_tax';
// if (strpos($url, $taxonomy_slug) === FALSE || $taxonomy != $taxonomy_name) return $url;
// $url = str_replace('/' . $taxonomy_slug, '', $url);
// return $url;
// }
/*【管理画面】投稿メニューを非表示 */
add_action('admin_menu', 'fc_my_remove_menus');
function fc_my_remove_menus()
{
global $menu;
remove_menu_page('edit.php');
}
// Code viet lai rule cho taxonomy custom post type. Chỉ chạy 1 lần rồi xóa đi.
// Code rewrite rule for taxonomy custom post type. Only run 1 time and then delete.
function generate_taxonomy_rewrite_rules($wp_rewrite)
{
$rules = array();
$post_types = get_post_types(array('public' => true, '_builtin' => false), 'objects');
$taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'objects');
foreach ($post_types as $post_type) {
$post_type_name = $post_type->name;
$post_type_slug = $post_type->rewrite['slug'];
foreach ($taxonomies as $taxonomy) {
if ($taxonomy->object_type[0] == $post_type_name) {
$terms = get_categories(array('type' => $post_type_name, 'taxonomy' => $taxonomy->name, 'hide_empty' => 0));
foreach ($terms as $term) {
$rules[$post_type_slug . '/' . $term->slug . '/?$'] = 'index.php?' . $term->taxonomy . '=' . $term->slug;
$rules[$post_type_slug . '/' . $term->slug . '/page/?([0-9]{1,})/?$'] = 'index.php?' . $term->taxonomy . '=' . $term->slug . '&paged=' . $wp_rewrite->preg_index(1);
}
}
}
}
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'generate_taxonomy_rewrite_rules');
/* その他設定
/*---------------------------------------------------------*/
add_action('init', 'fc_disable_emoji');
function fc_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');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_shortlink_wp_head');
}
/* ログイン中にwpadminbar を表示
/*---------------------------------------------------------*/
add_filter('show_admin_bar', 'fc_hidden_admin_bar');
function fc_hidden_admin_bar()
{
return false;
}
add_action('admin_head', 'fc_hiden_aiosp_custom_link_wrapper');
function fc_hiden_aiosp_custom_link_wrapper()
{
echo '<style>
#aiosp_custom_link_wrapper {
display: none !important;
}
</style>';
}
add_filter('aioseop_canonical_url', 'fc_custom_aioseop_canonical_url');
function fc_custom_aioseop_canonical_url($url)
{
if (is_page() || is_single()) {
return get_permalink();
}
return $url;
}
<?php
/* ===============================================================================
総合設定ファイル
=============================================================================== */
/* ディレクトリ設定
------------------------------------------------------------------------------- */
$templatepath = get_template_directory();
define('T_LIBS', $templatepath . '/libs/');
define('T_THEME', get_template_directory_uri());
/* 管理エディターのスタイルシートを登録します
/*---------------------------------------------------------*/
add_action( 'admin_init', 'my_theme_add_editor_style' );
function my_theme_add_editor_style() {
add_editor_style( 'assets/css/content.css' );
}
/* カスタム投稿
------------------------------------------------------------------------------- */
add_action('init', 'create_post_type');
function create_post_type()
{
register_post_type('news', [ // 投稿タイプ名の定義
'labels' => [
'name' => 'ニュース', // 管理画面上で表示する投稿タイプ名
'singular_name' => 'news', // カスタム投稿の識別名
],
'public' => true, // 投稿タイプをpublicにするか
'has_archive' => true, // アーカイブ機能ON/OFF
'menu_position' => 4, // 管理画面上での配置場所
'show_in_rest' => true, // 5系から出てきた新エディタ「Gutenberg」を有効にする
'supports' => array('title', 'editor', 'thumbnail'),
'slug' => 'news',
'rewrite' => array('slug' => 'news', 'with_front' => false),
'taxonomy' => 'news_tax',
]);
$args = array(
'label' => __('カテゴリー', 'achievement'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'news', 'with_front' => false),
);
register_taxonomy('news_tax', 'news', $args);
register_post_type('case', [
'labels' => [
'name' => 'お客様事例',
'singular_name' => 'case',
],
'public' => true,
'has_archive' => true,
'menu_position' => 3,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'case'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'case', 'with_front' => false),
);
register_taxonomy('case_tax', 'case', $args);
register_post_type('trainer', [
'labels' => [
'name' => '講師紹介',
'singular_name' => 'trainer',
],
'public' => true,
'has_archive' => true,
'menu_position' => 7,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'trainer'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'trainer', 'with_front' => false),
);
register_taxonomy('trainer_tax', 'trainer', $args);
register_post_type('experience', [
'labels' => [
'name' => '講演会',
'singular_name' => 'experience',
],
'public' => true,
'has_archive' => true,
'menu_position' => 8,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'experience'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'experience', 'with_front' => false),
);
register_taxonomy('experience_tax', 'experience', $args);
register_post_type('faq', [
'labels' => [
'name' => 'よくある質問',
'singular_name' => 'faq',
],
'public' => true,
'has_archive' => true,
'menu_position' => 9,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'faq'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'faq', 'with_front' => false),
);
register_taxonomy('faq_tax', 'faq', $args);
register_post_type('seminar', [
'labels' => [
'name' => 'セミナー',
'singular_name' => 'seminar',
],
'public' => true,
'has_archive' => true,
'menu_position' => 10,
'show_in_rest' => true,
]);
$args = array(
'label' => __('カテゴリー', 'seminar'),
'public' => true,
'hierarchical' => true,
'rewrite' => array('slug' => 'seminar', 'with_front' => false),
);
register_taxonomy('seminar_tax', 'seminar', $args);
}
add_theme_support('post-thumbnails');
set_post_thumbnail_size(600, 346, true);
/*【管理画面】ACF Options Page の設定 */
if (function_exists('acf_add_options_page')) {
acf_add_options_page(array(
'page_title' => 'UpdateText', // ページタイトル
'menu_title' => '一括更新テキスト', // メニュータイトル
'menu_slug' => 'update-text', // メニュースラッグ
'capability' => 'edit_posts',
'redirect' => false
));
}
// 「講演会」本文エディタ削除
function my_remove_post_support()
{
remove_post_type_support('experience', 'editor');
}
add_action('init', 'my_remove_post_support');
/*===================================
OGPタグ
===================================*/
function my_meta_ogp() {
if( is_front_page() || is_home() || is_singular() ){
global $post;
$ogp_title = '';
$ogp_descr = '';
$ogp_url = '';
$ogp_img = '';
$insert = '';
if( is_singular() ) { //記事&固定ページ
setup_postdata($post);
$ogp_title = $post->post_title;
$ogp_descr = mb_substr(get_the_excerpt(), 0, 100);
$ogp_url = get_permalink();
wp_reset_postdata();
} elseif ( is_front_page() || is_home() ) { //トップページ
$ogp_title = get_bloginfo('name');
$ogp_descr = get_bloginfo('description');
$ogp_url = home_url();
}
//og:type
$ogp_type = ( is_front_page() || is_home() ) ? 'website' : 'article';
//og:image
if ( is_singular() && has_post_thumbnail() ) {
$ps_thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
$ogp_img = $ps_thumb[0];
} else {
$ogp_img = 'https://achievement.co.jp/assets/img/common/ogp.jpg';
}
//facebookのapp_id(設定する場合)$insert .= '<meta property="fb:app_id" content="ここにappIDを入力">' . "\n";
echo $insert;
}
} //END my_meta_ogp
add_action('wp_head','my_meta_ogp');//headにOGPを出力
/*===================================
mark new post
===================================*/
function mark_new_post($days)
{
$today = date_i18n('U');
$entry_day = get_the_time('U');
$post_day = date('U', ($today - $entry_day)) / 86400;
if ($days > $post_day) :
echo '<p class="c-list1__tag"><span>会社情報</span></p>';
endif;
}
//auto check taxonomy custom post news
function mfields_set_default_object_terms($post_id, $post)
{
if ('publish' === $post->post_status && $post->post_type === 'news') {
$defaults = array(
'news_tax' => array('info')
);
$taxonomies = get_object_taxonomies($post->post_type);
foreach ((array)$taxonomies as $taxonomy) {
$terms = wp_get_post_terms($post_id, $taxonomy);
if (empty($terms) && array_key_exists($taxonomy, $defaults)) {
wp_set_object_terms($post_id, $defaults[$taxonomy], $taxonomy);
}
}
}
}
add_action('save_post', 'mfields_set_default_object_terms', 100, 2);
// function tax_news($termlink, $term, $taxonomy)
// {
// if ('news_tax' == $taxonomy)
// return home_url() . '/news/' . $term->slug;
// return $termlink;
// }
// add_filter('term_link', 'tax_news', 10, 3);
// add_filter('request', 'rudr_change_term_request', 1, 1);
// add_filter('term_link', 'rudr_term_permalink', 10, 3);
// function rudr_change_term_request($query)
// {
// $tax_name = 'news_tax';
// if ($query['attachment']) :
// $include_children = true;
// $name = $query['attachment'];
// else :
// $include_children = false;
// $name = $query['name'];
// endif;
// $term = get_term_by('slug', $name, $tax_name);
// if (isset($name) && $term && !is_wp_error($term)) :
// if ($include_children) {
// unset($query['attachment']);
// $parent = $term->parent;
// while ($parent) {
// $parent_term = get_term($parent, $tax_name);
// $name = $parent_term->slug . '/' . $name;
// $parent = $parent_term->parent;
// }
// } else {
// unset($query['name']);
// }
// endif;
// return $query;
// }
// function rudr_term_permalink($url, $term, $taxonomy)
// {
// $taxonomy_name = 'news_tax';
// $taxonomy_slug = 'news_tax';
// if (strpos($url, $taxonomy_slug) === FALSE || $taxonomy != $taxonomy_name) return $url;
// $url = str_replace('/' . $taxonomy_slug, '', $url);
// return $url;
// }
/*【管理画面】投稿メニューを非表示 */
add_action('admin_menu', 'fc_my_remove_menus');
function fc_my_remove_menus()
{
global $menu;
remove_menu_page('edit.php');
}
// Code viet lai rule cho taxonomy custom post type. Chỉ chạy 1 lần rồi xóa đi.
// Code rewrite rule for taxonomy custom post type. Only run 1 time and then delete.
function generate_taxonomy_rewrite_rules($wp_rewrite)
{
$rules = array();
$post_types = get_post_types(array('public' => true, '_builtin' => false), 'objects');
$taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'objects');
foreach ($post_types as $post_type) {
$post_type_name = $post_type->name;
$post_type_slug = $post_type->rewrite['slug'];
foreach ($taxonomies as $taxonomy) {
if ($taxonomy->object_type[0] == $post_type_name) {
$terms = get_categories(array('type' => $post_type_name, 'taxonomy' => $taxonomy->name, 'hide_empty' => 0));
foreach ($terms as $term) {
$rules[$post_type_slug . '/' . $term->slug . '/?$'] = 'index.php?' . $term->taxonomy . '=' . $term->slug;
$rules[$post_type_slug . '/' . $term->slug . '/page/?([0-9]{1,})/?$'] = 'index.php?' . $term->taxonomy . '=' . $term->slug . '&paged=' . $wp_rewrite->preg_index(1);
}
}
}
}
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'generate_taxonomy_rewrite_rules');
/* その他設定
/*---------------------------------------------------------*/
add_action('init', 'fc_disable_emoji');
function fc_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');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_shortlink_wp_head');
}
/* ログイン中にwpadminbar を表示
/*---------------------------------------------------------*/
add_filter('show_admin_bar', 'fc_hidden_admin_bar');
function fc_hidden_admin_bar()
{
return false;
}
add_action('admin_head', 'fc_hiden_aiosp_custom_link_wrapper');
function fc_hiden_aiosp_custom_link_wrapper()
{
echo '<style>
#aiosp_custom_link_wrapper {
display: none !important;
}
</style>';
}
add_filter('aioseop_canonical_url', 'fc_custom_aioseop_canonical_url');
function fc_custom_aioseop_canonical_url($url)
{
if (is_page() || is_single()) {
return get_permalink();
}
return $url;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment