Contenu connexe
Similaire à 俺のフックがこんなに簡単なわけがない。 (20)
Plus de Hishikawa Takuro (20)
俺のフックがこんなに簡単なわけがない。
- 1. 俺 の フック が こ んなに
ore no hook ga konna ni kantan na wakega nai.
簡単 な わけ がない。
WordBench KOBE #21
- 10. バター60gを混ぜる。
全ての処理には順番がありますが、
それぞれは独立しています。
砂糖60gを加える。
ふんわりするまで混ぜる。
バニラエッセンスを加える。
...
- 20. バター60gを混ぜる。
レシピの中には複数の処理に
砂糖60gを加える。共通した動作があります。
ふんわりするまで混ぜる。
バニラエッセンスを加える。
...
- 21. バター60gをよく混ぜる。
「混ぜる」を
砂糖60gを加える。 「よく混ぜる」に
フィルターをかけた
ふんわりするまでよく混ぜる。
バニラエッセンスを加える。
...
- 22. バター60gをよく混ぜる。
「混ぜる」を
砂糖60gを加える。 「よく混ぜる」に
フィルターをかけた
ふんわりするまでよく混ぜる。
=
フィルターフック
バニラエッセンスを加える。
...
- 24. バター60gをよく混ぜる。
「砂糖60gを加える」
を処理しない
ふんわりするまでよく混ぜる。
バニラエッセンスを加える。
...
- 25. バター60gをよく混ぜる。
「砂糖60gを加える」
を処理しない
ふんわりするまでよく混ぜる。
=
これもフィルターフック
バニラエッセンスを加える。
...
- 41. 該当部分のコード
function wp_trim_excerpt($text = '') {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' .
'[...]');
$text = wp_trim_words( $text, $excerpt_length,
$excerpt_more );
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
wp-includes/formatting.php
- 42. 該当部分のコード
function wp_trim_excerpt($text = '') {
$raw_excerpt = $text;
apply_filters() フィルターをかける
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' .
'[...]');
$text = wp_trim_words( $text, $excerpt_length,
$excerpt_more );
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
- 43. 該当部分のコード
function wp_trim_excerpt($text = '') {
$raw_excerpt = $text;
先ほどの $more の中身が判明。
if ( '' == $text ) {
半角スペース + [...] だった。
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' .
'[...]');
$text = wp_trim_words( $text, $excerpt_length,
$excerpt_more );
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
- 48. /**
* Categories widget class
* 該当部分のコード
* @since 2.8.0
*/
class WP_Widget_Categories extends WP_Widget {
...
! ! $cat_args = array('orderby' => 'name', 'show_count' => $c,
'hierarchical' => $h);
...
! ! <ul>
<?php
! ! $cat_args['title_li'] = '';
! ! wp_list_categories(apply_filters('widget_categories_args',
$cat_args));
?>
! ! </ul>
...
wp-includes/default-widget.php
- 49. /**
* Categories widget class
* 該当部分のコード
* @since 2.8.0
*/
class WP_Widget_Categories extends WP_Widget {
...
wp_list_categories() 関数で
! ! $cat_args = array('orderby' => 'name', 'show_count' => $c,
'hierarchical' => $h);
... カテゴリーの一覧を出力してるようだ。
! ! <ul>
<?php
! ! $cat_args['title_li'] = '';
! ! wp_list_categories(apply_filters('widget_categories_args',
$cat_args));
?>
! ! </ul>
...
- 50. /**
* Categories widget class
* 該当部分のコード
* @since 2.8.0
*/
class WP_Widget_Categories extends WP_Widget {
... オプション値 $cat_args に
フィルターを通してある!
! ! $cat_args = array('orderby' => 'name', 'show_count' => $c,
'hierarchical' => $h);
... これで並び順も変更できそう。
! ! <ul>
<?php
! ! $cat_args['title_li'] = '';
! ! wp_list_categories(apply_filters('widget_categories_args',
$cat_args));
?>
! ! </ul>
...
- 51. /**
* Categories widget class
* 該当部分のコード
* @since 2.8.0
*/
class WP_Widget_Categories extends WP_Widget {
...
! ! $cat_args = array('orderby' => 'name', 'show_count' => $c,
'hierarchical' => $h);
...
! ! <ul>
<?php
オプション値 $cat_args は
配列なんだな。
! ! $cat_args['title_li'] = '';
並び順は名前順になっているな。
! ! wp_list_categories(apply_filters('widget_categories_args',
$cat_args));
?>
! ! </ul>
...
- 52. /**
* Categories widget class
* 該当部分のコード
* @since 2.8.0
*/
class WP_Widget_Categories extends WP_Widget {
...
フィルター名は
! ! $cat_args = array('orderby' => 'name', 'show_count' => $c,
「widget_categories_args」か。
'hierarchical' => $h);
...
! ! <ul>
<?php
! ! $cat_args['title_li'] = '';
! ! wp_list_categories(apply_filters('widget_categories_args',
$cat_args));
?>
! ! </ul>
...