Astra_Target_Rules_Fields::target_rule_settings_field( string $name, string $settings, string $value )
Function Name: target_rule_settings_field.
Description
Function Description: Function to handle new input type.
Parameters
- $name
-
(string) (Required) string parameter.
- $settings
-
(string) (Required) string parameter.
- $value
-
(string) (Required) string parameter.
Source
File: classes/modules/target-rule/class-astra-target-rules-fields.php
public static function target_rule_settings_field( $name, $settings, $value ) { $input_name = $name; $type = isset( $settings['type'] ) ? $settings['type'] : 'target_rule'; $class = isset( $settings['class'] ) ? $settings['class'] : ''; $rule_type = isset( $settings['rule_type'] ) ? $settings['rule_type'] : 'target_rule'; $add_rule_label = isset( $settings['add_rule_label'] ) ? $settings['add_rule_label'] : __( 'Add Rule', 'astra-addon' ); $saved_values = $value; $output = ''; if ( isset( self::$location_selection ) || empty( self::$location_selection ) ) { self::$location_selection = self::get_location_selections(); } $selection_options = self::$location_selection; /* WP Template Format */ $output .= '<script type="text/html" id="tmpl-astra-target-rule-' . $rule_type . '-condition">'; $output .= '<div class="astra-target-rule-condition ast-target-rule-{{data.id}}" data-rule="{{data.id}}" >'; $output .= '<span class="target_rule-condition-delete dashicons dashicons-dismiss"></span>'; /* Condition Selection */ $output .= '<div class="target_rule-condition-wrap" >'; $output .= '<select name="' . esc_attr( $input_name ) . '[rule][{{data.id}}]" class="target_rule-condition form-control ast-input">'; $output .= '<option value="">' . __( 'Select', 'astra-addon' ) . '</option>'; foreach ( $selection_options as $group => $group_data ) { $output .= '<optgroup label="' . $group_data['label'] . '">'; foreach ( $group_data['value'] as $opt_key => $opt_value ) { $output .= '<option value="' . $opt_key . '">' . $opt_value . '</option>'; } $output .= '</optgroup>'; } $output .= '</select>'; $output .= '</div>'; $output .= '</div> <!-- astra-target-rule-condition -->'; /* Specific page selection */ $output .= '<div class="target_rule-specific-page-wrap" style="display:none">'; $output .= '<select name="' . esc_attr( $input_name ) . '[specific][]" class="target-rule-select2 target_rule-specific-page form-control ast-input " multiple="multiple">'; $output .= '</select>'; $output .= '</div>'; $output .= '</script>'; /* Wrapper Start */ $output .= '<div class="ast-target-rule-wrapper ast-target-rule-' . $rule_type . '-on-wrap" data-type="' . $rule_type . '">'; // $output .= '<input type="hidden" class="form-control ast-input ast-target_rule-input" name="' . esc_attr( $input_name ) . '" value=' . $value . ' />'; $output .= '<div class="ast-target-rule-selector-wrapper ast-target-rule-' . $rule_type . '-on">'; $output .= self::generate_target_rule_selector( $rule_type, $selection_options, $input_name, $saved_values, $add_rule_label ); $output .= '</div>'; /* Wrapper end */ $output .= '</div>'; echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped }
Expand full source code Collapse full source code View on Trac