Automattic\WooCommerce\Admin\Notes

Note::add_nonce_to_action()publicWC 1.0

Add a nonce to an existing note action.

Метод класса: Note{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$Note = new Note();
$Note->add_nonce_to_action( $note_action_name, $nonce_action, $nonce_name );
$note_action_name(строка) (обязательный)
Name of action to add a nonce to.
$nonce_action(строка) (обязательный)
The nonce action.
$nonce_name(строка) (обязательный)
The nonce Name. This is used as the paramater name in the resulting URL for the action.

Код Note::add_nonce_to_action() WC 8.7.0

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 );
}