Weitere ähnliche Inhalte
Ähnlich wie ノンプログラマーのためのWordPressテーマ作成ステップアップ術 (20)
ノンプログラマーのためのWordPressテーマ作成ステップアップ術
- 2. Webデザイナー
みにょんすたいる Mignon Style
いまい みずえ
WordPress公式ディレクトリ テーマ「Chocolat」
プラグイン「MS Custom Login」デベロッパー
WordPressスターターテーマ「_s」コントリビューター
Adobe BracketsのWordPress用コードヒントも作ってます!
http://mignonstyle.com/
@mignon_style
mignonxstyle
https://profiles.wordpress.org/mignonstyle
- 31. <?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'twentysixteen' ),
'next_text' => __( 'Next page', 'twentysixteen' ),
) );
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
header.phpを読み込み
sidebar.phpを読み込み
footer.phpを読み込み
index.php
- 33. index.php
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'twentysixteen' ),
'next_text' => __( 'Next page', 'twentysixteen' ),
) );
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
- 42. /**
* Twenty Sixteen only works in WordPress 4.4 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.4-alpha', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
}
/**
* Custom template tags for this theme.
*/
require get_template_directory() .
'/inc/template-tags.php';
/**
* Customizer additions.
*/
require get_template_directory() .
'/inc/customizer.php';
require()で
関数ファイルを読み込み
ファイルを1回だけ
読み込めばいいときは
require_once()を
使います
- 70. バリデーション
// タイトルから無効な文字を除外する
sanitize_title( );
// textfieldタグの値をサニタイズする
sanitize_text_field( );
// '#'のついた16進数のカラー値を
サニタイズする
sanitize_hex_color( );
// '#'のついていない16進数の
カラー値をサニタイズする
sanitize_hex_color_no_hash( );
// メールアドレスから無効な文字を
除外する
sanitize_email( );
入力されたデータが正しいものか確認する
カスタマイザーの
サニタイズのときは
Customizer APIの
コールバック関数を
使用します
- 71. // HTMLタグをエスケープ
esc_html( );
// HTMLタグ属性をエスケープ
esc_attr( );
// URLを無害化する
esc_url( );
// 数値を負ではない整数に変換する
absint( );
// textareaタグの値をエスケープ
esc_textarea( );
// 文字列をインライン
JavaScript向けにエスケープ
esc_js( );
エスケープ
表示するデータを規則にそったものに置き換える
他にも
いろいろ
あります!
- 72. // 特定のタグのみ許可する
$allowed_html = array(
'a' => array(
'href' => array(),
'title' => array()
),
'br' => array(),
'em' => array(),
);
wp_kses( $content, $allowed_html,
$allowed_protocols );
// 投稿や固定ページで許可される
HTMLタグのみを使用する
wp_kses_post( );
// コメントで許可されるHTMLタグ
HTMLタグのみを使用する
wp_kses_data( );
エスケープ
指定したHTMLタグだけ許可する場合