WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

wpcf7_rest_api_init() CF7 1.0

Хуков нет.

Возвращает

Null. Ничего.

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

wpcf7_rest_api_init();

Код wpcf7_rest_api_init() CF7 5.3

<?php
function wpcf7_rest_api_init() {
	$namespace = 'contact-form-7/v1';

	register_rest_route( $namespace,
		'/contact-forms',
		array(
			array(
				'methods' => WP_REST_Server::READABLE,
				'callback' => 'wpcf7_rest_get_contact_forms',
				'permission_callback' => function() {
					if ( current_user_can( 'wpcf7_read_contact_forms' ) ) {
						return true;
					} else {
						return new WP_Error( 'wpcf7_forbidden',
							__( "You are not allowed to access contact forms.", 'contact-form-7' ),
							array( 'status' => 403 )
						);
					}
				},
			),
			array(
				'methods' => WP_REST_Server::CREATABLE,
				'callback' => 'wpcf7_rest_create_contact_form',
				'permission_callback' => function() {
					if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
						return true;
					} else {
						return new WP_Error( 'wpcf7_forbidden',
							__( "You are not allowed to create a contact form.", 'contact-form-7' ),
							array( 'status' => 403 )
						);
					}
				},
			),
		)
	);

	register_rest_route( $namespace,
		'/contact-forms/(?P<id>\d+)',
		array(
			array(
				'methods' => WP_REST_Server::READABLE,
				'callback' => 'wpcf7_rest_get_contact_form',
				'permission_callback' => function( WP_REST_Request $request ) {
					$id = (int) $request->get_param( 'id' );

					if ( current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
						return true;
					} else {
						return new WP_Error( 'wpcf7_forbidden',
							__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
							array( 'status' => 403 )
						);
					}
				},
			),
			array(
				'methods' => WP_REST_Server::EDITABLE,
				'callback' => 'wpcf7_rest_update_contact_form',
				'permission_callback' => function( WP_REST_Request $request ) {
					$id = (int) $request->get_param( 'id' );

					if ( current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
						return true;
					} else {
						return new WP_Error( 'wpcf7_forbidden',
							__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
							array( 'status' => 403 )
						);
					}
				},
			),
			array(
				'methods' => WP_REST_Server::DELETABLE,
				'callback' => 'wpcf7_rest_delete_contact_form',
				'permission_callback' => function( WP_REST_Request $request ) {
					$id = (int) $request->get_param( 'id' );

					if ( current_user_can( 'wpcf7_delete_contact_form', $id ) ) {
						return true;
					} else {
						return new WP_Error( 'wpcf7_forbidden',
							__( "You are not allowed to access the requested contact form.", 'contact-form-7' ),
							array( 'status' => 403 )
						);
					}
				},
			),
		)
	);

	register_rest_route( $namespace,
		'/contact-forms/(?P<id>\d+)/feedback',
		array(
			array(
				'methods' => WP_REST_Server::CREATABLE,
				'callback' => 'wpcf7_rest_create_feedback',
				'permission_callback' => '__return_true',
			),
		)
	);

	register_rest_route( $namespace,
		'/contact-forms/(?P<id>\d+)/refill',
		array(
			array(
				'methods' => WP_REST_Server::READABLE,
				'callback' => 'wpcf7_rest_get_refill',
				'permission_callback' => '__return_true',
			),
		)
	);
}