wordpress キャッシュプラグインと 画像圧縮プラグイン サイト速度検査

WP Fastest Cache
http://webshufu.com/wp-fastest-cache/
http://pochilog.jp/2015/07/post-3139/
http://webshufu.com/wp-fastest-cache/

モバイルはキャッシュしない

調査 developers.google.com
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fdoggstarpromotion.info%2F&tab=desktop

画像のロスレス圧縮
EWWW Image Optimizer
http://webkaru.net/wordpress/plugin-ewww-image-optimizer/

EWWW Image Optimizerで画質が劣化しない設定と使い方
http://afirika.net/ewww-image-optimizer
画像圧縮プラグイン使い方

アンドロイド スマフォ クロームにて 文字サイズが大きくなる件

http://www.seomode.jp/html-css/2014/06/25/3339/

このサイトによるとviewportが数字で指定してある場合になる

対処法は

max-height: 100%;

全体のdivにかける

body div{
max-height: 100%; }

ただし
大きくなってほしい場合もあるが
#main_contents div{ max-height:none!important}
では駄目なようだ

一度100%で設定してしまうと
noneでも大きくならない

但し
一度
max-height: 100%; で指定して
のちにスマフォ用の分岐をいれていけば
いいのかなと思う

かってに大きくなると
こまるので

追記
ポップアップのdivが表示おかしくなったので たしか

/*モバイル用
文字が大きくならない*/
body div{
max-height: 200%; }

とした

また
iPhoneで文字が勝手に大きくなるのは

body {
  -webkit-text-size-adjust: 100%;
}

こちら 同じ記事かくわ

リファラスパム対策 2015 07

https://sem-technology.info/google-analytics/avoidance-referrer-spam
2つ目にリファラスパム対策というプロパティを作成。

http://tadasan.net/referer-spam/
正規表現で手動登録

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
 
  ga('create', 'UA-aaaaaaaa-aa', 'sample.com');
  ga('send', 'pageview');
 
  //新たなトラッキング
  ga('create', 'UA-bbbbbbbb-bb', 'auto', {'name': 'newTracker'});
  ga('newTracker.send', 'pageview');
</script>

表記参考
http://www.rikikikikikikikiki.com/analytics/270

googlemap apiにて地図を表示する方法

apiキーは登録せず

<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

apiあれば
詳しく説明
http://syncer.jp/google-maps-javascript-api-matome

<head>
	<script src="http://maps.googleapis.com/maps/api/js?key={APIキー}&sensor=false"></script>
</head>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
//キャンパスの要素を取得する
var canvas = document.getElementById( "gmap" );

//中心の位置座標を指定する
var latlng = new google.maps.LatLng( 35.2732709,136.7873687 );

//地図のオプションを設定する
var mapOptions = {
	zoom: 18 ,				//ズーム値
	center: latlng ,		//中心座標 [latlng]
	scrollwheel: false //スクロール禁止
};

//[canvas]に、[mapOptions]の内容の、地図のインスタンス([map])を作成する
var map = new google.maps.Map( canvas , mapOptions );


// マーカー
new google.maps.Marker({
  position: new google.maps.LatLng( 35.2732709,136.7873687),
  map: map,
 // icon: "v.png"
});
</script>


<div id="gmap" style="width:100%; height:500px;">



<!--
<iframe width="100%" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps?q=愛知県一宮市大和町南高井宮腰72&amp;z=14&amp;scrollwheel=false&amp;output=embed&iwloc=B"></iframe>

-->
</div>

参考http://www.nanchatte.com/map/MarkerImage.html

mac外付け 共有

サンダーバード
/Users/ユーザー名/Library/Thunderbird/Profiles
を外付けにコピーして外付けに作ったのシンボリックリンクをコピペして
/Users/ユーザー名/Library/Thunderbird/Profilesと入れ替え

profiles.iniは各デフォルトのまま。

ツール > アカウント > サーパー設定 > メッセージの保存先の項目がある
要チェック

デザインデータ
これはそのまま外付け

わかりやすいように アクセスしやすいようにね
(ファインダーのサイドが消えてしまうからシステム終了してはずすこと)

ドリームウィーバーcs6サイト設定
/Volumes/Macintosh HD SSD 1/Users/doggstar/Library/Application Support/Adobe/Common/12.0/Sites

