get_comments

Definition:
function get_comments( $args = '' ) {}

Retrieve a list of comments.
The comment list can be for the blog as a whole or for an individual post.

Parameters

  • mixed $args: Optional. Array or string of options to override defaults.

Return values

returns:List of comments.

Source code

function get_comments( $args = '' ) {

	$query = new WP_Comment_Query;

	return $query->query( $args );

}

1280

get_commentdata

Definition:
function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {}

Retrieve an array of comment data about comment $comment_ID.

Parameters

  • int $comment_ID: The ID of the comment
  • int $no_cache: Whether to use the cache (cast to bool)
  • bool $include_unapproved: Whether to include unapproved comments

Return values

returns:The comment data

Source code

function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {

	_deprecated_function( __FUNCTION__, '2.7', 'get_comment()' );

	return get_comment($comment_ID, ARRAY_A);

}

1278

get_comment

Definition:
function &get_comment(&$comment, $output = OBJECT) {}

Retrieves comment data given a comment ID or comment object.
If an object is passed then the comment data will be cached and then returned after being passed through a filter. If the comment is empty, then the global comment variable will be used, if it is set.

Parameters

  • object|string|int $comment: Comment to retrieve.
  • string $output: Optional. OBJECT or ARRAY_A or ARRAY_N constants.
  • &$comment

Return values

returns:Depends on $output value.

Defined filters

  • get_comment
    apply_filters('get_comment', $_comment)

Source code

function &get_comment(&$comment, $output = OBJECT) {

	global $wpdb;

	$null = null;



	if ( empty($comment) ) {

		if ( isset($GLOBALS['comment']) )

			$_comment = & $GLOBALS['comment'];

		else

			$_comment = null;

	} elseif ( is_object($comment) ) {

		wp_cache_add($comment->comment_ID, $comment, 'comment');

		$_comment = $comment;

	} else {

		if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) {

			$_comment = & $GLOBALS['comment'];

		} elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) {

			$_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment));

			if ( ! $_comment )

				return $null;

			wp_cache_add($_comment->comment_ID, $_comment, 'comment');

		}

	}



	$_comment = apply_filters('get_comment', $_comment);



	if ( $output == OBJECT ) {

		return $_comment;

	} elseif ( $output == ARRAY_A ) {

		$__comment = get_object_vars($_comment);

		return $__comment;

	} elseif ( $output == ARRAY_N ) {

		$__comment = array_values(get_object_vars($_comment));

		return $__comment;

	} else {

		return $_comment;

	}

}

1276

get_column_headers

Definition:
function get_column_headers( $screen ) {}

Get the column headers for a screen

Parameters

  • string|object $screen: The screen you want the headers for

Return values

returns:Containing the headers in the format id => UI String

Defined filters

  • manage_$screen->id_columns
    apply_filters( 'manage_' . $screen->id . '_columns', array()

Source code

function get_column_headers( $screen ) {

	if ( is_string( $screen ) )

		$screen = convert_to_screen( $screen );



	global $_wp_column_headers;



	if ( !isset( $_wp_column_headers[ $screen->id ] ) ) {

		$_wp_column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() );

	}



	return $_wp_column_headers[ $screen->id ];

}

1274

get_cli_args

Definition:
function get_cli_args( $param, $required = false ) {}

Returns value of command line params.
Exits when a required param is not set.

Parameters

  • string $param
  • bool $required

Source code

function get_cli_args( $param, $required = false ) {

	$args = $_SERVER['argv'];



	$out = array();



	$last_arg = null;

	$return = null;



	$il = sizeof( $args );



	for ( $i = 1, $il; $i < $il; $i++ ) {

		if ( (bool) preg_match( "/^--(.+)/", $args[$i], $match ) ) {

			$parts = explode( "=", $match[1] );

			$key = preg_replace( "/[^a-z0-9]+/", "", $parts[0] );



			if ( isset( $parts[1] ) ) {

				$out[$key] = $parts[1];

			} else {

				$out[$key] = true;

			}



			$last_arg = $key;

		} else if ( (bool) preg_match( "/^-([a-zA-Z0-9]+)/", $args[$i], $match ) ) {

			for ( $j = 0, $jl = strlen( $match[1] ); $j < $jl; $j++ ) {

				$key = $match[1]{$j};

				$out[$key] = true;

			}



			$last_arg = $key;

		} else if ( $last_arg !== null ) {

			$out[$last_arg] = $args[$i];

		}

	}



	// Check array for specified param

	if ( isset( $out[$param] ) ) {

		// Set return value

		$return = $out[$param];

	}



	// Check for missing required param

	if ( !isset( $out[$param] ) && $required ) {

		// Display message and exit

		echo "\"$param\" parameter is required but was not specified\n";

		exit();

	}



	return $return;

}

1272