当前浏览:首页 / WordPress钩子 / post_updated_messages

apply_filters( 'post_updated_messages', array[] $messages )

过滤文章更新后的信息

postmore...

updated


参数

$messagesarray[]
文章更新的信息。有关默认值,请参阅上面的$messages声明。

源码

查看源码 官方文档


更新日志

版本描述
3.0.0开始引入

使用示例

  • 示例1

    这是上述注释中提到的$messages声明:

    $messages['post'] = array(
        0  => '', // Unused. Messages start at index 1.
        1  => __( 'Post updated.' ) . $view_post_link_html,
        2  => __( 'Custom field updated.' ),
        3  => __( 'Custom field deleted.' ),
        4  => __( 'Post updated.' ),
        /* translators: %s: date and time of the revision */
        5  => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
        6  => __( 'Post published.' ) . $view_post_link_html,
        7  => __( 'Post saved.' ),
        8  => __( 'Post submitted.' ) . $preview_post_link_html,
        9  => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
        10 => __( 'Post draft updated.' ) . $preview_post_link_html,
    );
    $messages['page'] = array(
        0  => '', // Unused. Messages start at index 1.
        1  => __( 'Page updated.' ) . $view_page_link_html,
        2  => __( 'Custom field updated.' ),
        3  => __( 'Custom field deleted.' ),
        4  => __( 'Page updated.' ),
        /* translators: %s: date and time of the revision */
        5  => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
        6  => __( 'Page published.' ) . $view_page_link_html,
        7  => __( 'Page saved.' ),
        8  => __( 'Page submitted.' ) . $preview_page_link_html,
        9  => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
        10 => __( 'Page draft updated.' ) . $preview_page_link_html,
    );
    $messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now.