ドリームウィーバースニペットなどすべて
/Volumes/Macintosh HD SSD 1/Users/doggstar/Library/Application Support/Adobe/Dreamweaver CS6/ja_JP/Configuration

MAMPデータベース・バーチャルホスト
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
/Applications/MAMP/conf/apache/httpd.conf (MAMPの設定)
/Applications/MAMP/db/mysql/データベース全て
特にibdata1 ib_logfile1 ib_logfile0も

ホスター
/Volumes/Macintosh HD SSD 1/Users/doggstar/Library/Application Support/Hoster

ファイルジラ

旧 & 2021最新
/Volumes/Macintosh HD SSD 1/Users/doggstar/.filezilla
2021まで新
/Volumes/Macintosh HD SSD 1/Users/doggstar/.config/filezilla

フォントエクスプローラー
/Users/doggstar/Library/Application Support/Linotype/

このしたのは重要かどうか プラグイン設定など詳細は不明

/Users/doggstar/Library/Preferences/com.linotype.FontExplorerX.plist
/Users/doggstar/Library/Preferences/com.linotype.FontExplorerX-PlugIns.plist
/Users/doggstar/Library/LaunchAgents/com.linotype.FontFolderProtector.plist

???なくなった/Users/doggstar/Library/Saved Application State/com.linotype.FontExplorerX.savedState/

フォントフォルダを外付けにして共有

システムフォントも同じにしたほうがいいが
システム/System/Library/Fonts/
全員/Library/Fonts/
個人~/Library/Fonts/
ワードなど ソフトがちがうからどうしようか

うちのHPのURLをSEO最適化した覚え

固定ページなどに同じスラッグがあると出来ないから注意
ホームページ制作プラン など

バグってしまったら
キャッシュを消さないといつまでも前の転送がかかって
土ツボにハマる

CPT UI にてスラッグ変更
cate_jirei をホームページ制作実績 に

パーマーリンクの設定で更新保存し直す(※これしないと駄目)

Redirectionで301

url only

/jirei/
転送先
/ホームページ制作実績/
URLコピペして
文字化け?した日本語URLを入れる

これにて下層記事はすべてリダイレクトされる。

タクソノミーも同じく。


/cate_jirei/
転送先
/ホームページ制作カテゴリ/

WP4.2テーマ自動絵文字削除・停止ファンクション

//絵文字削除
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

かんりがめんもでも

//絵文字スクリプト&CSS 削除
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' );

welcart sslでカート内のssl表示を完璧にする

ファンクション
画像等 http://をhttps://に変更

//ssl

add_action('init', 'ssl_ob_start');
function ssl_ob_start(){
	if( !is_admin() )
		ob_start('ssl_ob_callback');
}
function ssl_ob_callback($buffer){
	$pattern = array(
		'|(<[^<]*)href=\"'.get_option('home').'([^>]*)\.css([^>]*>)|',
		'|(<[^<]*)href=\''.get_option('home').'([^>]*)\.css([^>]*>)|',
		'|(<[^<]*)src=\"'.get_option('home').'([^>]*>)|',
		'|(<[^<]*)src=\''.get_option('home').'([^>]*>)|'
	);
	$replacement = array(
		'${1}href="https://za-su.com${2}.css${3}',
		'${1}href=\'https://za-su.com${2}.css${3}',
		'${1}src="https://za-su.com${2}',
		'${1}src=\'https://za-su.com${2}'
	);
	$buffer = preg_replace($pattern, $replacement, $buffer);
	return $buffer;
}

アドバンスカスタムフィールドで地図を表示する

advance_g-map_sprict.php

<style type="text/css">

/*body div{max-height:100%;}こいつが効いてるため ピンとストリートビューがみえんくなる*/
body .acf-map div{max-height: none}

.acf-map {
	width: 100%;
	height: 400px;
	border: #ccc solid 1px;
	margin: 20px 0;
}

