namespace, '/hide-banner', array( 'methods' => $wp_rest_server::CREATABLE, 'permission_callback' => array( $this, 'permission_callback' ), 'callback' => array( $this, 'hide_banner' ), ) ); register_rest_route( $this->namespace, '/minimize-maximize-banner', array( 'methods' => $wp_rest_server::CREATABLE, 'permission_callback' => array( $this, 'permission_callback' ), 'callback' => array( $this, 'minimize_maximize_banner' ), ) ); } /** * Permission Callback * * @since 5.3.2 * @return bool */ public function permission_callback() { return is_user_logged_in() && current_user_can( 'manage_options' ); } /** * Hide Banner * @since 5.3.0 * * @param WP_REST_Request $request Rest API Request. * * @return WP_REST_Response */ public function hide_banner( $request ) { update_option( '_fma_banner_hide', 'yes' ); return new WP_REST_Response( array( 'success' => true ), 200 ); } /** * Minimize Maximize Banner * @since 5.3.0 * * @param WP_REST_Request $request Rest API Request. * * @return WP_REST_Response */ public function minimize_maximize_banner( $request ) { $action = $request->get_param( 'action' ); $action = sanitize_text_field( wp_unslash( $action ) ); update_option( '_fma_banner_minimize', $action ); return new WP_REST_Response( array( 'success' => true ), 200 ); } /** * Get Singleton Instance * @since 5.3.0 * * @return FMA_Controller */ public static function get_instance() { if ( is_null( self::$instance ) ) { self::$instance = new FMA_Controller(); } return self::$instance; } } FMA_Controller::get_instance(); endif;