Automattic\WooCommerce\Admin\Notes
Note::add_action
Add an action to the note
Метод класса: Note{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Note = new Note(); $Note->add_action( $name, $label, $url, $status, $primary, $actioned_text );
- $name(строка) (обязательный)
- Action name (not presented to user).
- $label(строка) (обязательный)
- Action label (presented as button label).
- $url(строка)
- Action URL, if navigation needed. Optional.
По умолчанию:'' - $status(строка)
- Status to transition parent Note to upon click.
По умолчанию:'actioned' - $primary(true|false)
- Deprecated since version 3.4.0.
По умолчанию:false - $actioned_text(строка)
- The label to display after the note has been actioned but before it is dismissed in the UI.
По умолчанию:''
Код Note::add_action() Note::add action WC 11.0.1
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 );
}