ラベル WordPress の投稿を表示しています。 すべての投稿を表示
ラベル WordPress の投稿を表示しています。 すべての投稿を表示

2019年7月20日土曜日

WordPress Cocoon テンプレートカスタマイズ:ヘッダーに任意の画像を挿入する

該当ファイル
lib > html-forms.php > generate_the_site_logo_tag

変更前
$logo_before_tag = '<'.$tag.' class="logo'.$class.'"><a href="'.esc_url(get_home_url()).'" class="site-name site-name-text-link" itemprop="url"><span class="site-name-text" itemprop="name about">';

変更後(赤字部分を追記)
  $logo_before_tag = '<'.$tag.' class="logo'.$class.'"><a href="'.esc_url(get_home_url()).'" class="site-name site-name-text-link" itemprop="url" style="display: flex; flex-direction: column;"><img class="page-sub-header-image" style="width: 5em; margin: auto;" src="画像のファイルパス"><span class="site-name-text" itemprop="name about">';

2014年8月9日土曜日

wp-dtree-30 のエラー回避

数年前に WordPress で wp-dtree を使ってカテゴリ別に記事をツリー表示していたことがあり、久しぶりにこのウィジットを使おうと思ってインストールしてみたところ、動かん・・・。他にもツリー表示をしてくれるウィジットは色々あったので試してみたんですが、どれもイマイチ・・・。
ツリー表示は諦めるか、そのうち自作するかと考えていたんですが、たまたま wp-dtree のスクリプトエラーを見てみたら意外と問題は単純そうでした。

※その後、ふとしたタイミングでもしかしたら「未分類」カテゴリーの記事が無いために発生しているのかと思って、試しに「未分類」カテゴリーの記事を追加したら、そもそも回避コードを使わずともエラーが無くなりました・・・。
  • 「未分類」カテゴリーの記事が無くて wp-dtree が表示されない場合に下記コードを検討してください。
  • 自分の試した環境では「未分類」カテゴリーの記事があっても wp-dtree の動作には問題なく、ツリーノードに「未分類」が表示されました。

ブラウザのコンソールに表示されるエラーメッセージ
SyntaxError: syntax error
 cat1.a(,0,'','','?p=123','','');
 ?cat=6 (307 行目, 7 列目)

