Automattic\WooCommerce\Admin\Notes
Note::add_action
Add an action to the note
Method of the class: Note{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Note = new Note(); $Note->add_action( $name, $label, $url, $status, $primary, $actioned_text );
- $name(string) (required)
- Action name (not presented to user).
- $label(string) (required)
- Action label (presented as button label).
- $url(string)
- Action URL, if navigation needed. Optional.
Default:'' - $status(string)
- Status to transition parent Note to upon click.
Default:'actioned' - $primary(true|false)
- Deprecated since version 3.4.0.
Default:false - $actioned_text(string)
- The label to display after the note has been actioned but before it is dismissed in the UI.
Default:''
Note::add_action() Note::add action code WC 10.6.2
public function add_action(
$name,
$label,
$url = '',
$status = self::E_WC_ADMIN_NOTE_ACTIONED,
$primary = false,
$actioned_text = ''
) {
$name = wc_clean( $name );
$label = wc_clean( $label );
$query = esc_url_raw( $url );
$status = wc_clean( $status );
$actioned_text = wc_clean( $actioned_text );
if ( empty( $name ) ) {
$this->error( 'admin_note_invalid_data', __( 'The admin note action name prop cannot be empty.', 'woocommerce' ) );
}
if ( empty( $label ) ) {
$this->error( 'admin_note_invalid_data', __( 'The admin note action label prop cannot be empty.', 'woocommerce' ) );
}
$action = array(
'name' => $name,
'label' => $label,
'query' => $query,
'status' => $status,
'actioned_text' => $actioned_text,
'nonce_name' => null,
'nonce_action' => null,
);
$note_actions = $this->get_prop( 'actions', 'edit' );
$note_actions[] = (object) $action;
$this->set_prop( 'actions', $note_actions );
}