0

私はWordpressに自己紹介しようとしています.テーマをインストールして編集を行った後、次の呼び出しを見つけました:

\wp-content\themes\catch-everest\footer.php

do_action( 'catcheverest_site_generator' );

私はそれをこの機能まで追跡しましたが、完全に迷っています:

function do_action($tag, $arg = '') {
    global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;

    if ( ! isset($wp_actions) )
        $wp_actions = array();

    if ( ! isset($wp_actions[$tag]) )
        $wp_actions[$tag] = 1;
    else
        ++$wp_actions[$tag];

    // Do 'all' actions first
    if ( isset($wp_filter['all']) ) {
        $wp_current_filter[] = $tag;
        $all_args = func_get_args();
        _wp_call_all_hook($all_args);
    }

    if ( !isset($wp_filter[$tag]) ) {
        if ( isset($wp_filter['all']) )
            array_pop($wp_current_filter);
        return;
    }

    if ( !isset($wp_filter['all']) )
        $wp_current_filter[] = $tag;

    $args = array();
    if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
        $args[] =& $arg[0];
    else
        $args[] = $arg;
    for ( $a = 2; $a < func_num_args(); $a++ )
        $args[] = func_get_arg($a);

    // Sort
    if ( !isset( $merged_filters[ $tag ] ) ) {
        ksort($wp_filter[$tag]);
        $merged_filters[ $tag ] = true;
    }

    reset( $wp_filter[ $tag ] );

    do {
        foreach ( (array) current($wp_filter[$tag]) as $the_ )
            if ( !is_null($the_['function']) )
                call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));

    } while ( next($wp_filter[$tag]) !== false );

    array_pop($wp_current_filter);
}

上記の場合のデータフローを説明していただけますか?

4

2 に答える 2

0

これは、Stack Overflow の範囲外の非常に幅広い質問です。

アクションとフィルター、またはフックは、物事を行う「Wordpress」の方法です。Wordpress ページには、アクションを優先的に実行し、ページに適用する前にフィルタリングするコンテンツを返すループがあります。

アクションとフィルターについて書かれた本がたくさんあります。より詳細な情報については、Wordpress プラグインの本をいくつか確認してください。

この本は、私が学んでいるときに何が起こっているのかを理解するのに大いに役立ちました:

http://www.amazon.com/Professional-WordPress-Plugin-Development-Williams/dp/0470916222

于 2013-04-22T18:35:27.167 に答える