WPCF7_REST_Controller::register_routes() │ public │ CF7 1.0
Метод класса: WPCF7_REST_Controller{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WPCF7_REST_Controller = new WPCF7_REST_Controller(); $WPCF7_REST_Controller->register_routes();
Код WPCF7_REST_Controller::register_routes() WPCF7 REST Controller::register routes CF7 5.8
public function register_routes() { register_rest_route( self::route_namespace, '/contact-forms', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_contact_forms' ), 'permission_callback' => static 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' => array( $this, 'create_contact_form' ), 'permission_callback' => static 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( self::route_namespace, '/contact-forms/(?P<id>\d+)', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_contact_form' ), 'permission_callback' => static 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' => array( $this, 'update_contact_form' ), 'permission_callback' => static 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' => array( $this, 'delete_contact_form' ), 'permission_callback' => static 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( self::route_namespace, '/contact-forms/(?P<id>\d+)/feedback', array( array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_feedback' ), 'permission_callback' => '__return_true', ), ) ); register_rest_route( self::route_namespace, '/contact-forms/(?P<id>\d+)/feedback/schema', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_schema' ), 'permission_callback' => '__return_true', ), 'schema' => 'wpcf7_swv_get_meta_schema', ) ); register_rest_route( self::route_namespace, '/contact-forms/(?P<id>\d+)/refill', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_refill' ), 'permission_callback' => '__return_true', ), ) ); }