</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
(function($) {

/*
*  render_map
*
*  This function will render a Google Map onto the selected jQuery element
*
*  @type	function
*  @date	8/11/2013
*  @since	4.3.0
*
*  @param	$el (jQuery element)
*  @return	n/a
*/

function render_map( $el ) {

	// var
	var $markers = $el.find('.marker');

	// vars
	var args = {
		zoom		: 16,
		center		: new google.maps.LatLng(0, 0),
		mapTypeId	: google.maps.MapTypeId.ROADMAP
	};

	// create map	        	
	var map = new google.maps.Map( $el[0], args);

	// add a markers reference
	map.markers = [];

	// add markers
	$markers.each(function(){

    	add_marker( $(this), map );

	});

	// center map
	center_map( map );

}

/*
*  add_marker
*
*  This function will add a marker to the selected Google Map
*
*  @type	function
*  @date	8/11/2013
*  @since	4.3.0
*
*  @param	$marker (jQuery element)
*  @param	map (Google Map object)
*  @return	n/a
*/

function add_marker( $marker, map ) {

	// var
	var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );

	// create marker
	var marker = new google.maps.Marker({
		position	: latlng,
		map			: map
	});

	// add to array
	map.markers.push( marker );

	// if marker contains HTML, add it to an infoWindow
	if( $marker.html() )
	{
		// create info window
		var infowindow = new google.maps.InfoWindow({
			content		: $marker.html()
		});

		// show info window when marker is clicked
		google.maps.event.addListener(marker, 'click', function() {

			infowindow.open( map, marker );

		});
	}

}

/*
*  center_map
*
*  This function will center the map, showing all markers attached to this map
*
*  @type	function
*  @date	8/11/2013
*  @since	4.3.0
*
*  @param	map (Google Map object)
*  @return	n/a
*/

function center_map( map ) {

	// vars
	var bounds = new google.maps.LatLngBounds();

	// loop through all markers and create bounds
	$.each( map.markers, function( i, marker ){

		var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );

		bounds.extend( latlng );

	});

	// only 1 marker?
	if( map.markers.length == 1 )
	{
		// set center of map
	    map.setCenter( bounds.getCenter() );
	    map.setZoom( 12 );
	}
	else
	{
		// fit to bounds
		map.fitBounds( bounds );
	}

}

/*
*  document ready
*
*  This function will render each map when the document is ready (page has loaded)
*
*  @type	function
*  @date	8/11/2013
*  @since	5.0.0
*
*  @param	n/a
*  @return	n/a
*/

$(document).ready(function(){

	$('.acf-map').each(function(){

		render_map( $(this) );

	});

});

})(jQuery);
</script>

こいつを収納してインクルード

Biz Calendar

ファンクション

//サイドバー
register_sidebars(5, array());

ソース

 
<div class="top_cal "> 
<?php dynamic_sidebar(3); ?>
</div>

css

.top_cal{ font-size:10px;
max-width:250px;
float:right;
margin-top:20px;
margin-right:20px;}

.holiday, .boxholiday{background-color:#2EA7E0!important;}
.today-img img{
display: none;
}

投稿順を直感的に操作できるための方法 ランキングに一覧も連動してくれとの要望 但しランキング選択含め2回入力

まず最初からそういう設定でなかったため
ランキングはランキングのコードを書いた
後からコードを追加したり メタキーを持たせたやり方。

【最初からランキング用のコードを全ての投稿に合わせるやり方】
これはランキングのタクソノミーを作らずに
一覧表示・分岐をすべてメタバリューにて行う方法
問題点としては一覧表示した時、同じランキングがあると複数表示される。
管理画面一覧にて順位が表示されない。
一覧で必ずランキングの順位が優先される つまりランキングの途中に他のツアーを表示できず
単調似なる可能性がある。

今回タマツアーでは後からの指示であったのと
元々メニューオーダーで順位を操作する予定だったため

メニューオーダーをやめて
あらたにソート用の数値boxを作った

0が最も前で デフォルトが100

ランキングに合わせて 123と変えていく。

方法
クイック編集にて調整したかったため今回はカスタムフィールドテンプレートをあえて使用
テンプレートタイトル:
一覧順位用 ▶  数字が小さい方が前に大きい方が後ろにきます。例)ランキングの数値に合わせる・一覧での表示で一番前にこさせたい・表示順を最後にしたいなど。
カスタムポストタイプ (カンマ区切り):
bali-tours,bali-optional-tours,bali-information

テンプレートコンテンツ:
[sort_numb]
type = text
label = 並び順
size = 3
default = 100

クイック編集時余分な所を非表示css

カスタムアドミンcss

.inline-edit-group #custom_field_template_select,
.inline-edit-group .button{ display:none}
#cftdiv .ui-sortable-handle{ font-weight:normal}

メインクエリにてメタバリューナンバーを使い
さらに投稿日にてソート

