iOS 7.1 beta 3のスクリーンショットを見ると、ボタン形状やサイズでも細かくデザインの統一が進められており、さらに洗練されているようだ。
画像:iPhone in Canada
http://www.iphoneincanada.ca/ios/whats-new-in-ios-7-1-beta-3-pics/
WordPressをスマートフォンに対応させるプラグイン「Wordpress PDA & iPhone」はスマートフォンからの閲覧時にコメントの表示や書き込みができない。
本格的なスマートフォンでの運用を考えた場合、コメントも重要。
一般的な方法としては、テンプレートに
<?php comments_template(); ?>
や
<?php comments_template('comments.php'); ?>
を追加するのだが、
上記の場合、呼び出されるcomments.phpは同階層のcomments.phpではなく
/wp-includes/theme-compat/comments.php
が呼び出されてしまう。
comments.phpの中身をカスタマイズしないのであればそれでも構わないが、例えばコメントフォームにある「ウェブサイト」を消したい場合やスタイルに手を入れたい場合、このファイルを修正してしまうと、バージョンアップの度に修正しなくてはならなくなる。
同階層のcomments.phpを呼び出す場合は、
<?php comments_template('/comments.php'); ?>
とファイル名の前に「/」を入れる。
なお、
元に入っているcomments.phpの中身は
<?php if ( have_comments() ) : ?> <?php endif; ?>
だけなので、
/wp-includes/theme-compat/comments.php
のファイルをコピーして修正して、置き換えればいい。
具体的な、コメントを呼び出すための修正は以下の通り
page.php
ファイルの場所は
/wp-content/plugins/wp-pda/jqmobile-theme/page.php
ファイルを開き
<div><?php the_content(); ?></div> <p> <small> <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?> </small> </p> </div> <?php endwhile; else: ?>
の箇所に追加して
<div><?php the_content(); ?></div> <p> <small> <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?> </small> </p> <?php comments_template('/comments.php'); ?> </div> <?php endwhile; else: ?> </div><!-- /content -->
となるようにする。
————————————————————————————
single.php
ファイルの場所は
/wp-content/plugins/wp-pda/jqmobile-theme/single.php
ファイルを開き
<div><?php the_content(); ?></div> <p> <small> <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?> </small> </p>
の後ろに追加して
<div><?php the_content(); ?></div> <p> <small> <?php echo sprintf(__('This entry was posted on %1$s at %2$s and is filled under:','pda-theme'), the_date(__('l, F jS, Y','pda-theme'), '', '', FALSE),get_the_time()) . " "; the_category(', ');?> </small> </p> <?php comments_template('/comments.php'); ?>
となるようにする。
iPhone・Android等のスマートフォンに対応させるWordPress用のプラグインWordpress PDA & iPhone(wp-pda)はベースにJquery mobileを使用している。
そのためwp-pdaの配布ファイルでは、ウェブサイトを高速化するため、jquery、jquery mobileの各javascriptおよびスタイルシートcssはCDNで直接呼び出しており、CSSを使ったカスタマイズが分かりにくいという難点がある。
デフォルトでは黒いタイトルラインとブルー系のナビボタン、日付になっているが、これを変更したいと思うことは多いはず。
色の変更であれば、意外なほど簡単に配色をカスタマイズしてサイトのデザインを変えることが可能なので紹介。
修正するのは以下のファイル
wp-content/plugins/wp-pda/style.css
ファイルを開き、最後に以下のスタイルシートを追加する
.ui-btn-active, .ui-bar-b, .ui-bar-c { background: #fff; color: #fff; font-weight: bold; border: 1px solid #bf0059; text-shadow: 0 -1px 1px #bf0059; text-shadow: none; background-image: -webkit-gradient(linear, left top, left bottom, from( #ffbbca), to( #ff90a7)); background-image: -webkit-linear-gradient(#ffbbca, #ff90a7); background-image: -moz-linear-gradient(#ffbbca, #ff90a7); background-image: -ms-linear-gradient(#ffbbca, #ff90a7); background-image: -o-linear-gradient(#ffbbca, #ff90a7); background-image: linear-gradient(#ffbbca, #ff90a7); }
各項目の解説
background:
ヘッダ、タイトル、ナビ選択状態の背景色
color:
ヘッダ、タイトル、ナビ選択状態の文字色
border:
回りのラインの色(同系色の濃いめにすると良い)
text-shadow:
タイトル文字の影(同系色の濃いめにすると良い)
background-image:
複数あるが、多くのブラウザに対応させるためのもの(同じ色で指定していく)
WordPressをiPhoneやAndroidなどのスマートフォンに対応させるプラグインとして、Wordpress PDA & iPhone (wp-pda) を新しいjQuery Mobileで使用すると、カテゴリー表示にした場合にレイアウトに不具合が発生する。
前回のエントリ『Wordpress PDA & iPhone (wp-pda)カテゴリ表示での不具合修正方法』では、カテゴリを呼び出す階層を制限することで表示不具合に対処したが、サブカテゴリに辿り着けないのは不便なため、別の修正方法をとることにした。
前回修正してしまっている場合も、
<?php if($detectedPage=='categories') :?> 〜 <?php endif; ?>
をそのまま入れ替えればいい。
修正するのは、前回と同じ以下のファイル
/plugins/wp-pda/jqmobile-theme/index.php
オリジナル
<?php if($detectedPage=='categories') :?> <div data-role="content"> <ul data-role="listview" data-inset="true"> <?php $categoriesHTML = wp_list_categories('title_li=&show_count=1&echo=0'); $categoriesHTML = ereg_replace("/\n\r|\r\n|\n|\r/", "", $categoriesHTML); $categoriesHTML = str_replace(" ",' ',$categoriesHTML); $categoriesHTML = str_replace(" ",' ',$categoriesHTML); $categoriesHTML = str_replace("a> (",'a> <span class="ui-li-count">',$categoriesHTML); $categoriesHTML = str_replace(")</li",'</span> </li',$categoriesHTML); echo $categoriesHTML; ?> </ul> </div> <?php endif; ?>
を
<?php if($detectedPage=='categories') :?> <div data-role="content"> <ul data-role="listview" data-inset="true"> <?php $categoriesHTML = wp_list_categories('title_li=&show_count=1&echo=0'); $categoriesHTML = ereg_replace("/\n\r|\r\n|\n|\r|\t|> </", "", $categoriesHTML); $categoriesHTML = str_replace("a> (",'a><span class="ui-li-count">',$categoriesHTML); $categoriesHTML = str_replace(")<ul class='children'>","</span><ul class='children'>",$categoriesHTML); $categoriesHTML = str_replace(")</li",'</span></li',$categoriesHTML); echo $categoriesHTML; ?> </ul> </div> <?php endif; ?>
に変更する。
この修正を施すことにより、カテゴリリストをタップすると、サブカテゴリが存在する場合はサブカテゴリ一覧、無い場合は該当カテゴリのファイル一覧が表示される。
WordPressをiPhoneやAndroidなどのスマートフォンに対応させるプラグインとして、Wordpress PDA & iPhone (wp-pda) は便利だが、jquery mobileのバージョンをjQuery Mobile 1.1や、新しいjQuery Mobile 1.2にすると、カテゴリー表示にした場合にレイアウトに不具合が発生する。
症状としては、エラー等で表示されない訳ではなく、サブカテゴリまであるカテゴリの表示部分に余分なテキスト等が表示されてしまい、表示が崩れてしまう。
階層が浅いサイトならば問題なく使える場合もあるだろうが、現実的にはこの表示バグを修正した方が良いだろう。
修正するのは以下のファイル
plugins/wp-pda/jqmobile-theme/index.php
<?php if($detectedPage=='categories') :?> <div data-role="content"> <ul data-role="listview" data-inset="true"> <?php $categoriesHTML = wp_list_categories('title_li=&show_count=1&echo=0'); $categoriesHTML = ereg_replace("/\n\r|\r\n|\n|\r/", "", $categoriesHTML); $categoriesHTML = str_replace(" ",' ',$categoriesHTML); $categoriesHTML = str_replace(" ",' ',$categoriesHTML); $categoriesHTML = str_replace("a> (",'a> <span class="ui-li-count">',$categoriesHTML); $categoriesHTML = str_replace(")</li",'</span> </li',$categoriesHTML); echo $categoriesHTML; ?> </ul> </div> <?php endif; ?>
を
<?php if($detectedPage=='categories') :?> <div data-role="content"> <ul data-role="listview" data-inset="true"> <?php $categoriesHTML = wp_list_categories('title_li=&show_count=1&echo=0&depth=1'); $categoriesHTML = ereg_replace("/\n\r|\r\n|\n|\r/", "", $categoriesHTML); $categoriesHTML = str_replace(" ",' ',$categoriesHTML); $categoriesHTML = str_replace(" ",' ',$categoriesHTML); $categoriesHTML = str_replace("a> (",'a> <span class="ui-li-count">',$categoriesHTML); $categoriesHTML = str_replace(")</li",'</span> </li',$categoriesHTML); echo $categoriesHTML; ?> </ul> </div> <?php endif; ?>
のように修正。具体的には
$categoriesHTML = wp_list_categories('title_li=&show_count=1&echo=0');
の部分に「&depth=1」を入れて階層取得を1階層に制限するだけの話。
この1行を修正するだけで、表示バグは直る。
iPhoneを使っていて、通常のメールは受信できるのに添付画像が受信できない、送られているはずの添付画像が反映されないことがある。
これからも、のんびり楽しめるSNSを続けていきます。
iPhoneオーナーのためのSNS『iPhoneStyle』
http://iphone-sns.com/
これからも、安全して楽しめるSNSを続けていきます。
iPhoneオーナーのためのSNS『iPhoneStyle』
http://iphone-sns.com/
iPhone対応の無料SNS『iPhoneStyle』は、2011年3月21日に登録者数が4000人を越えました。
これからも、安全して楽しめるSNSを続けていきます。
iPhoneオーナーのためのSNS『iPhoneStyle』
http://iphone-sns.com/