WP_CLI\Fetchers

Comment{}WP-CLI 1.0

Fetch a WordPress comment based on one of its attributes.

Хуков нет.

Использование

$Comment = new Comment();
// use class methods

Методы

  1. public get( $arg )

Код Comment{} WP-CLI 2.8.0-alpha

class Comment extends Base {

	/**
	 * The message to display when an item is not found.
	 *
	 * @var string
	 */
	protected $msg = 'Could not find the comment with ID %d.';

	/**
	 * Get a comment object by ID
	 *
	 * @param string $arg The raw CLI argument.
	 * @return WP_Comment|array|false The item if found; false otherwise.
	 */
	public function get( $arg ) {
		$comment_id = (int) $arg;
		$comment    = get_comment( $comment_id );

		if ( null === $comment ) {
			return false;
		}

		return $comment;
	}
}