/** * Initialize the slider renderer by retrieving the id and settings from the passed data. * * @since 4.0.0 * * @param array $data The data of the slider. */ public function __construct($data) { $this->data = $data; $this->id = $this->data['id']; $this->settings = $this->data['settings']; $this->default_settings = BQW_SliderPro_Settings::getSettings(); }
<tbody class="breakpoint-settings"> <?php if (isset($breakpoint_settings) && !empty($breakpoint_settings)) { foreach ($breakpoint_settings as $setting_name => $setting_value) { if ($setting_name !== 'breakpoint_width') { echo $this->create_breakpoint_setting($setting_name, $setting_value); } } } ?> </tbody> </table> <div class="add-breakpoint-setting-group"> <a class="button add-breakpoint-setting" href="#"><?php _e('Add Setting', 'sliderpro'); ?> <span class="add-breakpoint-setting-arrow">▼</span></a> <ul class="breakpoint-setting-name"> <?php $default_breakpoint_settings = BQW_SliderPro_Settings::getBreakpointSettings(); foreach ($default_breakpoint_settings as $setting_name) { if ($setting_name !== 'breakpoint_width') { $setting = BQW_SliderPro_Settings::getSettings($setting_name); echo '<li><a href="#" data-type="' . $setting_name . '">' . $setting['label'] . '</a></li>'; } } ?> </ul> </div> </div>
/** * Return the HTML markup for the breakpoint setting. * * Generates a unique number that will be attributed to * the label and to the input/select field. * * @since 4.0.0 * * @param string $name The name of the setting. * @param mixed $value The value of the setting. If false, the default setting value will be assigned. * @return string The HTML markup for the setting. */ public function create_breakpoint_setting($name, $value) { $setting = BQW_SliderPro_Settings::getSettings($name); $setting_value = $value !== false ? $value : $setting['default_value']; $setting_html = ''; $uid = mt_rand(); if ($setting['type'] === 'number' || $setting['type'] === 'mixed') { $setting_html = ' <tr> <td> <label data-info="' . $setting['description'] . '" for="breakpoint-' . $name . '-' . $uid . '">' . $setting['label'] . '</label> </td> <td class="setting-cell"> <input id="breakpoint-' . $name . '-' . $uid . '" class="breakpoint-setting" type="text" name="' . $name . '" value="' . esc_attr($setting_value) . '" /> <span class="remove-breakpoint-setting"></span> </td> </tr>'; } else { if ($setting['type'] === 'boolean') { $setting_html = ' <tr> <td> <label data-info="' . $setting['description'] . '" for="breakpoint-' . $name . '-' . $uid . '">' . $setting['label'] . '</label> </td> <td class="setting-cell"> <input id="breakpoint-' . $name . '-' . $uid . '" class="breakpoint-setting" type="checkbox" name="' . $name . '"' . ($setting_value === true ? ' checked="checked"' : '') . ' /> <span class="remove-breakpoint-setting"></span> </td> </tr>'; } else { if ($setting['type'] === 'select') { $setting_html = ' <tr> <td> <label data-info="' . $setting['description'] . '" for="breakpoint-' . $name . '-' . $uid . '">' . $setting['label'] . '</label> </td> <td class="setting-cell"> <select id="breakpoint-' . $name . '-' . $uid . '" class="breakpoint-setting" name="' . $name . '">'; foreach ($setting['available_values'] as $value_name => $value_label) { $setting_html .= '<option value="' . $value_name . '"' . ($setting_value == $value_name ? ' selected="selected"' : '') . '>' . $value_label . '</option>'; } $setting_html .= ' </select> <span class="remove-breakpoint-setting"></span> </td> </tr>'; } } } return $setting_html; }
/** * Initialize the slider renderer by retrieving the id and settings from the passed data. * * @since 4.0.0 * * @param array $data The data of the slider. */ public function __construct($data) { $this->data = $data; $this->id = $this->data['id']; $this->name = $this->data['name']; $this->settings = $this->data['settings']; $this->default_settings = BQW_SliderPro_Settings::getSettings(); $this->idAttribute = isset($this->settings['use_name_as_id']) && $this->settings['use_name_as_id'] === true ? str_replace(' ', '-', strtolower($this->name)) : 'slider-pro-' . $this->id; }