Automattic\WooCommerce\Admin\Notes
Note::add_nonce_to_action
Add a nonce to an existing note action.
Method of the class: Note{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Note = new Note(); $Note->add_nonce_to_action( $note_action_name, $nonce_action, $nonce_name );
- $note_action_name(string) (required)
- Name of action to add a nonce to.
- $nonce_action(string) (required)
- The nonce action.
- $nonce_name(string) (required)
- The nonce Name. This is used as the parameter name in the resulting URL for the action.
Note::add_nonce_to_action() Note::add nonce to action code WC 10.4.3
public function add_nonce_to_action( string $note_action_name, string $nonce_action, string $nonce_name ) {
$actions = $this->get_prop( 'actions', 'edit' );
$matching_action = null;
foreach ( $actions as $i => $action ) {
if ( $action->name === $note_action_name ) {
$matching_action =& $actions[ $i ];
}
}
if ( empty( $matching_action ) ) {
throw new \Exception( sprintf( 'Could not find action %s in note %s', $note_action_name, $this->get_name() ) );
}
$matching_action->nonce_action = $nonce_action;
$matching_action->nonce_name = $nonce_name;
$this->set_actions( $actions );
}