複数条件ソート

add_action( 'pre_get_posts', 'foo_modify_query_post_order' );
function foo_modify_query_post_order( $query ) {
  //管理画面スルー	
if ( is_admin() || ! $query->is_main_query() )
        return;

//アーカイブページ数 ココ本番 ナンバー若い順 投稿新しい順	
  if ( $query-> is_tax() && $query->is_main_query() ) {
$query->set('posts_per_page', 12 );
$query->set( 'meta_key', 'sort_numb' );//メタキーセット
$query -> set( 'orderby', array( 'meta_value_num' => 'ASC', 'date' => 'ASC' ) ); // 指定順を降順に

  }

}

クエリポストで表示してるやつの時

ここ

	'meta_key' => 'sort_numb',
		'orderby' => array('meta_value_num' => 'ASC', 'date' => 'ASC'),

使用例

      <?php
	$args = array(
		'posts_per_page' => 3,
		'post_type' => 'bali-tours', //カスタム投稿名
		'meta_key' => 'sort_numb',
		'orderby' => array('meta_value_num' => 'ASC', 'date' => 'ASC'),

     'tax_query' => array(
			'relation' => 'AND',
			array(
				'taxonomy' => 'bali-tours-cat',
				'field' => 'slug',
				'terms' => array( 'おすすめ厳選ツアー', '予備' ),
//'operator'=>'NOT IN'
				),
),
		
);

	query_posts( $args );

if ( have_posts () ) :
    while ( have_posts() ) :
        the_post();
?>

スマフォ用のサイドメニュー スライドメニューの導入方法 jquery.sidr.js

jquery.sidr.min.js

こいつを使う

※追記
class=”simple-menu” href=”#sidr”
とし
出てくるのにも
class=”simple-menu” href=”#sidr”要素を入れて
閉じる

下記だと IDだから1こしかきかない
http://number333.org/2013/06/14/sidr/
説明

ヘッダー

<link href="/js/css/jquery.sidr.dark.css" rel="stylesheet" type="text/css">
<script src="/js/jquery.sidr.min.js"></script>

<script>
$(document).ready(function() {
  $('.simple-menu').sidr({side: 'right'});
});
</script>


こいつでくくって

 <?php if (is_mobile()) : 
 //モバイルヘッダー
 ?>

<?php endif; ?>

リンクボタン

<a class="simple-menu" href="#sidr"> 
<img src="/img/d_this/moble_menu.jpg" width="120" height="120" alt="モバイルメニュー" />
</a>

実際のコード

<div id="sidr">
  <!-- Your content -->
  <ul>
  <li><a href="/会社概要/">タマツアーバリとは</a></li>
  <li style="text-align:center">現地ツアー</li>
    <?php wp_list_categories('title_li=&depth=1&taxonomy=bali-tours-cat&hide_empty=0'); ?>
    <li style="text-align:center">オプショナルツアー</li>
    <?php wp_list_categories('title_li=&depth=1&taxonomy=bali-optional-tours-cat&hide_empty=0'); ?>
    
<li style="text-align:center"> </li>
 <li><a href="/bali-tours/世界遺産ボロブドゥールへバリから日帰ツアー/">
世界遺産ボロブドゥール</a>
</a></li>
<li>

<li>
<a href="/bali-tours/バリ島空港送迎(デンパサール国際空港)/">
空港送迎
</a>
</li>


<li>
<a href="/bali-tours/ガソリン代込のお得な車チャーター!行動自由で/">
車チャーター
</a>
</li>
<li style="text-align:center"> </li>
<li>
<a href="/bali-tours-voice/">
お客様の声
</a>
</li>



<li style="text-align:center"> </li>
<li><a href="/お問合せ/">お問合せ</a></li>
<li><a href="/会社概要/">会社概要</a></li>
<li><a href="/個人情報の取扱/">個人情報の取扱</a></li>
    
  </ul>
</div>

<script>
$(document).ready(function() {
  $('#simple-menu').sidr({side: 'right'});
});
</script>

ギャラリーにてキーワードを強化 画像altをループフィールドでaltに

smart custum fileで

ループフィールドsekou_imgz

のsekou_img_altを画像altへ分岐あり

これはさらに新築施工例orリフォームというターム名まで取得して入れる

 

タイトルにて記事内でターム名取得

