Server IP : 172.67.216.182 / Your IP : 104.23.175.239 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/www.houseboatjetty.com/wp-content/plugins/woocommerce/src/Admin/API/ |
Upload File : |
<?php /** * REST API Admin Note Action controller * * Handles requests to the admin note action endpoint. */ namespace Automattic\WooCommerce\Admin\API; defined( 'ABSPATH' ) || exit; use Automattic\WooCommerce\Admin\Notes\Note; use \Automattic\WooCommerce\Admin\Notes\Notes as NotesFactory; /** * REST API Admin Note Action controller class. * * @internal * @extends WC_REST_CRUD_Controller */ class NoteActions extends Notes { /** * Register the routes for admin notes. */ public function register_routes() { register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<note_id>[\d-]+)/action/(?P<action_id>[\d-]+)', array( 'args' => array( 'note_id' => array( 'description' => __( 'Unique ID for the Note.', 'woocommerce' ), 'type' => 'integer', ), 'action_id' => array( 'description' => __( 'Unique ID for the Note Action.', 'woocommerce' ), 'type' => 'integer', ), ), array( 'methods' => \WP_REST_Server::EDITABLE, 'callback' => array( $this, 'trigger_note_action' ), // @todo - double check these permissions for taking note actions. 'permission_callback' => array( $this, 'get_item_permissions_check' ), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } /** * Trigger a note action. * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Request|WP_Error */ public function trigger_note_action( $request ) { $note = NotesFactory::get_note( $request->get_param( 'note_id' ) ); if ( ! $note ) { return new \WP_Error( 'woocommerce_note_invalid_id', __( 'Sorry, there is no resource with that ID.', 'woocommerce' ), array( 'status' => 404 ) ); } $note->set_is_read( true ); $note->save(); $triggered_action = NotesFactory::get_action_by_id( $note, $request->get_param( 'action_id' ) ); if ( ! $triggered_action ) { return new \WP_Error( 'woocommerce_note_action_invalid_id', __( 'Sorry, there is no resource with that ID.', 'woocommerce' ), array( 'status' => 404 ) ); } $triggered_note = NotesFactory::trigger_note_action( $note, $triggered_action ); $data = $triggered_note->get_data(); $data = $this->prepare_item_for_response( $data, $request ); $data = $this->prepare_response_for_collection( $data ); return rest_ensure_response( $data ); } }