File: /home/kusanagi/lease-back.com/DocumentRoot/wp-content/themes/original/functions.php
<?php
$freeNum = '0120-928-366';
$telNUM02 = '052-231-1380';
$mail = 'info@life-soleil.com';
$add = '名古屋市中区丸の内2丁目18-22 三博ビル7F';
$addShort = 'https://goo.gl/maps/viEbjRxJKoz';
?>
<?php //ショートコード
function wbfunc1()
{ //問合せ共通ボックス
global $freeNum;
$text = '
<div class="flex_list info_menu001">
<div class="imgBox">
<img class="bgnone" src="' . get_bloginfo('template_directory') . '/images/info_menu001_img001.png" alt=""/>
</div>
<div>
<div class="flex_list appeal">
<div><span class="icon-arrow001"></span>年中無休</div>
<div><span class="icon-arrow001"></span>相談無料</div>
<div><span class="icon-arrow001"></span>土日祝もご相談受付中</div>
</div>
<a class="flex_list tel" href="tel:' . $freeNum . '">
<div><img class="bgnone" src="' . get_bloginfo('template_directory') . '/images/tel001.svg" alt=""/></div>
<b>' . $freeNum . '</b>
<div class="sma tapT">タップすると電話が掛かります</div>
</a>
<div class="time">受付時間:朝8:00~夜21:00</div>
</div>
<div class="go">
<p>些細なことでもお気軽に<br>ご相談ください。</p>
<a class="info001" href="/問合せフォーム/">
<div><span class="icon-arrow003"></span>問い合わせフォーム</div>
</a>
</div>
</div>
';
return $text;
}
add_shortcode('code001', 'wbfunc1');
function wbfunc5()
{ //4つのメニュー1
$text = '
<div class="menuType001">
<div class="flex_list">
<div>
<a href="' . get_category_link(2) . '">
<span class="icon-arrow002"></span>専門家紹介</a>
</div>
<div class="two"><a href="' . get_permalink(134) . '">
<span class="icon-arrow002"></span>サービスと費用
</a></div>
<div><a href="' . get_category_link(4) . '">
<span class="icon-arrow002"></span>活用事例
</a></div>
<div class="two"><a href="' . get_permalink(148) . '">
<span class="icon-arrow002"></span>選ばれる<br class="sma">理由
</a></div>
</div>
</div>
';
return $text;
}
add_shortcode('code005', 'wbfunc5');
function wbfunc6()
{ //4つのメニュー2
$text = '
<div class="menuType002">
<div class="flex_list">
<div>
<a href="' . get_permalink(6) . '">
<span class="icon-arrow002"></span>会社紹介</a>
</div>
<div><a href="' . get_permalink(12) . '">
<span class="icon-arrow002"></span>無料相談
</a></div>
<div><a href="' . get_permalink(148) . '">
<span class="icon-arrow002"></span>当社<small>の</small>特徴
</a></div>
<div class="two"><a href="' . get_permalink(134) . '">
<span class="icon-arrow002"></span>費用と<br>サービス
</a></div>
</div>
</div>
';
return $text;
}
add_shortcode('code006', 'wbfunc6');
function wbfunc20()
{ //会社概要
global $freeNum, $telNUM02, $mail, $add;
$text = '
<table class="style003" style="margin:0;">
<tr><th style="min-width:100px;">会社名</th>
<td><img src="/wp-content/themes/original/images/kaisya.png"
alt="" width="auto" height="auto" class="bgnone" /></td></tr>
<tr><th>住所</th>
<td>
<div class="flex_list">
<div>
■名古屋オフィス<br />' . $add . '<br />
(名古屋駅から車で10分、地下鉄丸の内駅すぐ)<br>
■東京オフィス<br>
東京都中央区日本橋2丁目1-3 アーバンネット日本橋二丁目ビル10F<br>
(JR東京駅より徒歩5分 地下鉄日本橋駅より徒歩1分)
</div>
</div>
</td></tr>
<tr><th>電話番号</th>
<td>
<a href="tel:' . $telNUM02 . '">' . $telNUM02 . '</a>/<a href="tel:' . $telNUM . '">' . $telNUM . '</a>
</td></tr>
<tr><th>FAX</th>
<td>052-231-1381</td></tr>
<tr><th>メール</th>
<td><a href="mailto:' . $mail . '">' . $mail . '</a></td></tr>
<tr><th>営業時間</th>
<td>朝7:00~夜23:00 早朝から深夜まで相談可</td></tr>
<tr><th>定休日</th>
<td>年中無休 いつでもご相談ください。</td></tr>
<tr><th>提携弁護士・司法書士</th>
<td><a href="/category/専門家紹介/">詳しくはこちら</a></td></tr>
</table>
';
return $text;
}
add_shortcode('code020', 'wbfunc20');
function wbfunc40()
{ //リースバックの大事な概要図
$ua = $_SERVER['HTTP_USER_AGENT']; //スマホ判別
$browser = ((strpos($ua, 'iPhone') !== false) || (strpos($ua, 'iPod') !== false) || (strpos($ua, 'Android') !== false));
if ($browser == true): // true = スマホの場合
$text = '<img class="bgnone" src="/wp-content/themes/original/images/cont002_img001_smaho.svg" alt="" />';
else:
$text = '<img class="bgnone" src="/wp-content/themes/original/images/cont002_img001.svg" alt="" />';
endif;
return $text;
}
add_shortcode('code040', 'wbfunc40');
?>
<?php
function wbfunc10()
{ //アイキャッチをキービジュアルとして表示
global $post;
$thumb = get_the_post_thumbnail($post_id, 'full', array('class' => 'bgnone'));
return $thumb;
}
add_shortcode('code010', 'wbfunc10');
?>
<?php
function members()
{ //専門家紹介
global $post;
if (is_category(2)):
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array(2),
'include_children' => true,
'operator' => 'IN'
)
)
);
elseif (is_single()):
$arg = array(
'posts_per_page' => -1,
'post__not_in' => array(get_the_ID()),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array(2),
'include_children' => true,
'operator' => 'IN'
)
)
);
endif;
$myposts = get_posts($arg); ?>
<div class="member">
<ul class="flex_list">
<?php
foreach ($myposts as $post) : setup_postdata($post); ?>
<li class="m<?php echo $post->ID; ?>"><a href="<?php echo get_the_permalink(); ?>">
<dl>
<dt>
<?php $office = get_post_meta($post->ID, 'office', true); ?>
<span><?php echo get_the_title(); ?></span><?php if ($office): echo ' ' . $office . '';
endif; ?>
</dt>
<dd class="flex_list">
<div class="imgBox"><?php echo get_the_post_thumbnail($post_id, 'thumbnail', array('class' => 'bgnone')); ?></div>
<div>
<div class="k">
<span><?php echo get_post_meta($post->ID, 'job_position', true); ?></span>
<?php $job_add = get_post_meta($post->ID, 'job_add', true); ?>
<?php if ($job_add): echo '<span>(' . $job_add . ')</span>';
endif; ?>
</div>
<p>
<?php echo get_post_meta($post->ID, 'prof_text_001', true); ?>
<div class="more"><span class="icon-arrow002"></span>詳細</div>
</p>
</div>
</dd>
</dl>
</a></li>
<?php
endforeach;
wp_reset_postdata(); ?>
</ul>
</div>
<?php
}
?>
<?php
function serch_Menu()
{
if (is_404()):
$text = '申し訳ありません、<br />見つかりませんでした。 ';
elseif (is_search()):
if (have_posts()) :
$text = 'こちらからも検索できます。 ';
else:
$text = '申し訳ありません、<br />見つかりませんでした。 ';
endif;
else:
$text = 'こちらからも検索できます。 ';
endif; ?>
<div class="flex_list flex_list_alignLeft_4_6" style="align-items:center; padding:5% 8%; margin:0 auto; background:#f7ebc3; ">
<div style=""><b><?php echo $text; ?> </b></div>
<div id="sss" class="search_form" role="search" style="padding: 0 5%; margin:0;">
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<input class="part" type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="送 信" class="kensaku" style="top: 25%;" />
</form>
</div>
</div>
<?php
}
?>
<?php //句点で区切りパラグラフにする detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1026804890
function paragraph($para, $para_text)
{
$max = 60;
$now = 0; // 現在位置
$total = mb_strlen($para_text, 'UTF-8');
$ohanashi = array();
while ($now <= $total) {
$len = $max;
$tmp = mb_substr($para_text, $now, $len, 'UTF-8');
$pos = mb_strrpos($tmp, '。', 0, 'UTF-8');
if ($pos !== FALSE) { // 文章が制限文字数より短い
$len = $pos + 1;
$tmp = mb_substr($para_text, $now, $len, 'UTF-8');
}
$ohanashi[] = $tmp;
$now += $len;
}
for ($i = 0; $i <= $para; $i++):
echo $ohanashi[$i];
endfor;
}
?>
<?php //h1
function h1($post_h1)
{
if ($post_h1):
echo '<h1>' . $post_h1 . '</h1>';
else: echo '<h1>' . get_bloginfo('description') . '</h1>';
endif;
}
?>
<?php //パン屑
function breadcrumb()
{ ?>
<div class="breadcrumb" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<?php
$home = get_home_url();
echo '<a href="' . $home . '">HOME</a>';
if (is_single()):
echo ' > ';
$cat = get_the_category();
$cat_ID = $cat[0]->cat_ID;
foreach ($cat as $b):
echo '<a href="/category/' . $b->slug . '/">' . $b->name . '</a> > ';
endforeach;
echo '詳細';
elseif (is_category()):
$now_category = get_query_var('cat');
echo ' > ';
$now_category = get_query_var('cat');
$parent = (get_category($now_category)->parent);
if ($parent) :
$parent_group = get_category_parents($parent, true, ' > ');
echo $parent_group;
endif;
echo get_category($now_category)->cat_name;
elseif (is_page()): //固定ページ
echo ' > ';
the_title();
endif;
echo '</div>';
}
?>
<?php //RSS配信用。originalのフィード用テンプレートを参照するようにアクションを用意
remove_filter('do_feed_rss2', 'do_feed_rss2', 10);
function custom_feed_rss2()
{
$template_file = '/feed-rss2.php';
load_template(get_template_directory() . $template_file);
}
add_action('do_feed_rss2', 'custom_feed_rss2', 10);
?>
<?php //次の記事へ 前の記事へ
function previous_next()
{ ?>
<div class="previous-next">
<div class="previous"><?php previous_post_link('« %link', '%title', 'TRUE'); ?></div>
<div class="next"><?php next_post_link('%link', '%title »', 'TRUE'); ?></div>
<br style="clear:both;" />
</div>
<?php
}
?>
<?php
//ウィジェット使用
// if ( function_exists('register_sidebar') )
// register_sidebar();
?>
<?php
remove_action('wp_head', 'wp_generator'); //バージョン削除
remove_action('wp_head', 'rsd_link'); //rsd_link削除 ※リモート投稿用
remove_action('wp_head', 'wlwmanifest_link'); //wlwmanifest削除 ※リモート投稿用
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
add_action('wp_print_styles', 'dequeue_yarpp_styles'); //YARPPヘッダーCSS削除
add_action('wp_footer', 'dequeue_yarpp_styles'); //YARPPフッターCSS削除
function dequeue_yarpp_styles()
{ //YARPP CSS削除
wp_dequeue_style('yarppRelatedCss');
remove_action('wp_head', 'rest_output_link_wp_head'); //Embed系のタグを削除
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wp_oembed_add_host_js');
}
?>
<?php
//カテゴリーに項目追加(キーワード・ディスクリプション用) http://www.webopixel.net/wordpress/436.html
add_action('edit_category_form_fields', 'extra_category_fields');
function extra_category_fields($tag)
{
$t_id = $tag->term_id;
$cat_meta = get_option("cat_$t_id");
?>
<tr class="form-field">
<th><label for="extra_text">カテゴリー用の説明テキスト(cat_text)</label></th>
<td><textarea name="Cat_meta[cat_text]" id="cat_text" rows="3" cols="60"><?php if (isset($cat_meta['cat_text'])) echo esc_html($cat_meta['cat_text']) ?></textarea>
</td>
</tr>
<tr class="form-field">
<th><label for="extra_text">キーワード</label></th>
<td><input type="text" name="Cat_meta[cat_key]" id="cat_key" size="60" value="<?php if (isset($cat_meta['cat_key'])) echo esc_html($cat_meta['cat_key']) ?>" /></td>
</tr>
<tr class="form-field">
<th><label for="extra_text">ディスクリプション</label></th>
<td><textarea name="Cat_meta[cat_discripsion]" id="cat_discripsion" rows="3" cols="60"><?php if (isset($cat_meta['cat_discripsion'])) echo esc_html($cat_meta['cat_discripsion']) ?></textarea>
</td>
</tr>
<?php
}
add_action('edited_term', 'save_extra_category_fileds');
function save_extra_category_fileds($term_id)
{
if (isset($_POST['Cat_meta'])) {
$t_id = $term_id;
$cat_meta = get_option("cat_$t_id");
$cat_keys = array_keys($_POST['Cat_meta']);
foreach ($cat_keys as $key) {
if (isset($_POST['Cat_meta'][$key])) {
$cat_meta[$key] = $_POST['Cat_meta'][$key];
}
}
update_option("cat_$t_id", $cat_meta);
}
}
//ここから画像UP用
//add_action('admin_print_scripts', 'my_admin_scripts');
//add_action('admin_print_styles', 'my_admin_styles');
//function my_admin_scripts() {
// global $taxonomy;
// if( 'category' == $taxonomy ) {
// wp_enqueue_script('media-upload');
// wp_enqueue_script('thickbox');
// wp_register_script('my-upload', get_bloginfo('template_directory') .'/js/upload.js');
// wp_enqueue_script('my-upload');
// }
//}
//function my_admin_styles() {
// global $taxonomy;
// if( 'category' == $taxonomy ) {
// wp_enqueue_style('thickbox');
// }
//}
?>
<?php
//一般設定に項目追加(キーワード用)
// whitelist_optionsにフックし、有効な項目名にother_infoを追加。
// $whitelist_optionsは設定画面で有効な項目名の配列
// generalは、一般設定。その他、discussion、media、privacy、reading、writing、optionsが記述可能
function add_other_info_field($whitelist_options)
{
$whitelist_options['general'][] = 'other_info';
return $whitelist_options;
}
add_filter('whitelist_options', 'add_other_info_field');
// add_settings_field関数を用いて、一般設定画面に表示項目を追加。
// other_infoは、$whitelist_optionsに追加した項目名、連絡先は項目の表示名。display_other_infoは、フォームを表示させる関数名。generalは一般設定画面。
function regist_other_info_field()
{
add_settings_field('other_info', 'キーワード', 'display_other_info', 'general');
}
add_action('admin_init', 'regist_other_info_field');
// 一般設定でのフォームを表示する関数。
// DBへの保存は、WordPressが自動的に行ってくれる。ただし、ファイルアップロードは対応不可能。
function display_other_info()
{
$other_info = get_option('other_info');
?>
<textarea cols="70" rows="1" name="other_info"><?php echo esc_html($other_info); ?></textarea>
<?php
}
?>
<?php
//サムネイル機能追加
add_theme_support('post-thumbnails'); ?>
<?php
//ページナビゲーション category.phpのみベタ打ち
function page_navigation()
{
global $wp_query;
$big = 99999; // need an unlikely integer
echo '<div class="page_navi">';
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'prev_text' => '« 前へ',
'next_text' => '次へ »'
));
echo '</div>';
} ?>
<?php //css
function add_phpcss()
{
$page_id = 2;
$ua = $_SERVER['HTTP_USER_AGENT']; //スマホ判別
$browser = ((strpos($ua, 'iPhone') !== false) || (strpos($ua, 'iPod') !== false) || (strpos($ua, 'Android') !== false));
if ($browser == true): // true = スマホの場合
?>
<meta name="viewport" content="width=380px">
<link href="<?php bloginfo('template_directory'); ?>/style.php" type="text/css" rel="stylesheet" />
<?php
else:
$data = array(
'side_class001' => get_post_meta($page_id, 'side_class001', true),
'class001' => get_post_meta($page_id, 'class001', true),
'class002' => get_post_meta($page_id, 'class002', true),
);
echo '<link rel="stylesheet" href="' . get_bloginfo('stylesheet_directory') . '/style.php?' . http_build_query($data) . '" type="text/css" />';
endif;
}
add_action('wp_head', 'add_phpcss');
?>
<?php
//category_descriptionのpタグ除去
remove_filter('term_description', 'wpautop'); ?>
<?php
//サムネイル
//add_image_size( 'original_size', 400, 200, true);
add_theme_support('post-thumbnails');
//外観のメニュー
add_theme_support('menus');
//=== 追加 2020/01/07 ========================================
function wpcf7_custom_item_error_position($items, $result)
{
$class = 'wpcf7-custom-item-error';
$names = array('way', 'saimu');
if (isset($items['invalidFields'])) {
foreach ($items['invalidFields'] as $k => $v) {
$orig = $v['into'];
$name = substr($orig, strrpos($orig, ".") + 1);
if (in_array($name, $names)) {
$items['invalidFields'][$k]['into'] = ".{$class}.{$name}";
}
}
}
if (isset($items['invalids'])) {
foreach ($items['invalids'] as $k => $v) {
$orig = $v['into'];
$name = substr($orig, strrpos($orig, ".") + 1);
if (in_array($name, $names)) {
$items['invalids'][$k]['into'] = ".{$class}.{$name}";
}
}
}
return $items;
}
add_filter('wpcf7_ajax_json_echo', 'wpcf7_custom_item_error_position', 10, 2);
add_action('wpcf7_init', 'wpcf7_add_shortcode_radio_required');
function wpcf7_add_shortcode_radio_required()
{
wpcf7_add_shortcode(array('radio*'), 'wpcf7_checkbox_form_tag_handler', true);
}
add_filter('wpcf7_validate_radio*', 'wpcf7_checkbox_validation_filter', 10, 2);
/*
register_post_type($post_type, array(
'label' => '',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => $show_in_menu,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => $post_slug, 'with_front' => true),
'query_var' => true,
'has_archive' => true,
'supports' => array('title','editor','thumbnail'),
'taxonomies' => $_taxonomies,
'labels' => array(
'name' => $post_name,
'singular_name' => $post_name,
'menu_name' => $post_name,
'add_new' => $post_name.' 新規追加',
'add_new_item' => '新規'.$post_name.'追加',
'edit' => '編集',
'edit_item' => $post_name. 'を編集',
'new_item' => '新規'.$post_name,
'view' => '表示',
'view_item' => $post_name.'を表示',
'search_items' => $post_name.'を検索',
'not_found' => '見つかりません。',
'not_found_in_trash' => 'ゴミ箱にはありません。',
'parent' => '親記事',
),
));
*/
?>