wp_ajax_find_posts
函数
wp_ajax_find_posts ( No parameters )
- 相关
-
- 定义位置
-
-
wp-admin/includes/ajax-actions.php
, line 2207
-
wp-admin/includes/ajax-actions.php
- 引入
- 3.1.0
- 弃用
- –
Ajax handler for querying posts for the Find Posts modal.
function wp_ajax_find_posts() {
check_ajax_referer( 'find-posts' );
$post_types = get_post_types( array( 'public' => true ), 'objects' );
unset( $post_types['attachment'] );
$args = array(
'post_type' => array_keys( $post_types ),
'post_status' => 'any',
'posts_per_page' => 50,
);
$search = wp_unslash( $_POST['ps'] );
if ( '' !== $search ) {
$args['s'] = $search;
}
$posts = get_posts( $args );
if ( ! $posts ) {
wp_send_json_error( __( 'No items found.' ) );
}
$html = '
| ‘ . __( ‘Title’ ) . ‘ | ‘ . __( ‘Type’ ) . ‘ | ‘ . __( ‘Date’ ) . ‘ | ‘ . __( ‘Status’ ) . ‘ | |
|---|---|---|---|---|
| ‘ . esc_html( $post_types[ $post->post_type ]->labels->singular_name ) . ‘ | ‘ . esc_html( $time ) . ‘ | ‘ . esc_html( $stat ) . ‘ |
‘;
wp_send_json_success( $html );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


