_wp_dashboard_control_callback

Definition:
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {}

Parameters

  • $dashboard
  • $meta_box

Source code

function _wp_dashboard_control_callback( $dashboard, $meta_box ) {

	echo '<form action="" method="post" class="dashboard-widget-control-form">';

	wp_dashboard_trigger_widget_control( $meta_box['id'] );

	echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';

	submit_button( __('Submit') );

	echo '</form>';

}

4389

_wp_comment_row

Definition:
function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {}

Parameters

  • unknown_type $comment_id
  • unknown_type $mode
  • unknown_type $comment_status
  • unknown_type $checkbox
  • $from_ajax

Defined filters

  • get_comment_author
    apply_filters( 'get_comment_author', $parent->comment_author )
  • comment_edit_pre
    apply_filters('comment_edit_pre', $comment->comment_content)
  • comment_row_actions
    apply_filters( 'comment_row_actions', array_filter($actions)

Defined actions

  • manage_comments_custom_column
    do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );

Source code

function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {

	global $comment, $post, $_comment_pending_count;

	$comment = get_comment( $comment_id );

	$post = get_post($comment->comment_post_ID);

	$the_comment_status = wp_get_comment_status($comment->comment_ID);

	$post_type_object = get_post_type_object($post->post_type);

	$user_can = current_user_can($post_type_object->cap->edit_post, $post->ID);



	$comment_url = esc_url(get_comment_link($comment->comment_ID));

	$author_url = get_comment_author_url();

	if ( 'http://' == $author_url )

		$author_url = '';

	$author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url);

	if ( strlen($author_url_display) > 50 )

		$author_url_display = substr($author_url_display, 0, 49) . '...';



	$ptime = date('G', strtotime( $comment->comment_date ) );

	if ( ( abs(time() - $ptime) ) < 86400 )

		$ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );

	else

		$ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );



	if ( $user_can ) {

		$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );

		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );



		$approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );

		$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );

		$spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

	}



	echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";

	$columns = get_column_headers('edit-comments');

	$hidden = get_hidden_columns('edit-comments');

	foreach ( $columns as $column_name => $column_display_name ) {

		$class = "class=\"$column_name column-$column_name\"";



		$style = '';

		if ( in_array($column_name, $hidden) )

			$style = ' style="display:none;"';



		$attributes = "$class$style";



		switch ($column_name) {

			case 'cb':

				if ( !$checkbox ) break;

				echo '<th scope="row" class="check-column">';

				if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";

				echo '</th>';

				break;

			case 'comment':

				echo "<td $attributes>";

				echo '<div id="submitted-on">';

				/* translators: 2: comment date, 3: comment time */

				printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url,

					/* translators: comment date format. See http://php.net/date */ get_comment_date( __('Y/m/d') ),

					/* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );



				if ( $comment->comment_parent ) {

					$parent = get_comment( $comment->comment_parent );

					$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );

					$name = apply_filters( 'get_comment_author', $parent->comment_author ); // there's no API function for this

					printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );

				}



				echo '</div>';

				comment_text();

				if ( $user_can ) { ?>

				<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">

				<textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea>

				<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>

				<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>

				<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>

				<div class="comment_status"><?php echo $comment->comment_approved; ?></div>

				</div>

				<?php

				}



				if ( $user_can ) {

					// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash

					$actions = array(

						'approve' => '', 'unapprove' => '',

						'reply' => '',

						'quickedit' => '',

						'edit' => '',

						'spam' => '', 'unspam' => '',

						'trash' => '', 'untrash' => '', 'delete' => ''

					);



					if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments

						if ( 'approved' == $the_comment_status )

							$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';

						else if ( 'unapproved' == $the_comment_status )

							$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';

					} else {

						$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';

						$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';

					}



					if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {

						$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';

					} elseif ( 'spam' == $the_comment_status ) {

						$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';

					} elseif ( 'trash' == $the_comment_status ) {

						$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';

					}



					if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {

						$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';

					} else {

						$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';

					}



					if ( 'trash' != $the_comment_status ) {

						$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';

						$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.esc_attr__('Quick Edit').'" href="#">' . __('Quick&nbsp;Edit') . '</a>';

						if ( 'spam' != $the_comment_status )

							$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';

					}



					$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );



					$i = 0;

					echo '<div class="row-actions">';

					foreach ( $actions as $action => $link ) {

						++$i;

						( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';



						// Reply and quickedit need a hide-if-no-js span when not added with ajax

						if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )

							$action .= ' hide-if-no-js';

						elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) {

							if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))

								$action .= ' approve';

							else

								$action .= ' unapprove';

						}



						echo "<span class='$action'>$sep$link</span>";

					}

					echo '</div>';

				}



				echo '</td>';

				break;

			case 'author':

				echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';

				if ( !empty($author_url) )

					echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";

				if ( $user_can ) {

					if ( !empty($comment->comment_author_email) ) {

						comment_author_email_link();

						echo '<br />';

					}

					echo '<a href="edit-comments.php?s=';

					comment_author_IP();

					echo '&amp;mode=detail';

					if ( 'spam' == $comment_status )

						echo '&amp;comment_status=spam';

					echo '">';

					comment_author_IP();

					echo '</a>';

				} //current_user_can

				echo '</td>';

				break;

			case 'date':

				echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';

				break;

			case 'response':

				if ( 'single' !== $mode ) {

					if ( isset( $_comment_pending_count[$post->ID] ) ) {

						$pending_comments = $_comment_pending_count[$post->ID];

					} else {

						$_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) );

						$pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];

					}

					if ( $user_can ) {

						$post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";

						$post_link .= get_the_title($post->ID) . '</a>';

					} else {

						$post_link = get_the_title($post->ID);

					}

					echo "<td $attributes>\n";

					echo '<div class="response-links"><span class="post-com-count-wrapper">';

					echo $post_link . '<br />';

					$pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) ));

					if ( $pending_comments )

						echo '<strong>';

					comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');

					if ( $pending_comments )

						echo '</strong>';

					echo '</span> ';

					echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";

					echo '</div>';

					if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )

						echo $thumb;

					echo '</td>';

				}

				break;

			default:

				echo "<td $attributes>\n";

				do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );

				echo "</td>\n";

				break;

		}

	}

4387

_wp_ajax_menu_quick_search

Definition:
function _wp_ajax_menu_quick_search( $request = array() {}

Prints the appropriate response to a menu quick search.

Parameters

  • array $request: The unsanitized request values.

Source code

function _wp_ajax_menu_quick_search( $request = array() ) {

	$args = array();

	$type = isset( $request['type'] ) ? $request['type'] : '';

	$object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';

	$query = isset( $request['q'] ) ? $request['q'] : '';

	$response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json';



	if ( 'markup' == $response_format ) {

		$args['walker'] = new Walker_Nav_Menu_Checklist;

	}



	if ( 'get-post-item' == $type ) {

		if ( post_type_exists( $object_type ) ) {

			if ( isset( $request['ID'] ) ) {

				$object_id = (int) $request['ID'];

				if ( 'markup' == $response_format ) {

					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );

				} elseif ( 'json' == $response_format ) {

					$post_obj = get_post( $object_id );

					echo json_encode(

						array(

							'ID' => $object_id,

							'post_title' => get_the_title( $object_id ),

							'post_type' => get_post_type( $object_id ),

						)

					);

					echo "\n";

				}

			}

		} elseif ( taxonomy_exists( $object_type ) ) {

			if ( isset( $request['ID'] ) ) {

				$object_id = (int) $request['ID'];

				if ( 'markup' == $response_format ) {

					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );

				} elseif ( 'json' == $response_format ) {

					$post_obj = get_term( $object_id, $object_type );

					echo json_encode(

						array(

							'ID' => $object_id,

							'post_title' => $post_obj->name,

							'post_type' => $object_type,

						)

					);

					echo "\n";

				}

			}



		}





	} elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {

		if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {

			query_posts(array(

				'posts_per_page' => 10,

				'post_type' => $matches[2],

				's' => $query,

			));

			if ( ! have_posts() )

				return;

			while ( have_posts() ) {

				the_post();

				if ( 'markup' == $response_format ) {

					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( get_the_ID() ) ) ), 0, (object) $args );

				} elseif ( 'json' == $response_format ) {

					echo json_encode(

						array(

							'ID' => get_the_ID(),

							'post_title' => get_the_title(),

							'post_type' => get_post_type(),

						)

					);

					echo "\n";

				}

			}

		} elseif ( 'taxonomy' == $matches[1] ) {

			$terms = get_terms( $matches[2], array(

				'name__like' => $query,

				'number' => 10,

			));

			if ( empty( $terms ) || is_wp_error( $terms ) )

				return;

			foreach( (array) $terms as $term ) {

				if ( 'markup' == $response_format ) {

					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );

				} elseif ( 'json' == $response_format ) {

					echo json_encode(

						array(

							'ID' => $term->term_id,

							'post_title' => $term->name,

							'post_type' => $matches[2],

						)

					);

					echo "\n";

				}

			}

		}

	}

}

4385

_wp_ajax_delete_comment_response

Definition:
function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {}

Sends back current comment total and new page links if they need to be updated.
Contrary to normal success AJAX response ("1"), die with time() on success.

Parameters

  • int $comment_id
  • $delta

Source code

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'] );

	// JS didn't send us everything we need to know. Just die with success message

	if ( !$total || !$per_page || !$page || !$url )

		die( (string) time() );



	$total += $delta;

	if ( $total < 0 )

		$total = 0;



	// Only do the expensive stuff on a page-break, and about 1 other time per page

	if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {

		$post_id = 0;

		$status = 'total_comments'; // What type of comment count are we looking for?

		$parsed = parse_url( $url );

		if ( isset( $parsed['query'] ) ) {

			parse_str( $parsed['query'], $query_vars );

			if ( !empty( $query_vars['comment_status'] ) )

				$status = $query_vars['comment_status'];

			if ( !empty( $query_vars['p'] ) )

				$post_id = (int) $query_vars['p'];

		}



		$comment_count = wp_count_comments($post_id);



		if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count

			$total = $comment_count->$status;

			// else use the decremented value from above

	}



	$time = time(); // The time since the last comment count



	$x = new WP_Ajax_Response( array(

		'what' => 'comment',

		'id' => $comment_id, // here for completeness - not used

		'supplemental' => array(

			'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ),

			'total_pages' => ceil( $total / $per_page ),

			'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),

			'total' => $total,

			'time' => $time

		)

	) );

	$x->send();

}

4383

_wp_ajax_add_hierarchical_term

Definition:
function _wp_ajax_add_hierarchical_term() {}

Source code

function _wp_ajax_add_hierarchical_term() {

	$action = $_POST['action'];

	$taxonomy = get_taxonomy(substr($action, 4));

	check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );

	if ( !current_user_can( $taxonomy->cap->edit_terms ) )

		die('-1');

	$names = explode(',', $_POST['new'.$taxonomy->name]);

	$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;

	if ( 0 > $parent )

		$parent = 0;

	if ( $taxonomy->name == 'category' )

		$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();

	else

		$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();

	$checked_categories = array_map( 'absint', (array) $post_category );

	$popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);



	foreach ( $names as $cat_name ) {

		$cat_name = trim($cat_name);

		$category_nicename = sanitize_title($cat_name);

		if ( '' === $category_nicename )

			continue;

		if ( !($cat_id = term_exists($cat_name, $taxonomy->name, $parent)) ) {

			$new_term = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent));

			$cat_id = $new_term['term_id'];

		}

		$checked_categories[] = $cat_id;

		if ( $parent ) // Do these all at once in a second

			continue;

		$category = get_term( $cat_id, $taxonomy->name );

		ob_start();

			wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids ));

		$data = ob_get_contents();

		ob_end_clean();

		$add = array(

			'what' => $taxonomy->name,

			'id' => $cat_id,

			'data' => str_replace( array("\n", "\t"), '', $data),

			'position' => -1

		);

	}



	if ( $parent ) { // Foncy - replace the parent and all its children

		$parent = get_term( $parent, $taxonomy->name );

		$term_id = $parent->term_id;



		while ( $parent->parent ) { // get the top parent

			$parent = &get_term( $parent->parent, $taxonomy->name );

			if ( is_wp_error( $parent ) )

				break;

			$term_id = $parent->term_id;

		}



		ob_start();

			wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));

		$data = ob_get_contents();

		ob_end_clean();

		$add = array(

			'what' => $taxonomy->name,

			'id' => $term_id,

			'data' => str_replace( array("\n", "\t"), '', $data),

			'position' => -1

		);

	}



	ob_start();

		wp_dropdown_categories( array(

			'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',

			'hierarchical' => 1, 'show_option_none' => '&mdash; '.$taxonomy->labels->parent_item.' &mdash;'

		) );

	$sup = ob_get_contents();

	ob_end_clean();

	$add['supplemental'] = array( 'newcat_parent' => $sup );



	$x = new WP_Ajax_Response( $add );

	$x->send();

}

4381