| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template: Fields Group — status dropdown partial. |
| 4 |
* |
| 5 |
* Renders the status (active/inactive) select field for a fields group. |
| 6 |
* |
| 7 |
* @var array<string, mixed> $settings Field settings. |
| 8 |
* @var mixed $value Field value. |
| 9 |
* @var string $module_id Module ID. |
| 10 |
* @var bool $inside_flexible Whether group is inside flexible_content. |
| 11 |
* @var array<string, mixed> $args Extra args when inside flexible_content. |
| 12 |
* |
| 13 |
* @package Merchant |
| 14 |
* @since 2.2.5 |
| 15 |
*/ |
| 16 |
|
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Filter the status field configuration. |
| 23 |
* |
| 24 |
* @since 1.9.12 |
| 25 |
* |
| 26 |
* @param array $status_field Status field configuration. |
| 27 |
* @param array $settings Parent group settings. |
| 28 |
* @param mixed $value Group value. |
| 29 |
* @param string $module_id Module ID. |
| 30 |
*/ |
| 31 |
$status_field = apply_filters( |
| 32 |
'merchant_group_status_field', |
| 33 |
array( |
| 34 |
'id' => $settings['id'] . '_status', |
| 35 |
'type' => 'select', |
| 36 |
'title' => esc_html__( 'Status', 'merchant' ), |
| 37 |
'options' => array( |
| 38 |
'inactive' => esc_html__( 'Inactive', 'merchant' ), |
| 39 |
'active' => esc_html__( 'Active', 'merchant' ), |
| 40 |
), |
| 41 |
'default' => isset( $settings['default'] ) ? $settings['default'] : 'active', |
| 42 |
), |
| 43 |
$settings, |
| 44 |
$value, |
| 45 |
$module_id |
| 46 |
); |
| 47 |
|
| 48 |
if ( $inside_flexible ) { |
| 49 |
Merchant_Field_Fields_Group::render_sub_field( |
| 50 |
$status_field, |
| 51 |
isset( $args['value'][ $settings['id'] ][ $status_field['id'] ] ) ? $args['value'][ $settings['id'] ][ $status_field['id'] ] : $status_field['default'] ?? '', |
| 52 |
"name=\"merchant[{$status_field['id']}]", |
| 53 |
"name=\"merchant[{$args['id']}][{$args['option_key']}][{$settings['id']}][{$status_field['id']}]\" data-name=\"merchant[{$args['id']}][0][{$settings['id']}][{$status_field['id']}]", |
| 54 |
$module_id |
| 55 |
); |
| 56 |
} else { |
| 57 |
Merchant_Field_Fields_Group::render_sub_field( |
| 58 |
$status_field, |
| 59 |
isset( $value[ $status_field['id'] ] ) ? $value[ $status_field['id'] ] : '', |
| 60 |
"name=\"merchant[{$status_field['id']}]", |
| 61 |
"name=\"merchant[{$settings['id']}][{$status_field['id']}]", |
| 62 |
$module_id |
| 63 |
); |
| 64 |
} |
| 65 |
|