WPCF7_REST_Controller::get_contact_forms()publicCF7 1.0

Метод класса: WPCF7_REST_Controller{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$WPCF7_REST_Controller = new WPCF7_REST_Controller();
$WPCF7_REST_Controller->get_contact_forms( $request );
$request(WP_REST_Request) (обязательный)
-

Код WPCF7_REST_Controller::get_contact_forms() CF7 5.9.3

public function get_contact_forms( WP_REST_Request $request ) {
	$args = array();

	$per_page = $request->get_param( 'per_page' );

	if ( null !== $per_page ) {
		$args['posts_per_page'] = (int) $per_page;
	}

	$offset = $request->get_param( 'offset' );

	if ( null !== $offset ) {
		$args['offset'] = (int) $offset;
	}

	$order = $request->get_param( 'order' );

	if ( null !== $order ) {
		$args['order'] = (string) $order;
	}

	$orderby = $request->get_param( 'orderby' );

	if ( null !== $orderby ) {
		$args['orderby'] = (string) $orderby;
	}

	$search = $request->get_param( 'search' );

	if ( null !== $search ) {
		$args['s'] = (string) $search;
	}

	$items = WPCF7_ContactForm::find( $args );

	$response = array();

	foreach ( $items as $item ) {
		$response[] = array(
			'id' => $item->id(),
			'hash' => $item->hash(),
			'slug' => $item->name(),
			'title' => $item->title(),
			'locale' => $item->locale(),
		);
	}

	return rest_ensure_response( $response );
}