' . '

'; add_contextual_help( $theme_page, $help ); */ } add_action( 'admin_menu', 'biz_vektor_theme_options_add_page' ); /*-------------------------------------------*/ /* title 生成 /*-------------------------------------------*/ function getHeadTitle() { $options = biz_vektor_get_theme_options(); global $wp_query; $post = $wp_query->get_queried_object(); if (is_home() || is_page('home') || is_front_page()) { if ($options['topTitle']) { $headTitle = $options['topTitle']; } else { $headTitle = get_bloginfo('name'); } // ▼投稿者ページ } else if (is_author()) { $userObj = get_queried_object(); $headTitle = esc_html($userObj->display_name)." | ".get_bloginfo('name'); // ▼固定ページ } else if (is_page()) { // ▼サブページの場合 if ( $post->post_parent ) { if($post->ancestors){ foreach($post->ancestors as $post_anc_id){ $post_id = $post_anc_id; } } else { $post_id = $post->ID; } $headTitle = get_the_title()." | ".get_the_title($post_id)." | ".get_bloginfo('name'); // ▼サブページではない場合 } else { $headTitle = get_the_title()." | ".get_bloginfo('name'); } // ▼お知らせ } else if (get_post_type() === 'info') { // ▼お知らせ if (is_single()) { $taxo_catelist = get_the_term_list_nolink( $post->ID, 'info-cat', '', ',', '' ); if (!empty($taxo_catelist)) : $headTitle = get_the_title()." | ".$taxo_catelist." | ".get_bloginfo('name'); else : $headTitle = get_the_title()." | ".get_bloginfo('name'); endif; // ▼お知らせカテゴリー } else if (is_tax()){ $headTitle = single_cat_title()." | ".get_bloginfo('name'); // ▼お知らせアーカイブ } else if (is_archive()) { $headTitle = get_the_date('Y')."年 | ".get_bloginfo('name'); } // ▼投稿記事 } else if (is_single()) { $category = get_the_category(); if (!empty($category)) : $headTitle = get_the_title()." | ".$category[0]->cat_name." | ".get_bloginfo('name'); else : $headTitle = get_the_title()." | ".get_bloginfo('name'); endif; // ▼投稿カテゴリーページ } else if (is_category()) { $headTitle = single_cat_title()." | ".get_bloginfo('name'); // ▼タグアーカイブ */ } else if (is_tag()) { $headTitle = single_tag_title()." | ".get_bloginfo('name'); // ▼投稿アーカイブページ } else if (is_archive()) { if (is_date()){ $headTitle = get_the_date('Y'."年".'M')." | ".get_bloginfo('name'); } else { $headTitle = single_tag_title(); } // ▼検索結果 } else if (is_search()) { $headTitle = get_search_query()."の検索結果 | ".get_bloginfo('name'); // ▼それ以外 } else { $headTitle = get_bloginfo('name'); } $headTitle = apply_filters( 'titleCustom', $headTitle ); echo $headTitle; } /*-------------------------------------------*/ /* レイアウト /*-------------------------------------------*/ function biz_vektor_layouts() { $layout_options = array( 'content-sidebar' => array( 'value' => 'content-sidebar', 'label' => '右サイドバー', 'thumbnail' => get_template_directory_uri() . '/inc/images/content-sidebar.png', ), 'sidebar-content' => array( 'value' => 'sidebar-content', 'label' => '左サイドバー', 'thumbnail' => get_template_directory_uri() . '/inc/images/sidebar-content.png', ), ); return apply_filters( 'biz_vektor_layouts', $layout_options ); } function biz_vektor_get_default_theme_options() { $default_theme_options = array( 'theme_layout' => 'content-sidebar', ); } function biz_vektor_get_theme_options() { return get_option( 'biz_vektor_theme_options', biz_vektor_get_default_theme_options() ); } /*-------------------------------------------*/ /* bodyタグにレイアウトのクラス追加 /*-------------------------------------------*/ function biz_vektor_layout_classes( $existing_classes ) { $options = biz_vektor_get_theme_options(); $current_layout = $options['theme_layout']; if ( in_array( $current_layout, array( 'content-sidebar', 'sidebar-content' ) ) ) $classes = array( 'two-column' ); if ( 'content-sidebar' == $current_layout ) $classes[] = 'right-sidebar'; elseif ( 'sidebar-content' == $current_layout ) $classes[] = 'left-sidebar'; else $classes[] = $current_layout; $classes = apply_filters( 'biz_vektor_layout_classes', $classes, $current_layout ); return array_merge( $existing_classes, $classes ); } add_filter( 'body_class', 'biz_vektor_layout_classes' ); /*-------------------------------------------*/ /* bodyタグにトップページでサイドバー非表示に設定されていた場合のクラス制御追加 /*-------------------------------------------*/ function biz_vektor_topSideBarDisplay( $existing_classes ) { // $existing_classesは既に存在するbodyのclass // トップページでのみ実行 if (is_front_page()){ $options = biz_vektor_get_theme_options(); if ($options['topSideBarDisplay'] ){ $classes[] = 'one-column'; // 既に存在するbodyの配列から指定の配列名を削除 $existing_classes = array_diff( $existing_classes , array('right-sidebar','left-sidebar','two-column') ); // 既に存在したclass($existing_classes)と今回追加したclass($classes)をマージ $existing_classes = array_merge( $existing_classes, $classes ); } } // bodyのclassを返す return $existing_classes; } add_filter( 'biz_vektor_layout_classes', 'biz_vektor_topSideBarDisplay' ); /*-------------------------------------------*/ /* テーマオプション入力画面 /*-------------------------------------------*/ get_template_part('inc/theme-options-edit'); /*-------------------------------------------*/ /* テーマスタイル /*-------------------------------------------*/ // [1] テーマ配列読み込み function biz_vektor_theme_styleSetting() { global $biz_vektor_theme_styles; $biz_vektor_theme_styles = array( 'calmly' => array( 'label' => 'Calmly', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/002/002.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/002/002_oldIE.css', ), 'plain' => array( 'label' => 'プレーン', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/plain/plain.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/plain/plain_oldIE.css', ), '001_red' => array( 'label' => 'Default_赤', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/001/001_red.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/001/001_oldIE.css', ), '001_bizblue' => array( 'label' => 'Default_紺', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/001/001_bizblue.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/001/001_oldIE.css', ), '001_green' => array( 'label' => 'Default_緑', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/001/001_green.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/001/001_oldIE.css', ), '001_bizgreen' => array( 'label' => 'Default_深緑', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/001/001_bizgreen.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/001/001_oldIE.css', ), '001_black' => array( 'label' => 'Default_黒', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/001/001_black.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/001/001_oldIE.css', ), '001_daidai' => array( 'label' => 'Default_橙', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/001/001_daidai.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/001/001_oldIE.css', ), '001_darkbrown' => array( 'label' => 'Default_焦茶', 'cssPath' => get_template_directory_uri().'/bizvektor_themes/001/001_darkbrown.css', 'cssPathOldIe' => get_template_directory_uri().'/bizvektor_themes/001/001_oldIE.css', ), ); // [2] プラグインからフィルターフックで拡張テーマの配列情報を受け取る $biz_vektor_theme_styles = apply_filters( 'biz_vektor_themePlus', $biz_vektor_theme_styles ); } /* [3] 管理画面のデザイン選択プルダウンで$biz_vektor_theme_stylesを読み込み。 第一引数を valueとして $options[theme_style] に格納 第一引数の配列のlavel $biz_vektor_theme_styleValues['label'] をプルダウン項目として表示。*/ // [4] ヘッダーにスタイルを書き出す function biz_vektor_theme_style() { // DBに入っている配列を読み込み $options = biz_vektor_get_theme_options(); // biz_vektor_theme_styles配列読み込み global $biz_vektor_theme_styles; biz_vektor_theme_styleSetting(); $themePath = $biz_vektor_theme_styles[$options['theme_style']]['cssPath']; // 空の場合(テーマ選択されていない場合)デフォルトの値を設定 if (!$themePath) { $themePath = get_template_directory_uri().'/bizvektor_themes/002/002.css'; } // 基本スタイルのCSSを出力 wp_enqueue_style( 'theme', $themePath , false, '2013-01-31'); } // ▼レスポンシブに非対応なIE8以前用 function biz_vektor_theme_styleOldIe(){ // DBに入っている配列を読み込み $options = biz_vektor_get_theme_options(); // biz_vektor_theme_styles配列読から旧IE用のバスを読み込んで$themePathOldIeに格納 global $biz_vektor_theme_styles; biz_vektor_theme_styleSetting(); $themePathOldIe = $biz_vektor_theme_styles[$options['theme_style']]['cssPathOldIe']; $themePath = $biz_vektor_theme_styles[$options['theme_style']]['cssPath']; $themePathOldIe = $biz_vektor_theme_styles[$options['theme_style']]['cssPathOldIe']; // 空の場合(テーマ選択されていない場合)デフォルトの値を設定 if (!$themePath && !$themePathOldIe) $themePathOldIe = get_template_directory_uri().'/bizvektor_themes/002/002_oldIE.css'; // $themePathOldIeを意図的に空にする場合はあり得る為、空かどうかの条件分岐は必要 if ($themePathOldIe){ print ''."\n"; } } /*-------------------------------------------*/ /* メニューボタンの数 /*-------------------------------------------*/ function biz_vektor_gMenuDivide() { $options = biz_vektor_get_theme_options(); // メニューボタンが未設定の場合 if ($options['gMenuDivide'] == '[ 選択して下さい ]' || ! $options['gMenuDivide'] || ($options['gMenuDivide'] == 'divide_natural') ) { // それ以外 } else { print ''."\n"; print ''."\n"; } } /*-------------------------------------------*/ /* ヘッダーロゴ /*-------------------------------------------*/ function biz_vektor_print_headLogo() { $options = biz_vektor_get_theme_options(); $head_logo = $options['head_logo']; if ($options['head_logo']) { print ''.get_bloginfo('name').''; } else { echo bloginfo('name'); } } /*-------------------------------------------*/ /* ヘッダー電話番号・受付時間 /*-------------------------------------------*/ function biz_vektor_print_headContact() { $options = biz_vektor_get_theme_options(); $contact_txt = $options['contact_txt']; $contact_time = nl2br($options['contact_time']); if ($options['tel_number']) { // 電話番号の入力がある場合 $headContact = '
'."\n"; if ($contact_txt) { // お問い合わせメッセージの入力がある場合 $headContact .= '
'.$contact_txt.'
'."\n"; } // モバイル端末の場合 if ( function_exists('wp_is_mobile') && wp_is_mobile() ) { $headContact .= ''."\n"; // モバイルじゃない場合 } else { $headContact .= '
TEL '.$options['tel_number'].'
'."\n"; } if ($contact_time) { // お問い合わせ時間の入力がある場合 $headContact .= '
'.$contact_time.'
'."\n"; } $headContact .= '
'; } // $headContact にフィルターフックを設定 $headContact = apply_filters( 'headContactCustom', $headContact ); echo $headContact; } /*-------------------------------------------*/ /* お問い合わせページURL出力 0.6以降不使用のはず /*-------------------------------------------*/ /* function biz_vektor_contact_url() { $options = biz_vektor_get_theme_options(); echo $options['contact_link']; } */ /*-------------------------------------------*/ /* facebook twitter バナー出力 /*-------------------------------------------*/ function biz_vektor_snsBnrs() { $options = biz_vektor_get_theme_options(); $facebook = $options['facebook']; $twitter = $options['twitter']; if ($facebook || $twitter) { print '"; ?> '."\n"; echo $topContentsBottom; if ( is_user_logged_in() == TRUE ) { echo '
'."\n"; echo '編集'."\n"; echo '
'."\n"; } echo ''."\n"; } } /*-------------------------------------------*/ /* OGP追加 /*-------------------------------------------*/ function biz_vektor_ogp () { $options = biz_vektor_get_theme_options(); //$ogpImage = $options['ogpImage']; //$fbAppId = $options['fbAppId']; global $wp_query; $post = $wp_query->get_queried_object(); if (is_home() || is_front_page()) { $linkUrl = home_url(); } else if (is_single() || is_page()) { $linkUrl = get_permalink(); } else { $linkUrl = get_permalink(); } $bizVektorOGP = ''."\n"; $bizVektorOGP .= ''."\n"; if ($options['fbAppId']){ $bizVektorOGP = $bizVektorOGP.''."\n"; } // ▼ トップページ if (is_front_page() || is_home()) { echo ''."\n"; if ($options['ogpImage']){ $bizVektorOGP .= ''."\n"; } $bizVektorOGP .= ''."\n"; $bizVektorOGP .= ''."\n"; // ▼ カテゴリー&アーカイブ } else if (is_category() || is_archive()) { echo ''."\n"; if ($options['ogpImage']){ $bizVektorOGP .= ''."\n"; } // ▼ 固定ページ・投稿ページの場合 } else if (is_page() || is_single()) { $bizVektorOGP .= ''."\n"; // image if (has_post_thumbnail()) { $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,'large', true); $bizVektorOGP .= ''."\n"; } else if ($options['ogpImage']){ $bizVektorOGP .= ''."\n"; } // description $metaExcerpt = $post->post_excerpt; if ($metaExcerpt) { $metadescription = $post->post_excerpt; } else { $metadescription = mb_substr( strip_tags($post->post_content), 0, 240 ); // タグを無効化して240文字でトリム $metadescription = str_replace(array("\r\n","\r","\n"), ' ', $metadescription); // 改行コード削除 } $bizVektorOGP .= ''."\n"; $bizVektorOGP .= ''."\n"; // 固定ページ・投稿ページ以外 } else { $bizVektorOGP .= ''."\n"; if ($options['ogpImage']){ $bizVektorOGP .= ''."\n"; } } // $bizVektorOGP にフィルターフックを設定 $bizVektorOGP = apply_filters('bizVektorOGPCustom', $bizVektorOGP ); echo $bizVektorOGP; //echo ''."\n"; } /*-------------------------------------------*/ /* 中ページ下部問い合わせエリア /*-------------------------------------------*/ function biz_vektor_mainfootContact() { $options = biz_vektor_get_theme_options(); $contact_txt = $options['contact_txt']; $contact_time = nl2br($options['contact_time']); if ($contact_txt) { print ''.$contact_txt.''."\n"; } if ($options['tel_number']) { // モバイル端末の場合 if ( function_exists('wp_is_mobile') && wp_is_mobile() ) { echo 'TEL '.$options['tel_number'].''."\n"; // モバイルじゃない場合 } else { echo 'TEL '.$options['tel_number'].''."\n"; } if ($contact_time) { print ''.$contact_time.''."\n"; } } } /*-------------------------------------------*/ /* snsBtns /*-------------------------------------------*/ function twitterID() { $options = biz_vektor_get_theme_options(); return $options['twitter']; } function mixiKey() { $options = biz_vektor_get_theme_options(); return $options['mixiKey']; } /*-------------------------------------------*/ /* snsBtns 表示ページ設定 /*-------------------------------------------*/ function biz_vektor_snsBtns() { $options = biz_vektor_get_theme_options(); $snsBtnsFront = $options['snsBtnsFront']; $snsBtnsPage = $options['snsBtnsPage']; $snsBtnsPost = $options['snsBtnsPost']; $snsBtnsInfo = $options['snsBtnsInfo']; $snsBtnsHidden = $options['snsBtnsHidden']; global $wp_query; $post = $wp_query->get_queried_object(); $snsHiddenFlag = false ; // $snsBtnsHidden を , で分割して $snsHiddens に配列として格納 $snsHiddens = spliti(",",$snsBtnsHidden); // $snsHiddenに値を順番に入れて実行 foreach( $snsHiddens as $snsHidden ){ // 現在のIDと配列の数字が同じだった場合 if (get_the_ID() == $snsHidden) { // $snsHiddenFlagフラグ立てる $snsHiddenFlag = true ; } } wp_reset_query(); // フラグが立ってなかったら実行 if (!$snsHiddenFlag) { if ((is_front_page() && $snsBtnsFront) || (is_page() && $snsBtnsPage && !is_front_page()) || (get_post_type() == 'info' && $snsBtnsInfo) || (is_single() && $snsBtnsPost) ) { get_template_part('module_snsBtns'); } } } /*-------------------------------------------*/ /* facebookコメント欄表示ページ設定 /*-------------------------------------------*/ function biz_vektor_fbComments() { $options = biz_vektor_get_theme_options(); global $wp_query; $post = $wp_query->get_queried_object(); $fbCommentHiddenFlag = false ; // $snsBtnsHidden を , で分割して $snsHiddens に配列として格納 $fbCommentHiddens = spliti(",",$options['fbCommentsHidden']); // $snsHiddenに値を順番に入れて実行 foreach( $fbCommentHiddens as $fbCommentHidden ){ // 現在のIDと配列の数字が同じだった場合 if (get_the_ID() == $fbCommentHidden) { // $snsHiddenFlagフラグ立てる $fbCommentHiddenFlag = true ; } } wp_reset_query(); // フラグが立ってなかったら実行 if (!$fbCommentHiddenFlag) { if ((is_front_page() && $options['fbCommentsFront']) || (is_page() && $options['fbCommentsPage'] && !is_front_page() ) || (get_post_type() == 'info' && $options['fbCommentsInfo']) || (is_single() && $options['fbCommentsPost']) ) { ?>
data-show-faces="" data-stream="" data-header="true">
'; } else { echo $footSiteName; } } function biz_vektor_print_footContact() { $options = biz_vektor_get_theme_options(); $contact_address = nl2br($options['contact_address']); if ($contact_address) { print $contact_address; } } function biz_vektor_footerCopyRight() { $options = biz_vektor_get_theme_options(); $subSiteName = ($options['sub_sitename']); print '
Copyright © '; if ($subSiteName) { print $subSiteName; } else { bloginfo( 'name' ); } print ' All Rights Reserved.
'; /* 利用規約上は表示を強制していませんが、差し支えなければなるべく消さないで下さい。 */ // id名は個別カスタマイズしてしまっている案件がある為変更不可 $footerPowerd = '
Powered by WordPress & BizVektor Theme by Vektor,Inc. technology.
'; // フィルターフック設定 // ※変数名・フィルター名は既にプラグインが販売されているので変更不可 $footerPowerd = apply_filters( 'footerPowerdCustom', $footerPowerd ); echo $footerPowerd; } /*-------------------------------------------*/ /* GoogleAnalytics /*-------------------------------------------*/ function biz_vektor_googleAnalytics(){ $options = biz_vektor_get_theme_options(); $gaID = $options['gaID']; $gaType = $options['gaType']; if ($gaID) { // 未選択 or 通常 or 両方 出力設定の場合 if ((!$gaType) || ($gaType == 'gaType_normal') || ($gaType == 'gaType_both')){ ?> '; if ($options['slide'.$i.'link']) { $blank = ""; if ($options['slide'.$i.'blank']) : $blank = ' target="_blank"'; endif; print ''; } else { print ''; } print ''.$options['slide'.$i.'alt'].''; if ($options['slide'.$i.'link']) { print ''; } else { print ''; } print ''."\n"; } } } } /*-------------------------------------------*/ /* optionの値を単純に引っ張る /*-------------------------------------------*/ function bizVektorOptions($optionLabel) { $options = biz_vektor_get_theme_options(); if ($options[$optionLabel]){ return $options[$optionLabel]; } else { bizVektorOptions_default(); global $bizVektorOptions_default; return $bizVektorOptions_default[$optionLabel]; } } /*-------------------------------------------*/ /* optionの値のデフォルトの値を設定 /*-------------------------------------------*/ function bizVektorOptions_default() { global $bizVektorOptions_default; $bizVektorOptions_default = array( 'postLabelName' => 'ブログ', 'rssLabelName' => '新着ブログ記事', ); } /*-------------------------------------------*/ /* theme_optionsページでのみ使うjsを読み込む /*-------------------------------------------*/ add_action('admin_print_scripts-appearance_page_theme_options', 'admin_theme_options_plugins'); function admin_theme_options_plugins( $hook_suffix ) { wp_enqueue_script( 'jquery' ); wp_register_script( 'biz_vektor-theme-options', get_template_directory_uri().'/inc/theme-options.js', array('jquery'), '20120902' ); wp_enqueue_script( 'biz_vektor-theme-options' ); } /* admin_head JavaScriptのデバッグコンソールにhook_suffixの値を出力 /*-------------------------------------------*/ /* add_action("admin_head", 'suffix2console'); function suffix2console() { global $hook_suffix; if (is_user_logged_in()) { $str = ""; printf($str, $hook_suffix); } } */