if ( ! empty($_POST['data']) ) {
$data = wp_unslash( (array) $_POST['data'] );
+
+ /**
+ * Filter Heartbeat AJAX response in no-privilege environments.
+ *
+ * @since 3.6.0
+ *
+ * @param array|object $response The no-priv Heartbeat response object or array.
+ * @param array $data An array of data passed via $_POST.
+ * @param string $screen_id The screen id.
+ */
$response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id );
}
+ /**
+ * Filter Heartbeat AJAX response when no data is passed.
+ *
+ * @since 3.6.0
+ *
+ * @param array|object $response The Heartbeat response object or array.
+ * @param string $screen_id The screen id.
+ */
$response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id );
- // Allow the transport to be replaced with long-polling easily
+ /**
+ * Fires when Heartbeat ticks in no-privilege environments.
+ *
+ * Allows the transport to be easily replaced with long-polling.
+ *
+ * @since 3.6.0
+ *
+ * @param array|object $response The no-priv Heartbeat response.
+ * @param string $screen_id The screen id.
+ */
do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
// send the current time according to the server
if ( strlen( $s ) < 2 )
wp_die(); // require 2 chars for matching
- $results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) );
+ $results = get_terms( $taxonomy, array( 'name__like' => $s, 'fields' => 'names', 'hide_empty' => false ) );
echo join( $results, "\n" );
wp_die();
if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) )
wp_die( -1 );
+ /** This filter is documented in wp-admin/user-new.php */
if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) )
wp_die( -1 );
* @return die
*/
function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
- $total = (int) @$_POST['_total'];
- $per_page = (int) @$_POST['_per_page'];
- $page = (int) @$_POST['_page'];
- $url = esc_url_raw( @$_POST['_url'] );
+ $total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0;
+ $per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0;
+ $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0;
+ $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : '';
+
// JS didn't send us everything we need to know. Just die with success message
if ( !$total || !$per_page || !$page || !$url )
wp_die( time() );
wp_die( -1 );
$current = wp_get_comment_status( $comment->comment_ID );
- if ( $_POST['new'] == $current )
+ if ( isset( $_POST['new'] ) && $_POST['new'] == $current )
wp_die( time() );
check_ajax_referer( "approve-comment_$id" );
check_ajax_referer( $action );
+ if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {
+ $id = absint( $_REQUEST['p'] );
+ if ( ! empty( $id ) )
+ $post_id = $id;
+ }
+
+ if ( empty( $post_id ) )
+ wp_die( -1 );
+
$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
- if ( !current_user_can( 'edit_post', $post_id ) )
+ if ( ! current_user_can( 'edit_post', $post_id ) )
wp_die( -1 );
$wp_list_table->prepare_items();
$comment_author_url = wp_slash( $user->user_url );
$comment_content = trim($_POST['content']);
if ( current_user_can( 'unfiltered_html' ) ) {
+ if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) )
+ $_POST['_wp_unfiltered_html_comment'] = '';
+
if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
kses_remove_filters(); // start with a clean slate
kses_init_filters(); // set up the filters
if ( '' == $comment_content )
wp_die( __( 'ERROR: please type a comment.' ) );
- $comment_parent = absint($_POST['comment_ID']);
+ $comment_parent = 0;
+ if ( isset( $_POST['comment_ID'] ) )
+ $comment_parent = absint( $_POST['comment_ID'] );
$comment_auto_approved = false;
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
$position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
ob_start();
- if ( 'dashboard' == $_REQUEST['mode'] ) {
- require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
- _wp_dashboard_recent_comments_row( $comment );
+ if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) {
+ require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
+ _wp_dashboard_recent_comments_row( $comment );
+ } else {
+ if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) {
+ $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
} else {
- if ( 'single' == $_REQUEST['mode'] ) {
- $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
- } else {
- $wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
- }
- $wp_list_table->single_row( $comment );
+ $wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
}
- $comment_list_item = ob_get_contents();
- ob_end_clean();
+ $wp_list_table->single_row( $comment );
+ }
+ $comment_list_item = ob_get_clean();
$response = array(
'what' => 'comment',
if ( '' == $_POST['content'] )
wp_die( __( 'ERROR: please type a comment.' ) );
- $_POST['comment_status'] = $_POST['status'];
+ if ( isset( $_POST['status'] ) )
+ $_POST['comment_status'] = $_POST['status'];
edit_comment();
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
$comment = get_comment( $comment_id );
+ if ( empty( $comment->comment_ID ) )
+ wp_die( -1 );
ob_start();
- $wp_list_table->single_row( $comment );
- $comment_list_item = ob_get_contents();
- ob_end_clean();
+ $wp_list_table->single_row( $comment );
+ $comment_list_item = ob_get_clean();
$x = new WP_Ajax_Response();
}
}
+ /**
+ * Filter the Walker class used when adding nav menu items.
+ *
+ * @since 3.4.0
+ *
+ * @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'.
+ * @param int $menu_id The menu id, derived from $_POST['menu'].
+ */
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
if ( ! class_exists( $walker_class_name ) )
check_ajax_referer( 'autosave', 'autosavenonce' );
- $_POST['post_category'] = explode(",", $_POST['catslist']);
- if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
- unset($_POST['post_category']);
+ if ( ! empty( $_POST['catslist'] ) )
+ $_POST['post_category'] = explode( ',', $_POST['catslist'] );
+ if ( $_POST['post_type'] == 'page' || empty( $_POST['post_category'] ) )
+ unset( $_POST['post_category'] );
$data = '';
$supplemental = array();
$post_id = (int) $_POST['post_id'];
$_POST['ID'] = $_POST['post_ID'] = $post_id;
- $post = get_post($post_id);
+ $post = get_post( $post_id );
+ if ( empty( $post->ID ) || ! current_user_can( 'edit_post', $post->ID ) )
+ wp_die( __( 'You are not allowed to edit this post.' ) );
+
+ if ( 'page' == $post->post_type && ! current_user_can( 'edit_page', $post->ID ) )
+ wp_die( __( 'You are not allowed to edit this page.' ) );
+
if ( 'auto-draft' == $post->post_status )
$_POST['post_status'] = 'draft';
- if ( 'page' == $post->post_type ) {
- if ( !current_user_can('edit_page', $post->ID) )
- wp_die( __( 'You are not allowed to edit this page.' ) );
- } else {
- if ( !current_user_can('edit_post', $post->ID) )
- wp_die( __( 'You are not allowed to edit this post.' ) );
- }
-
if ( ! empty( $_POST['autosave'] ) ) {
if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) {
// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
}
if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) {
- $item = apply_filters( 'nav_menu_meta_box_object', $items[ $_POST['item-object'] ] );
+ $menus_meta_box_object = $items[ $_POST['item-object'] ];
+ /**
+ * Filter a nav menu meta box object.
+ *
+ * @since 3.0.0
+ *
+ * @param object $menus_meta_box_object A nav menu meta box object, such as Page, Post, Category, Tag, etc.
+ */
+ $item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object );
ob_start();
call_user_func_array($callback, array(
null,
$data['excerpt'] = $post['post_excerpt'];
// rename
- $data['user_ID'] = $GLOBALS['user_ID'];
+ $data['user_ID'] = get_current_user_id();
if ( isset($data['post_parent']) )
$data['parent_id'] = $data['post_parent'];
unset( $_POST['savewidgets'], $_POST['action'] );
- do_action('load-widgets.php');
- do_action('widgets.php');
- do_action('sidebar_admin_setup');
+ /**
+ * Fires early when editing the widgets displayed in sidebars.
+ *
+ * @since 2.8.0
+ */
+ do_action( 'load-widgets.php' );
+
+ /**
+ * Fires early when editing the widgets displayed in sidebars.
+ *
+ * @since 2.8.0
+ */
+ do_action( 'widgets.php' );
+
+ /**
+ * Fires early when editing the widgets displayed in sidebars.
+ *
+ * @since 2.2.0
+ */
+ do_action( 'sidebar_admin_setup' );
$id_base = $_POST['id_base'];
$widget_id = $_POST['widget-id'];
if ( $active_lock[1] != get_current_user_id() )
wp_die( 0 );
+ /**
+ * Filter the post lock window duration.
+ *
+ * @since 3.3.0
+ *
+ * @param int $interval The interval in seconds the post lock duration should last, plus 5 seconds. Default 120.
+ */
$new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 120 ) + 5 ) . ':' . $active_lock[1];
update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
wp_die( 1 );
if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
$query['post_status'] .= ',private';
+ /**
+ * Filter the arguments passed to WP_Query during an AJAX call for querying attachments.
+ *
+ * @since 3.7.0
+ *
+ * @param array $query An array of query variables. @see WP_Query::parse_query()
+ */
+ $query = apply_filters( 'ajax_query_attachments_args', $query );
$query = new WP_Query( $query );
$posts = array_map( 'wp_prepare_attachment_for_js', $query->posts );
if ( 'attachment' != $post['post_type'] )
wp_send_json_error();
+ /** This filter is documented in wp-admin/includes/media.php */
$post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
if ( isset( $post['errors'] ) ) {
$html = stripslashes_deep( $_POST['html'] );
}
+ /** This filter is documented in wp-admin/includes/media.php */
$html = apply_filters( 'media_send_to_editor', $html, $id, $attachment );
wp_send_json_success( $html );
&& ( 'audio' == $ext_type || 'video' == $ext_type ) )
$type = $ext_type;
+ /** This filter is documented in wp-admin/includes/media.php */
$html = apply_filters( $type . '_send_to_editor_url', $html, $src, $title );
wp_send_json_success( $html );
if ( ! empty($_POST['data']) ) {
$data = (array) $_POST['data'];
+
+ /**
+ * Filter the Heartbeat response received.
+ *
+ * @since 3.6.0
+ *
+ * @param array|object $response The Heartbeat response object or array.
+ * @param array $data The $_POST data sent.
+ * @param string $screen_id The screen id.
+ */
$response = apply_filters( 'heartbeat_received', $response, $data, $screen_id );
}
+ /**
+ * Filter the Heartbeat response sent.
+ *
+ * @since 3.6.0
+ *
+ * @param array|object $response The Heartbeat response object or array.
+ * @param string $screen_id The screen id.
+ */
$response = apply_filters( 'heartbeat_send', $response, $screen_id );
- // Allow the transport to be replaced with long-polling easily
+ /**
+ * Fires when Heartbeat ticks in logged-in environments.
+ *
+ * Allows the transport to be easily replaced with long-polling.
+ *
+ * @since 3.6.0
+ *
+ * @param array|object $response The Heartbeat response object or array.
+ * @param string $screen_id The screen id.
+ */
do_action( 'heartbeat_tick', $response, $screen_id );
// Send the current time according to the server