<?php if ( $terms = get_the_terms($post->ID, 'built-cat') ) { echo ''; //前 <ul> foreach ( $terms as $term ) { echo '' . esc_html($term->name) . ''; //"前後ろ<li></li> } echo ''; //後ろ</ul> } ?>

ギャラリー

<div id="img_box2">
<div class="navi-image">

 <?php
$fields = SCF::get('sekou_imgz');
foreach ($fields as $field) :
?>
<?php
//ターム名
$tarm_key = $term->name;
//ページタイトル
$title_base = get_the_title();
//画像altあれば
if($field['sekou_img_alt']):
$alt = $field['sekou_img_alt'];
$title = $alt.'|'.$tarm_key.'|'.$title_base;
//画像altなければ
else:
$title = $tarm_key.'|'.$title_base;
endif;

 $attachment_id = $field['sekou_img'];
?>


<a href="#" onClick="return false;">
<?php 
$car_photo = wp_get_attachment_image($attachment_id,'gall_h500',0,array('alt'=>$title,'title'=>$title));
echo $car_photo;
?>
</a>
<?php
endforeach;
?>



</div class="navi-image">
  
  <div class="navi">
<ul>


   <?php
$fields = SCF::get('sekou_imgz');
foreach ($fields as $field) :
?>
<?php
//ターム名
$tarm_key = $term->name;
//ページタイトル
$title_base = get_the_title();
//画像altあれば
if($field['sekou_img_alt']):
$alt = $field['sekou_img_alt'];
$title = $alt.'|'.$tarm_key.'|'.$title_base;
//画像altなければ
else:
$title = $tarm_key.'|'.$title_base;
endif;
 $attachment_id = $field['sekou_img'];

?>


<li><a href="#" onClick="return false;">
<?php 
$car_photo = wp_get_attachment_image($attachment_id,'gall_s',0,array('alt'=>$title,'title'=>$title,'class'=>'navi_sam'));
echo $car_photo;
?>
</a></li>
<?php
endforeach;
?>


    </ul>
  </div class="navi">
  <div style="clear:both;"></div>
  
  


  </div id="img_box2">
<!---------------------------------------------------->  

日付で分岐

get_the_time(‘Ymd’)で数字を取得 

if ($day <= 20150611):で その日付を含む古い記事は〜の分岐  [php] <?php $day = get_the_time('Ymd'); if ($day <= 20150611): ?> <div class="blog_deta"><ul><li class="blogcate_icon"><?php echo get_the_term_list( $post->ID, 'jirei_cat','','','' ); ?>  </li></ul> <?php edit_post_link('この記事を編集', '', ''); ?> </div> <?php else:?> <div class="blog_deta"><ul><li><?php the_time('Y.m.d'); ?></li><li class="blogcate_icon"><?php echo get_the_term_list( $post->ID, 'jirei_cat','','','' ); ?>  </li></ul> <?php edit_post_link('この記事を編集', '', ''); ?> </div> <?php endif; ?> [/php]

css3 セレクタ 何番目

20150722追記

http://weboook.blog22.fc2.com/blog-entry-285.html

/*3個目でクリア改行*/
#sample li:nth-child(3n+1){
clear:both;

}


/*2個目でクリア*/
.jirei_box_all .jirei_box2:nth-child(2n+1){clear:both;
}
#smart-cf-custom-field-4672 .smart-cf-meta-box-table:first-child .widefat{ height:480px;}

いつもまちがえるから再び
今回は
:first-childで

最初の要素を指定

親が存在している事で
その後の同じ子でしていする。

今回は
いくつも同じdivの要素で囲われた
その中のテキストエリアを指定

#divの子 .div::first-childの.widefat

購読者の場合はログイン後にトップページ 管理ページにいかせず アドミンバー消す

add_action( 'auth_redirect', 'subscriber_go_to_home' );
function subscriber_go_to_home( $user_id ) {
    $user = get_userdata( $user_id );
    if ( !$user->has_cap( 'edit_posts' ) ) {
        wp_redirect( get_home_url() );
        exit();
    }
}
add_action( 'after_setup_theme', 'subscriber_hide_admin_bar' );
function subscriber_hide_admin_bar() {
    $user = wp_get_current_user();
    if ( isset( $user->data ) && !$user->has_cap( 'edit_posts' ) ) {
        show_admin_bar( false );
    }
}