ReferenceError: cat1 is not defined
 ...cript><script type='text/javascript'>cat1.openTo('-6', true); /*wp_query object ...
 ?cat=6 (309 行目)

SyntaxError のリンクを辿って行くと表示ページの 307 行目に移動。
var cat1 = new wpdTree('cat1', 'http://WordPressのURL','0');
cat1.config.useLines=1;
cat1.config.useIcons=0;
cat1.config.closeSameLevel=1;
cat1.config.folderLinks=0;
cat1.config.useSelection=0;
cat1.a(0,'root','','','','','');
cat1.a(-6,0,'カテゴリー1','','?cat=6','','');
cat1.a(-12,0,'カテゴリー2','','?cat=12','','');
cat1.a(-7,0,'カテゴリー3','','?cat=7','','');
cat1.a(,0,'','','?p=123','',''); //←ここで失敗
document.write(cat1);

wp-dtree のソースコードを調べてみると、この cat1 を生成しているのは wp-dtree-build.php ファイルの wpdt_build_tree 関数内で、WP-dTree 4.3.1 では 48 行目に記述があります。
$tree .= "{$t}.a({$nodedata['id']},{$nodedata['pid']},'{$nodedata['name']}','{$nodedata['title']}','{$nodedata['url']}','{$target}','{$rsspath}');\n";

おそらく id が null の時を判定して cat1 追加を行わないようにするのがいいような気がしますが、url に 'p' が含まれている場合でも判定条件に使えるので下記コードでエラーを回避しました。
// 元々のコード
// $tree .= "{$t}.a({$nodedata['id']},{$nodedata['pid']},'{$nodedata['name']}','{$nodedata['title']}','{$nodedata['url']}','{$target}','{$rsspath}');\n";  

// {$nodedata['id'] が空になり $nodedata['url'] に "p" が含まれているためか、cat1 変数の作成に失敗?
// 回避コード
if (strpos($nodedata['url'],'p') == false) {
    $tree .= "{$t}.a({$nodedata['id']},{$nodedata['pid']},'{$nodedata['name']}','{$nodedata['title']}','{$nodedata['url']}','{$target}','{$rsspath}');\n";  
}

2014年6月7日土曜日

SQLite を使って WordPress を XAMPP にインストール

以下の5つのステップで SQLite を使った WordPress を簡単に作ることができます。

1.リソースのダウンロード

まずは、WordPress 本体と SQLite Integration をダウンロードしてきます。
WordPress
http://ja.wordpress.org/

SQLite Integration
http://wordpress.org/plugins/sqlite-integration/

(こちらにもインストール手順があります。)
SQLite Integration 本家
http://dogwood.skr.jp/wordpress/sqlite-integration-ja/


2.WordPress と SQLite Integration を XAMMP に配置

次に、WordPress と SQLite Integration を XAMMP に配置していきます。xampp は C:\xampp にインストールしている前提で説明していきます。

C:\xampp\htdocs\wordpress の様に WordPress を配置します。
また、ダウンロードした SQLite Integration を展開し、C:\xampp\htdocs\wordpress\wp-content\plugins に解凍したsqlite-integration を配置します。

3.db.php のコピー
sqlite-integration に含まれる db.php を以下フォルダにコピーします。
C:\xampp\htdocs\wordpress\wp-content

4.wp-config.php の設定
C:\xampp\htdocs\wordpress の wp-config-sample.php をコピーもしくはリネームして wp-config.php にします。

wp-config.php の 認証用ユニークキー部分を探し出します。

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

↓

https://api.wordpress.org/secret-key/1.1/salt にアクセスして取得したコードに置き換えます。

5.WordPress のインストール
http://localhost/wordpress にアクセスしてインストールを開始します。

以上でおしまいです。意外と簡単ですね!

2013年4月19日金曜日

WordPress のヘッダーイメージを非表示

WordPress のヘッダーイメージは header.php の 91 行目あたりにある以下のアンカータグで表示されます。ここを削除する、もしくはコメントアウトするとヘッダーイメージが消えます。


2013年3月17日日曜日

NetBeans で WordPress をデバッグ実行 その1

NetBeans で WordPress をデバッグ実行するための設定をメモします。
最終目標は WordPress のデバッグですが、今回は前提となる XAMPP や NetBeans のインストール手順を説明します。


1.XAMPP インストール
2.JDK インストール
3.NetBeans PHP インストールとデバッグ実行


1.XAMPP インストール
http://www.apachefriends.org/jp/xampp-windows.html#2671

今回は「インストーラ」を選択

インストール時のオプションで、以下を外します。

Server
- FileZilla FTP
- Mercury Mail Server
Program languages
- Perl
Tools
- Webalizer
- Face Sendmail


C:\xampp をインストールフォルダに設定(デフォルト)


インストール終了


C:\xampp\php\ext に php_xdebug.dll があることを確認


php.ini を開いて


php.ini を書き換え


こんなふうに変更
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port=9000
xdebug.trace_output_dir = "C:\xampp\tmp"

一旦 Apatch を止めて・・・


再起動します。



2.JDKダウンロードとインストール
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

JDK インストーラーを実行し、インストールします。
ソースコードは省きました。


インストール終了


3.NetBeans PHP ダウンロードとインストール

ダウンロードはここから
http://netbeans.org/downloads/index.html

NetBeans PHP をインストール











NetBeans を起動して、「ツール」→「オプション」を開きます。
「PHP」→「デバッグ」を開きます。
「最初の行で停止」はチェックを外しておきます。



デバッグ実行




次回は NetBeans に WordPress をインポートする方法と、実際にデバッグする方法を書きます。今回の内容で大方重要な設定は完了していますが(^^;

2013年3月3日日曜日