includes/controls.php
I can’t see any easy way to override the functions below, there is a data object at the top of the document but not all inputs are checked against this and no way to inject own values from elsewhere. These changes will need to be re-applied after every update.
function yesno($name) { $value = isset($this->data[$name]) ? (int) $this->data[$name] : 0; //mychange if($name == 'options_wp_users') $value = 1; echo '<select style="width: 60px" name="options[' . esc_attr($name) . ']">'; echo '<option value="0"'; if ($value == 0) { echo ' selected'; } echo '>', __('No', 'newsletter'), '</option>'; echo '<option value="1"'; if ($value == 1) { echo ' selected'; } echo '>', __('Yes', 'newsletter'), '</option>'; echo '</select> '; }
function select($name, $options, $first = null) { $value = $this->get_value($name); //mychange if ($name == 'options_status') { $value = 'C'; } echo '<select id="options-' . esc_attr($name) . '" name="options[' . esc_attr($name) . ']">'; if (!empty($first)) { echo '<option value="">' . esc_html($first) . '</option>'; } foreach ($options as $key => $label) { echo '<option value="' . esc_attr($key) . '"'; if ($value == $key) echo ' selected'; echo '>' . esc_html($label) . '</option>'; } echo '</select>'; }
function select2($name, $options, $first = null, $multiple = false, $style = null, $placeholder = '') { if ($multiple) { $option_name = "options[" . esc_attr($name) . "][]"; } else { $option_name = "options[" . esc_attr($name) . "]"; } if (is_null($style)) { $style = 'width: 100%'; } $value = $this->get_value($name); //mychange if ($name == 'options_lists') { $value = 1; } echo '<select id="options-', esc_attr($name), '" name="', $option_name, '" style="', $style, '"', ($multiple ? ' multiple' : ''), '>'; if (!empty($first)) { echo '<option value="">' . esc_html($first) . '</option>'; } foreach ($options as $key => $data) { echo '<option value="' . esc_attr($key) . '"'; if (is_array($value) && in_array($key, $value) || $value == $key) echo ' selected'; echo '>' . esc_html($data) . '</option>'; } echo '</select>'; echo '<script>jQuery("#options-' . esc_attr($name) . '").select2({placeholder: "', esc_js($placeholder), '"});</script>'; }