| 1 |
<?php |
| 2 |
|
| 3 |
if (!class_exists('UltimatePostKit_Settings_API')) : |
| 4 |
|
| 5 |
class UltimatePostKit_Settings_API { |
| 6 |
|
| 7 |
/** |
| 8 |
* settings sections array |
| 9 |
* |
| 10 |
* @var array |
| 11 |
*/ |
| 12 |
protected $settings_sections = array(); |
| 13 |
|
| 14 |
/** |
| 15 |
* Settings fields array |
| 16 |
* |
| 17 |
* @var array |
| 18 |
*/ |
| 19 |
protected $settings_fields = array(); |
| 20 |
|
| 21 |
public function __construct() { |
| 22 |
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
| 23 |
|
| 24 |
add_action('wp_ajax_ultimate_post_kit_settings_save', [$this, "ultimate_post_kit_settings_save"]); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Enqueue scripts and styles |
| 29 |
*/ |
| 30 |
function admin_enqueue_scripts() { |
| 31 |
wp_enqueue_script('jquery'); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Set settings sections |
| 36 |
* |
| 37 |
* @param array $sections setting sections array |
| 38 |
*/ |
| 39 |
function set_sections($sections) { |
| 40 |
$this->settings_sections = $sections; |
| 41 |
|
| 42 |
return $this; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Add a single section |
| 47 |
* |
| 48 |
* @param array $section |
| 49 |
*/ |
| 50 |
function add_section($section) { |
| 51 |
$this->settings_sections[] = $section; |
| 52 |
|
| 53 |
return $this; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Set settings fields |
| 58 |
* |
| 59 |
* @param array $fields settings fields array |
| 60 |
*/ |
| 61 |
function set_fields($fields) { |
| 62 |
$this->settings_fields = $fields; |
| 63 |
|
| 64 |
return $this; |
| 65 |
} |
| 66 |
|
| 67 |
function add_field($section, $field) { |
| 68 |
$defaults = array( |
| 69 |
'name' => '', |
| 70 |
'label' => '', |
| 71 |
'desc' => '', |
| 72 |
'type' => 'text' |
| 73 |
); |
| 74 |
|
| 75 |
$arg = wp_parse_args($field, $defaults); |
| 76 |
$this->settings_fields[$section][] = $arg; |
| 77 |
|
| 78 |
return $this; |
| 79 |
} |
| 80 |
|
| 81 |
function do_settings_sections($page) { |
| 82 |
global $wp_settings_sections, $wp_settings_fields; |
| 83 |
|
| 84 |
if (!isset($wp_settings_sections[$page])) { |
| 85 |
return; |
| 86 |
} |
| 87 |
|
| 88 |
// $matched_height = ' bdt-grid bdt-height-match="target: > div > .upk-option-item-inner"'; |
| 89 |
$data_settings = ''; |
| 90 |
|
| 91 |
foreach ((array) $wp_settings_sections[$page] as $section) { |
| 92 |
|
| 93 |
if ($section['id'] == 'ultimate_post_kit_api_settings') { |
| 94 |
$section_class = ' bdt-grid-small bdt-child-width-1-3@xl'; |
| 95 |
} elseif ($section['id'] == 'ultimate_post_kit_other_settings') { |
| 96 |
// $data_settings = $matched_height; |
| 97 |
$section_class = ' bdt-grid-small bdt-child-width-1-3@xl'; |
| 98 |
} else { |
| 99 |
$section_class = ' bdt-grid-small bdt-child-width-1-4@xl'; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
if ($section['callback']) { |
| 105 |
call_user_func($section['callback'], $section); |
| 106 |
} |
| 107 |
|
| 108 |
if (!isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']])) { |
| 109 |
continue; |
| 110 |
} |
| 111 |
echo '<div class="upk-options" role="presentation" ' . esc_attr($data_settings) . '>'; |
| 112 |
|
| 113 |
echo '<p class="upk-no-result bdt-text-center bdt-width-1-1 bdt-margin-small-top bdt-h4">'.esc_html__('Ops! Your Searched widget not found! Do you have any idea? If yes, ', 'ultimate-post-kit').'<a href="https://feedback.ultimatepostkit.pro/b/3v2gg80n/feature-requests/idea/new" target="_blank">'.esc_html__('Submit here', 'ultimate-post-kit').'</a></p>'; |
| 114 |
|
| 115 |
$this->do_settings_fields($page, $section['id']); |
| 116 |
|
| 117 |
echo '</div>'; |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
function do_settings_fields($page, $section) { |
| 123 |
global $wp_settings_fields; |
| 124 |
|
| 125 |
if (!isset($wp_settings_fields[$page][$section])) { |
| 126 |
return; |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
foreach ((array) $wp_settings_fields[$page][$section] as $field) { |
| 131 |
$class = ''; |
| 132 |
|
| 133 |
if (!empty($field['args']['class'])) { |
| 134 |
$class .= ' ' . esc_attr($field['args']['class']); |
| 135 |
} |
| 136 |
|
| 137 |
if (!empty($field['args']['widget_type'])) { |
| 138 |
$class .= ' upk-widget-' . esc_attr($field['args']['widget_type']); |
| 139 |
} |
| 140 |
|
| 141 |
if (!empty($field['args']['widget_type']) && 'pro' == $field['args']['widget_type'] && true !== upk_license_validation()) { |
| 142 |
$class .= ' upk-pro-inactive'; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
$used_widgets = self::get_used_widgets_obj(); |
| 147 |
$widget_name = 'upk-' . str_replace(' ', '-', strtolower($field['args']['id'])); |
| 148 |
$used_widgets_count = 0; |
| 149 |
|
| 150 |
if (isset($used_widgets)) { |
| 151 |
$used_widgets_count = (in_array($widget_name, array_keys($used_widgets)) ? $used_widgets[$widget_name] : 0); |
| 152 |
if ($used_widgets_count === 0) { |
| 153 |
$widget_name = str_replace('_', '-', $widget_name); |
| 154 |
$used_widgets_count = (in_array($widget_name, array_keys($used_widgets)) ? $used_widgets[$widget_name] : 0); |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
$widget_used_status = ' upk-used'; |
| 159 |
if ($used_widgets_count === 0) { |
| 160 |
$widget_used_status = ' upk-unused'; |
| 161 |
} |
| 162 |
|
| 163 |
$data_type = ' data-widget-type="' . esc_attr($field['args']['widget_type']) . '" data-content-type="' . esc_attr($field['args']['content_type']) . esc_attr($widget_used_status) . '" data-widget-name="' . strtolower($field['args']['name']) . '"'; |
| 164 |
|
| 165 |
|
| 166 |
if (!empty($field['args']['widget_type']) && 'pro' == $field['args']['widget_type'] && true !== _is_upk_pro_activated()) { |
| 167 |
$data_type .= ' bdt-tooltip="'.esc_html__('Pro widget only works with Pro version.', 'ultimate-post-kit').'"'; |
| 168 |
} |
| 169 |
|
| 170 |
echo "<div class='upk-option-item {$class} {$widget_used_status}' {$data_type}>"; |
| 171 |
|
| 172 |
call_user_func($field['callback'], $field['args']); |
| 173 |
|
| 174 |
echo '</div>'; |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
/** |
| 179 |
* Initialize and registers the settings sections and fileds to WordPress |
| 180 |
* |
| 181 |
* Usually this should be called at `admin_init` hook. |
| 182 |
* |
| 183 |
* This function gets the initiated settings sections and fields. Then |
| 184 |
* registers them to WordPress and ready for use. |
| 185 |
*/ |
| 186 |
function admin_init() { |
| 187 |
//register settings sections |
| 188 |
foreach ($this->settings_sections as $section) { |
| 189 |
if (false == get_option($section['id'])) { |
| 190 |
add_option($section['id']); |
| 191 |
} |
| 192 |
|
| 193 |
if (isset($section['desc']) && !empty($section['desc'])) { |
| 194 |
$section['desc'] = '<div class="inside">' . $section['desc'] . '</div>'; |
| 195 |
$callback = function () use ($section) { |
| 196 |
echo str_replace('"', '\"', $section['desc']); |
| 197 |
}; |
| 198 |
} else if (isset($section['callback'])) { |
| 199 |
$callback = $section['callback']; |
| 200 |
} else { |
| 201 |
$callback = null; |
| 202 |
} |
| 203 |
|
| 204 |
add_settings_section($section['id'], $section['title'], $callback, $section['id']); |
| 205 |
} |
| 206 |
|
| 207 |
//register settings fields |
| 208 |
foreach ($this->settings_fields as $section => $field) { |
| 209 |
foreach ($field as $option) { |
| 210 |
|
| 211 |
$name = $option['name']; |
| 212 |
$type = isset($option['type']) ? $option['type'] : 'text'; |
| 213 |
$label = isset($option['label']) ? $option['label'] : ''; |
| 214 |
$callback = isset($option['callback']) ? $option['callback'] : array($this, 'callback_' . $type); |
| 215 |
|
| 216 |
$args = array( |
| 217 |
'id' => $name, |
| 218 |
'class' => isset($option['class']) ? 'upk-' . $name . ' ' . $option['class'] : 'upk-' . $name, |
| 219 |
'label_for' => "upk-{$section}[{$name}]", |
| 220 |
'desc' => isset($option['desc']) ? $option['desc'] : '', |
| 221 |
'name' => $label, |
| 222 |
'section' => $section, |
| 223 |
'size' => isset($option['size']) ? $option['size'] : null, |
| 224 |
'options' => isset($option['options']) ? $option['options'] : '', |
| 225 |
'std' => isset($option['default']) ? $option['default'] : '', |
| 226 |
'sanitize_callback' => isset($option['sanitize_callback']) ? $option['sanitize_callback'] : '', |
| 227 |
'type' => $type, |
| 228 |
'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : '', |
| 229 |
'min' => isset($option['min']) ? $option['min'] : '', |
| 230 |
'max' => isset($option['max']) ? $option['max'] : '', |
| 231 |
'step' => isset($option['step']) ? $option['step'] : '', |
| 232 |
'plugin_name' => !empty($option['plugin_name']) ? $option['plugin_name'] : null, |
| 233 |
'plugin_path' => !empty($option['plugin_path']) ? $option['plugin_path'] : null, |
| 234 |
'paid' => !empty($option['paid']) ? $option['paid'] : null, |
| 235 |
'widget_type' => !empty($option['widget_type']) ? $option['widget_type'] : null, |
| 236 |
'content_type' => !empty($option['content_type']) ? $option['content_type'] : null, |
| 237 |
'demo_url' => !empty($option['demo_url']) ? $option['demo_url'] : null, |
| 238 |
'video_url' => !empty($option['video_url']) ? $option['video_url'] : null, |
| 239 |
); |
| 240 |
|
| 241 |
add_settings_field("{$section}[{$name}]", $label, $callback, $section, $section, $args); |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
// creates our settings in the options table |
| 246 |
foreach ($this->settings_sections as $section) { |
| 247 |
register_setting($section['id'], $section['id'], array($this, 'sanitize_options')); |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
/** |
| 252 |
* Get field description for display |
| 253 |
* |
| 254 |
* @param array $args settings field args |
| 255 |
*/ |
| 256 |
public function get_field_description($args) { |
| 257 |
if (!empty($args['desc'])) { |
| 258 |
$desc = sprintf('<p class="description">%s</p>', $args['desc']); |
| 259 |
} else { |
| 260 |
$desc = ''; |
| 261 |
} |
| 262 |
|
| 263 |
return $desc; |
| 264 |
} |
| 265 |
|
| 266 |
/** |
| 267 |
* Displays a text field for a settings field |
| 268 |
* |
| 269 |
* @param array $args settings field args |
| 270 |
*/ |
| 271 |
function callback_text($args) { |
| 272 |
|
| 273 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std'])); |
| 274 |
$class = 'bdt-input'; |
| 275 |
$type = isset($args['type']) ? $args['type'] : 'text'; |
| 276 |
$placeholder = empty($args['placeholder']) ? '' : ' placeholder="' . $args['placeholder'] . '"'; |
| 277 |
$html = ''; |
| 278 |
|
| 279 |
|
| 280 |
$html .= '<div class="upk-option-item-inner">'; |
| 281 |
if ($args['video_url']) { |
| 282 |
$html .= '<a href="' . $args['video_url'] . '" target="_blank" class="upk-option-video" bdt-tooltip="View ' . $args['name'] . ' Video Tutorial"><i class="upk-icon-tutorial" aria-hidden="true"></i></a>'; |
| 283 |
} |
| 284 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s]">', $args['section'], $args['id']); |
| 285 |
$html .= '<span scope="row" class="upk-option-label">' . $args['name'] . '</span>'; |
| 286 |
$html .= '</label>'; |
| 287 |
|
| 288 |
|
| 289 |
$html .= sprintf('<input type="%1$s" class="%2$s" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s/>', $type, $class, $args['section'], $args['id'], $value, $placeholder); |
| 290 |
|
| 291 |
$html .= $this->get_field_description($args); |
| 292 |
|
| 293 |
$html .= '</div>'; |
| 294 |
|
| 295 |
echo $html; |
| 296 |
} |
| 297 |
|
| 298 |
/** |
| 299 |
* Displays a url field for a settings field |
| 300 |
* |
| 301 |
* @param array $args settings field args |
| 302 |
*/ |
| 303 |
function callback_url($args) { |
| 304 |
$this->callback_text($args); |
| 305 |
} |
| 306 |
|
| 307 |
/** |
| 308 |
* Displays a number field for a settings field |
| 309 |
* |
| 310 |
* @param array $args settings field args |
| 311 |
*/ |
| 312 |
function callback_number($args) { |
| 313 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std'])); |
| 314 |
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular'; |
| 315 |
$type = isset($args['type']) ? $args['type'] : 'number'; |
| 316 |
$placeholder = empty($args['placeholder']) ? '' : ' placeholder="' . $args['placeholder'] . '"'; |
| 317 |
$min = ($args['min'] == '') ? '' : ' min="' . $args['min'] . '"'; |
| 318 |
$max = ($args['max'] == '') ? '' : ' max="' . $args['max'] . '"'; |
| 319 |
$step = ($args['step'] == '') ? '' : ' step="' . $args['step'] . '"'; |
| 320 |
|
| 321 |
$html = sprintf('<input type="%1$s" class="%2$s-number" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step); |
| 322 |
$html .= $this->get_field_description($args); |
| 323 |
|
| 324 |
echo $html; |
| 325 |
} |
| 326 |
|
| 327 |
/** |
| 328 |
* Get used widgets. |
| 329 |
* |
| 330 |
* @access public |
| 331 |
* @since 6.0.0 |
| 332 |
* |
| 333 |
* @return array |
| 334 |
*/ |
| 335 |
|
| 336 |
public static function get_used_widgets_obj() { |
| 337 |
return UltimatePostKit_Admin_Settings::get_used_widgets(); |
| 338 |
} |
| 339 |
|
| 340 |
/** |
| 341 |
* Get unused widgets. |
| 342 |
* |
| 343 |
* @access public |
| 344 |
* @since 6.0.0 |
| 345 |
* |
| 346 |
* @return array |
| 347 |
*/ |
| 348 |
|
| 349 |
public static function get_unused_widgets_obj() { |
| 350 |
return UltimatePostKit_Admin_Settings::get_unused_widgets(); |
| 351 |
} |
| 352 |
|
| 353 |
/** |
| 354 |
* Displays a checkbox for a settings field |
| 355 |
* |
| 356 |
* @param array $args settings field args |
| 357 |
*/ |
| 358 |
function callback_checkbox($args) { |
| 359 |
|
| 360 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std'])); |
| 361 |
$plugin_name = isset($args['plugin_name']) ? $args['plugin_name'] : ''; |
| 362 |
$plugin_path = isset($args['plugin_path']) ? $args['plugin_path'] : ''; |
| 363 |
$paid = isset($args['paid']) ? $args['paid'] : ''; |
| 364 |
|
| 365 |
$parent_class = isset($args['ep_parent_switcher']) ? ' upk-feature-option-parent' : ''; |
| 366 |
|
| 367 |
$used_widgets = self::get_used_widgets_obj(); |
| 368 |
$widget_name = 'bdt-' . $args['id']; |
| 369 |
$used_widgets_count = 0; |
| 370 |
|
| 371 |
|
| 372 |
if (isset($used_widgets)) { |
| 373 |
$used_widgets_count = (in_array($widget_name, array_keys($used_widgets)) ? $used_widgets[$widget_name] : 0); |
| 374 |
if ($used_widgets_count === 0) { |
| 375 |
$widget_name = str_replace('_', '-', $widget_name); |
| 376 |
$used_widgets_count = (in_array($widget_name, array_keys($used_widgets)) ? $used_widgets[$widget_name] : 0); |
| 377 |
} |
| 378 |
} |
| 379 |
|
| 380 |
$html = ''; |
| 381 |
|
| 382 |
$html .= '<div class="upk-option-item-inner">'; |
| 383 |
$html .= '<div class="bdt-grid bdt-grid-collapse bdt-flex bdt-flex-middle">'; |
| 384 |
|
| 385 |
$html .= '<div class="bdt-width-expand bdt-flex-inline bdt-flex-middle">'; |
| 386 |
|
| 387 |
|
| 388 |
$html .= '<i class="upk-icon-' . esc_attr($args['id']) . '" aria-hidden="true"></i>'; |
| 389 |
$html .= '<div class="upk-option-label-wrap">'; |
| 390 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s]">', $args['section'], $args['id']); |
| 391 |
$html .= '<span scope="row" class="upk-option-label">' . $args['name'] . '</span>'; |
| 392 |
$html .= '</label>'; |
| 393 |
|
| 394 |
$html .= '<div class="upk-option-links">'; |
| 395 |
if ($args['demo_url']) { |
| 396 |
$html .= '<a href=' . $args['demo_url'] . ' target="_blank" class="upk-option-demo" title="' . esc_html__('View ' . $args['name'] . ' Widget Demo', 'bdthemes-element-pack') . '">' . esc_html__('Demo', 'bdthemes-element-pack') . '<i class="upk-icon-preview" aria-hidden="true"></i></a>'; |
| 397 |
} |
| 398 |
if ($args['video_url']) { |
| 399 |
$html .= '<a href=' . $args['video_url'] . ' target="_blank" class="upk-option-video" title="View ' . $args['name'] . ' Video Tutorial">Video<i class="upk-icon-tutorial" aria-hidden="true"></i></a>'; |
| 400 |
} |
| 401 |
$html .= '</div>'; |
| 402 |
$html .= '</div>'; |
| 403 |
$html .= '</div>'; |
| 404 |
|
| 405 |
$html .= '<div class="bdt-width-auto">'; |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
// 3rd party widgets |
| 410 |
if ($plugin_name and $plugin_path) { |
| 411 |
|
| 412 |
if ($this->_is_plugin_installed($plugin_name, $plugin_path)) { |
| 413 |
if (!current_user_can('activate_plugins')) { |
| 414 |
return; |
| 415 |
} |
| 416 |
if (!is_plugin_active($plugin_path)) { |
| 417 |
$active_link = wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_path . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin_path); |
| 418 |
$html .= '<a href="' . $active_link . '" class="ultimate-post-kit-3pp-active" bdt-tooltip="' . esc_html__('Activate the plugin first then you can activate this widget.', 'bdthemes-element-pack') . '"><span class="dashicons dashicons-admin-plugins"></span></a>'; |
| 419 |
} |
| 420 |
} else { |
| 421 |
if ($paid) { |
| 422 |
$html .= '<a href="' . $paid . '" class="ultimate-post-kit-3pp-download" bdt-tooltip="' . esc_html__('Download and install plugin first then you can activate this widget.', 'bdthemes-element-pack') . '"><span class="dashicons dashicons-download"></span></a>'; |
| 423 |
} else { |
| 424 |
$install_link = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_name), 'install-plugin_' . $plugin_name); |
| 425 |
$html .= '<a href="' . $install_link . '" class="ultimate-post-kit-3pp-install" bdt-tooltip="' . esc_html__('Install the plugin first then you can activate this widget.', 'bdthemes-element-pack') . '"><span class="dashicons dashicons-download"></span></a>'; |
| 426 |
} |
| 427 |
} |
| 428 |
if ($this->_is_plugin_installed($plugin_name, $plugin_path) and is_plugin_active($plugin_path)) { |
| 429 |
|
| 430 |
$html .= '<fieldset>'; |
| 431 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s]">', $args['section'], $args['id']); |
| 432 |
$html .= sprintf('<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id']); |
| 433 |
$html .= sprintf('<input type="checkbox" class="checkbox' . $parent_class . '" id="bdt_upk_%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s />', $args['section'], $args['id'], checked($value, 'on', false)); |
| 434 |
$html .= '<span class="switch"></span>'; |
| 435 |
$html .= '</label>'; |
| 436 |
$html .= '</fieldset>'; |
| 437 |
} |
| 438 |
} else { // core widgets |
| 439 |
|
| 440 |
$html .= '<fieldset>'; |
| 441 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s]">', $args['section'], $args['id']); |
| 442 |
$html .= sprintf('<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id']); |
| 443 |
$html .= sprintf('<input type="checkbox" class="checkbox" id="bdt_upk_%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s />', $args['section'], $args['id'], checked($value, 'on', false)); |
| 444 |
$html .= '<span class="switch"></span>'; |
| 445 |
$html .= '</label>'; |
| 446 |
$html .= '</fieldset>'; |
| 447 |
} |
| 448 |
|
| 449 |
$html .= '</div>'; |
| 450 |
$html .= '</div>'; |
| 451 |
$html .= '</div>'; |
| 452 |
|
| 453 |
echo wp_kses($html, array( |
| 454 |
'div' => array( |
| 455 |
'class' => array(), |
| 456 |
), |
| 457 |
'span' => array( |
| 458 |
'class' => array(), |
| 459 |
), |
| 460 |
'label' => array( |
| 461 |
'for' => array(), |
| 462 |
), |
| 463 |
'input' => array( |
| 464 |
'type' => array(), |
| 465 |
'class' => array(), |
| 466 |
'id' => array(), |
| 467 |
'name' => array(), |
| 468 |
'value' => array(), |
| 469 |
'checked' => array(), |
| 470 |
), |
| 471 |
'i' => array( |
| 472 |
'class' => array(), |
| 473 |
'aria-hidden' => array(), |
| 474 |
), |
| 475 |
'a' => array( |
| 476 |
'href' => array(), |
| 477 |
'target' => array(), |
| 478 |
'class' => array(), |
| 479 |
'bdt-tooltip' => array(), |
| 480 |
), |
| 481 |
'fieldset' => array(), |
| 482 |
)); |
| 483 |
} |
| 484 |
|
| 485 |
function _is_plugin_installed($plugin, $plugin_path) { |
| 486 |
$installed_plugins = get_plugins(); |
| 487 |
return isset($installed_plugins[$plugin_path]); |
| 488 |
} |
| 489 |
|
| 490 |
|
| 491 |
/** |
| 492 |
* Displays a multicheckbox for a settings field |
| 493 |
* |
| 494 |
* @param array $args settings field args |
| 495 |
*/ |
| 496 |
function callback_multicheck($args) { |
| 497 |
|
| 498 |
$value = $this->get_option($args['id'], $args['section'], $args['std']); |
| 499 |
$html = '<fieldset>'; |
| 500 |
$html .= sprintf('<input type="hidden" name="%1$s[%2$s]" value="" />', $args['section'], $args['id']); |
| 501 |
foreach ($args['options'] as $key => $label) { |
| 502 |
$checked = isset($value[$key]) ? $value[$key] : '0'; |
| 503 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key); |
| 504 |
$html .= sprintf('<input type="checkbox" class="checkbox" id="bdt_upk_%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked($checked, $key, false)); |
| 505 |
$html .= '<span class="switch"></span>'; |
| 506 |
$html .= sprintf('%1$s</label><br>', $label); |
| 507 |
} |
| 508 |
|
| 509 |
$html .= $this->get_field_description($args); |
| 510 |
$html .= '</fieldset>'; |
| 511 |
|
| 512 |
echo $html; |
| 513 |
} |
| 514 |
|
| 515 |
/** |
| 516 |
* Displays a radio button for a settings field |
| 517 |
* |
| 518 |
* @param array $args settings field args |
| 519 |
*/ |
| 520 |
function callback_radio($args) { |
| 521 |
|
| 522 |
$value = $this->get_option($args['id'], $args['section'], $args['std']); |
| 523 |
$html = '<fieldset>'; |
| 524 |
|
| 525 |
foreach ($args['options'] as $key => $label) { |
| 526 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key); |
| 527 |
$html .= sprintf('<input type="radio" class="radio" id="bdt_upk_%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked($value, $key, false)); |
| 528 |
$html .= sprintf('%1$s</label><br>', $label); |
| 529 |
} |
| 530 |
|
| 531 |
$html .= $this->get_field_description($args); |
| 532 |
$html .= '</fieldset>'; |
| 533 |
|
| 534 |
echo $html; |
| 535 |
} |
| 536 |
|
| 537 |
/** |
| 538 |
* Displays a selectbox for a settings field |
| 539 |
* |
| 540 |
* @param array $args settings field args |
| 541 |
*/ |
| 542 |
function callback_select($args) { |
| 543 |
|
| 544 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std'])); |
| 545 |
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular'; |
| 546 |
$html = sprintf('<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id']); |
| 547 |
|
| 548 |
foreach ($args['options'] as $key => $label) { |
| 549 |
$html .= sprintf('<option value="%s"%s>%s</option>', $key, selected($value, $key, false), $label); |
| 550 |
} |
| 551 |
|
| 552 |
$html .= sprintf('</select>'); |
| 553 |
$html .= $this->get_field_description($args); |
| 554 |
|
| 555 |
echo $html; |
| 556 |
} |
| 557 |
|
| 558 |
/** |
| 559 |
* Displays a textarea for a settings field |
| 560 |
* |
| 561 |
* @param array $args settings field args |
| 562 |
*/ |
| 563 |
function callback_textarea($args) { |
| 564 |
|
| 565 |
$value = esc_textarea($this->get_option($args['id'], $args['section'], $args['std'])); |
| 566 |
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular'; |
| 567 |
$placeholder = empty($args['placeholder']) ? '' : ' placeholder="' . $args['placeholder'] . '"'; |
| 568 |
|
| 569 |
$html = ''; |
| 570 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s]">', $args['section'], $args['id']); |
| 571 |
$html .= '<span scope="row" class="upk-option-label">' . $args['name'] . '</span>'; |
| 572 |
$html .= '</label>'; |
| 573 |
|
| 574 |
$html .= sprintf('<textarea rows="5" cols="55" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]" %4$s >%5$s</textarea>', $size, $args['section'], $args['id'], $placeholder, $value); |
| 575 |
$html .= $this->get_field_description($args); |
| 576 |
|
| 577 |
echo $html; |
| 578 |
} |
| 579 |
|
| 580 |
/** |
| 581 |
* Displays the html for a settings field |
| 582 |
* |
| 583 |
* @param array $args settings field args |
| 584 |
* @return string |
| 585 |
*/ |
| 586 |
function callback_html($args) { |
| 587 |
echo $args['desc']; |
| 588 |
} |
| 589 |
|
| 590 |
/** |
| 591 |
* Displays a file upload field for a settings field |
| 592 |
* |
| 593 |
* @param array $args settings field args |
| 594 |
*/ |
| 595 |
function callback_file($args) { |
| 596 |
|
| 597 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std'])); |
| 598 |
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular'; |
| 599 |
$id = $args['section'] . '[' . $args['id'] . ']'; |
| 600 |
$label = isset($args['options']['button_label']) ? $args['options']['button_label'] : __('Choose File', 'ultimate-post-kit'); |
| 601 |
|
| 602 |
$html = sprintf('<input type="text" class="%1$s-text wpsa-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value); |
| 603 |
$html .= '<input type="button" class="button wpsa-browse" value="' . $label . '" />'; |
| 604 |
$html .= $this->get_field_description($args); |
| 605 |
|
| 606 |
echo $html; |
| 607 |
} |
| 608 |
|
| 609 |
/** |
| 610 |
* Displays a password field for a settings field |
| 611 |
* |
| 612 |
* @param array $args settings field args |
| 613 |
*/ |
| 614 |
function callback_password($args) { |
| 615 |
|
| 616 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std'])); |
| 617 |
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular'; |
| 618 |
|
| 619 |
$html = sprintf('<input type="password" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value); |
| 620 |
$html .= $this->get_field_description($args); |
| 621 |
|
| 622 |
echo $html; |
| 623 |
} |
| 624 |
|
| 625 |
/** |
| 626 |
* Displays a color picker field for a settings field |
| 627 |
* |
| 628 |
* @param array $args settings field args |
| 629 |
*/ |
| 630 |
function callback_color($args) { |
| 631 |
|
| 632 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std'])); |
| 633 |
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular'; |
| 634 |
|
| 635 |
$html = sprintf('<input type="text" class="%1$s-text wp-color-picker-field" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" />', $size, $args['section'], $args['id'], $value, $args['std']); |
| 636 |
$html .= $this->get_field_description($args); |
| 637 |
|
| 638 |
echo $html; |
| 639 |
} |
| 640 |
|
| 641 |
/** |
| 642 |
* Displays a 2 colspan subheading field for a settings field |
| 643 |
* |
| 644 |
* @param array $args settings field args |
| 645 |
*/ |
| 646 |
function callback_subheading($args) { |
| 647 |
|
| 648 |
$html = '<h3 class="setting_subheading column-merge">' . $args['name'] . '</h3>'; |
| 649 |
$html .= $this->get_field_description($args); |
| 650 |
$html .= '<hr class="setting_separator">'; |
| 651 |
|
| 652 |
echo $html; |
| 653 |
} |
| 654 |
|
| 655 |
function callback_start_group($args) { |
| 656 |
|
| 657 |
$html = '<div class="upk-option-item-inner upk-option-group">'; |
| 658 |
|
| 659 |
$html .= sprintf('<label for="bdt_upk_%1$s[%2$s]">', $args['section'], $args['id']); |
| 660 |
$html .= '<span scope="row" class="upk-option-label">' . $args['name'] . '</span>'; |
| 661 |
$html .= '</label>'; |
| 662 |
|
| 663 |
if ($args['video_url']) { |
| 664 |
$html .= '<a href="' . $args['video_url'] . '" target="_blank" class="upk-option-video" bdt-tooltip="View ' . $args['name'] . ' Video Tutorial"><i class="upk-icon-tutorial" aria-hidden="true"></i></a>'; |
| 665 |
} |
| 666 |
|
| 667 |
$html .= $this->get_field_description($args); |
| 668 |
|
| 669 |
$html .= '<div class="bdt-grid" bdt-grid>'; |
| 670 |
|
| 671 |
echo $html; |
| 672 |
} |
| 673 |
|
| 674 |
function callback_end_group($args) { |
| 675 |
|
| 676 |
$html = '</div>'; |
| 677 |
$html .= '</div>'; |
| 678 |
|
| 679 |
echo $html; |
| 680 |
} |
| 681 |
|
| 682 |
/** |
| 683 |
* Displays a 2 colspan separator field for a settings field |
| 684 |
* |
| 685 |
* @param array $args settings field args |
| 686 |
*/ |
| 687 |
function callback_separator($args) { |
| 688 |
|
| 689 |
$html = '<hr class="setting_separator column-merge">'; |
| 690 |
$html .= $this->get_field_description($args); |
| 691 |
|
| 692 |
|
| 693 |
echo $html; |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
/** |
| 698 |
* Displays a select box for creating the pages select box |
| 699 |
* |
| 700 |
* @param array $args settings field args |
| 701 |
*/ |
| 702 |
function callback_pages($args) { |
| 703 |
|
| 704 |
$dropdown_args = array( |
| 705 |
'selected' => esc_attr($this->get_option($args['id'], $args['section'], $args['std'])), |
| 706 |
'name' => $args['section'] . '[' . $args['id'] . ']', |
| 707 |
'id' => $args['section'] . '[' . $args['id'] . ']', |
| 708 |
'echo' => 0 |
| 709 |
); |
| 710 |
$html = wp_dropdown_pages($dropdown_args); |
| 711 |
echo $html; |
| 712 |
} |
| 713 |
|
| 714 |
/** |
| 715 |
* Sanitize callback for Settings API |
| 716 |
* |
| 717 |
* @return mixed |
| 718 |
*/ |
| 719 |
function sanitize_options($options) { |
| 720 |
|
| 721 |
if (!$options) { |
| 722 |
return $options; |
| 723 |
} |
| 724 |
|
| 725 |
foreach ($options as $option_slug => $option_value) { |
| 726 |
$sanitize_callback = $this->get_sanitize_callback($option_slug); |
| 727 |
|
| 728 |
// If callback is set, call it |
| 729 |
if ($sanitize_callback) { |
| 730 |
$options[$option_slug] = call_user_func($sanitize_callback, $option_value); |
| 731 |
continue; |
| 732 |
} |
| 733 |
} |
| 734 |
|
| 735 |
return $options; |
| 736 |
} |
| 737 |
|
| 738 |
/** |
| 739 |
* Get sanitization callback for given option slug |
| 740 |
* |
| 741 |
* @param string $slug option slug |
| 742 |
* |
| 743 |
* @return mixed string or bool false |
| 744 |
*/ |
| 745 |
function get_sanitize_callback($slug = '') { |
| 746 |
if (empty($slug)) { |
| 747 |
return false; |
| 748 |
} |
| 749 |
|
| 750 |
// Iterate over registered fields and see if we can find proper callback |
| 751 |
foreach ($this->settings_fields as $section => $options) { |
| 752 |
foreach ($options as $option) { |
| 753 |
if ($option['name'] != $slug) { |
| 754 |
continue; |
| 755 |
} |
| 756 |
|
| 757 |
// Return the callback name |
| 758 |
return isset($option['sanitize_callback']) && is_callable($option['sanitize_callback']) ? $option['sanitize_callback'] : false; |
| 759 |
} |
| 760 |
} |
| 761 |
|
| 762 |
return false; |
| 763 |
} |
| 764 |
|
| 765 |
/** |
| 766 |
* Get the value of a settings field |
| 767 |
* |
| 768 |
* @param string $option settings field name |
| 769 |
* @param string $section the section name this field belongs to |
| 770 |
* @param string $default default text if it's not found |
| 771 |
* @return string |
| 772 |
*/ |
| 773 |
function get_option($option, $section, $default = '') { |
| 774 |
|
| 775 |
$options = get_option($section); |
| 776 |
|
| 777 |
if (isset($options[$option])) { |
| 778 |
return $options[$option]; |
| 779 |
} |
| 780 |
|
| 781 |
return $default; |
| 782 |
} |
| 783 |
|
| 784 |
/** |
| 785 |
* Show navigations as tab |
| 786 |
* |
| 787 |
* Shows all the settings section labels as tab |
| 788 |
*/ |
| 789 |
function show_navigation() { |
| 790 |
$html = '<div class="bdt-dashboard-navigation">'; |
| 791 |
$html .= '<ul class="bdt-tab bdt-flex-column" bdt-tab="animation: bdt-animation-slide-bottom-small;connect: .bdt-tab-container;">'; |
| 792 |
|
| 793 |
// Dashboard - always first |
| 794 |
$html .= sprintf('<li><a href="#%1$s" class="bdt-tab-item" id="bdt-%1$s" data-tab-index="0"><i class="dashicons dashicons-admin-home"></i>%2$s</a></li>', 'ultimate_post_kit_welcome', esc_html__('Dashboard', 'ultimate-post-kit')); |
| 795 |
|
| 796 |
$count = 1; |
| 797 |
|
| 798 |
// Get all sections including manually created ones |
| 799 |
$all_sections = $this->get_all_sections(); |
| 800 |
|
| 801 |
foreach ($all_sections as $tab) { |
| 802 |
$icon = isset($tab['icon']) ? $tab['icon'] : 'dashicons dashicons-admin-generic'; |
| 803 |
$html .= sprintf('<li><a href="#%1$s" class="bdt-tab-item" id="bdt-%1$s" data-tab-index="%2$s"><i class="%4$s"></i>%3$s</a></li>', $tab['id'], $count++, $tab['title'], $icon); |
| 804 |
} |
| 805 |
|
| 806 |
// License section |
| 807 |
$license_wl_status = UltimatePostKit_Admin_Settings::license_wl_status(); |
| 808 |
|
| 809 |
if (!defined('BDTUPK_LO') || false == $license_wl_status) { |
| 810 |
$html .= sprintf('<li><a href="#%1$s" class="bdt-tab-item" id="bdt-%1$s" data-tab-index="%2$s"><i class="dashicons dashicons-admin-network"></i>%3$s</a></li>', 'ultimate_post_kit_license_settings', $count, esc_html__('License', 'ultimate-post-kit')); |
| 811 |
} |
| 812 |
|
| 813 |
$html .= '</ul>'; |
| 814 |
$html .= '</div>'; |
| 815 |
|
| 816 |
echo wp_kses($html, array( |
| 817 |
'div' => array( |
| 818 |
'class' => true, |
| 819 |
), |
| 820 |
'ul' => array( |
| 821 |
'class' => true, |
| 822 |
'bdt-tab' => true, |
| 823 |
), |
| 824 |
'li' => array( |
| 825 |
'class' => true, |
| 826 |
), |
| 827 |
'a' => array( |
| 828 |
'href' => true, |
| 829 |
'class' => true, |
| 830 |
'id' => true, |
| 831 |
'data-tab-index' => true, |
| 832 |
), |
| 833 |
'i' => array( |
| 834 |
'class' => true, |
| 835 |
) |
| 836 |
)); |
| 837 |
} |
| 838 |
|
| 839 |
function ultimate_post_kit_settings_save() { |
| 840 |
|
| 841 |
if (!check_ajax_referer('ultimate-post-kit-settings-save-nonce')) { |
| 842 |
wp_send_json_error(); |
| 843 |
} |
| 844 |
|
| 845 |
if (!current_user_can('manage_options')) { |
| 846 |
return; |
| 847 |
} |
| 848 |
|
| 849 |
$moudle_id = sanitize_text_field($_POST['id']); |
| 850 |
|
| 851 |
unset($_POST['id']); |
| 852 |
|
| 853 |
if (isset($_POST[$moudle_id])) { |
| 854 |
update_option($moudle_id, $_POST[$moudle_id]); |
| 855 |
} |
| 856 |
|
| 857 |
wp_send_json_success(); |
| 858 |
} |
| 859 |
|
| 860 |
/** |
| 861 |
* Get all sections including manually created content pages |
| 862 |
*/ |
| 863 |
private function get_all_sections() { |
| 864 |
// Start with the settings sections that have forms |
| 865 |
$all_sections = $this->settings_sections; |
| 866 |
|
| 867 |
// Add manually created content sections that don't have settings forms |
| 868 |
$content_only_sections = [ |
| 869 |
[ |
| 870 |
'id' => 'ultimate_post_kit_extra_options', |
| 871 |
'title' => esc_html__('Extra Options', 'ultimate-post-kit'), |
| 872 |
'icon' => 'dashicons dashicons-smiley', |
| 873 |
], |
| 874 |
[ |
| 875 |
'id' => 'ultimate_post_kit_analytics_system_req', |
| 876 |
'title' => esc_html__('System Status', 'ultimate-post-kit'), |
| 877 |
'icon' => 'dashicons dashicons-chart-bar', |
| 878 |
], |
| 879 |
[ |
| 880 |
'id' => 'ultimate_post_kit_other_plugins', |
| 881 |
'title' => esc_html__('Other Plugins', 'ultimate-post-kit'), |
| 882 |
'icon' => 'dashicons dashicons-admin-plugins', |
| 883 |
], |
| 884 |
// [ |
| 885 |
// 'id' => 'ultimate_post_kit_affiliate', |
| 886 |
// 'title' => esc_html__('Get Up to 60%', 'ultimate-post-kit'), |
| 887 |
// 'icon' => 'dashicons dashicons-money-alt', |
| 888 |
// ], |
| 889 |
[ |
| 890 |
'id' => 'ultimate_post_kit_rollback_version', |
| 891 |
'title' => esc_html__('Rollback Version', 'ultimate-post-kit'), |
| 892 |
'icon' => 'dashicons dashicons-update', |
| 893 |
], |
| 894 |
]; |
| 895 |
|
| 896 |
// Check if each content section exists in settings sections, if not add it |
| 897 |
foreach ($content_only_sections as $content_section) { |
| 898 |
$exists = false; |
| 899 |
foreach ($all_sections as $existing_section) { |
| 900 |
if ($existing_section['id'] === $content_section['id']) { |
| 901 |
$exists = true; |
| 902 |
break; |
| 903 |
} |
| 904 |
} |
| 905 |
if (!$exists) { |
| 906 |
$all_sections[] = $content_section; |
| 907 |
} |
| 908 |
} |
| 909 |
|
| 910 |
return $all_sections; |
| 911 |
} |
| 912 |
|
| 913 |
/** |
| 914 |
* Show the section settings forms |
| 915 |
* |
| 916 |
* This function displays every sections in a different form |
| 917 |
*/ |
| 918 |
function show_forms() { |
| 919 |
?> |
| 920 |
|
| 921 |
<?php $i = 0; |
| 922 |
foreach ($this->settings_sections as $form) { |
| 923 |
$i++; ?> |
| 924 |
<div id="<?php echo esc_attr($form['id']); ?>_page" class="upk-option-page"> |
| 925 |
|
| 926 |
<div bdt-filter="target: .upk-options" class="upk-options-parent" id="upk-options-parent-<?php echo esc_attr($i); ?>"> |
| 927 |
|
| 928 |
|
| 929 |
<?php if ($form['id'] == 'ultimate_post_kit_active_modules' or $form['id'] == 'ultimate_post_kit_elementor_extend'): ?> |
| 930 |
|
| 931 |
<div class="bdt-widget-filter-wrapper bdt-flex bdt-flex-column bdt-flex-wrap" |
| 932 |
bdt-sticky="end: !.upk-dashboard-container; offset: 115; animation: bdt-animation-slide-top-small; duration: 300"> |
| 933 |
|
| 934 |
<!-- Filter Shape Elements --> |
| 935 |
<div class="upk-filter-elements"> |
| 936 |
<span class="upk-filter-element upk-filter-circle"></span> |
| 937 |
<span class="upk-filter-element upk-filter-dots"></span> |
| 938 |
<span class="upk-filter-element upk-filter-wave"></span> |
| 939 |
<span class="upk-filter-element upk-filter-hexagon"></span> |
| 940 |
<span class="upk-filter-element upk-filter-zigzag"></span> |
| 941 |
</div> |
| 942 |
|
| 943 |
<div class="bdt-widget-filter-header"> |
| 944 |
|
| 945 |
<div class="bdt-flex bdt-flex-wrap"> |
| 946 |
|
| 947 |
<div class="bdt-width-expand@l upk-widget-filter-nav bdt-visible@l"> |
| 948 |
<div class="bdt-flex-inline bdt-flex-middle"> |
| 949 |
|
| 950 |
<div> |
| 951 |
<ul |
| 952 |
class="bdt-subnav bdt-subnav-pill upk-widget-filter bdt-widget-type-content bdt-flex-inline"> |
| 953 |
<li class="upk-widget-all bdt-active" bdt-filter-control="*"><a |
| 954 |
href="#"><?php esc_html_e('All', 'ultimate-post-kit'); ?></a></li> |
| 955 |
<li class="upk-widget-free" |
| 956 |
bdt-filter-control="filter: [data-widget-type='free']; group: data-content-type"> |
| 957 |
<a href="#"><?php esc_html_e('Free', 'ultimate-post-kit'); ?></a> |
| 958 |
</li> |
| 959 |
<li class="upk-widget-pro" |
| 960 |
bdt-filter-control="filter: [data-widget-type='pro']; group: data-content-type"> |
| 961 |
<a href="#"><?php esc_html_e('Pro', 'ultimate-post-kit'); ?></a> |
| 962 |
</li> |
| 963 |
|
| 964 |
</ul> |
| 965 |
</div> |
| 966 |
|
| 967 |
<?php if ($form['id'] == 'ultimate_post_kit_active_modules' or $form['id'] == 'ultimate_post_kit_third_party_widget'): ?> |
| 968 |
|
| 969 |
|
| 970 |
<?php if ($form['id'] != 'ultimate_post_kit_elementor_extend' or $form['id'] == 'ultimate_post_kit_third_party_widget'): ?> |
| 971 |
|
| 972 |
<div> |
| 973 |
<ul |
| 974 |
class="bdt-subnav bdt-subnav-pill upk-widget-filter upk-used-unused-widgets bdt-flex-inline "> |
| 975 |
<li class="upk-widget--" |
| 976 |
bdt-filter-control="filter: [data-content-type*='upk-used']; group: data-content-type"> |
| 977 |
<a href="#"><?php esc_html_e('Used', 'ultimate-post-kit'); ?> |
| 978 |
<span class="bdt-badge upk-used-widget"></span> |
| 979 |
</a> |
| 980 |
</li> |
| 981 |
<li class="upk-widget--" |
| 982 |
bdt-filter-control="filter: [data-content-type*='upk-unused']; group: data-content-type"> |
| 983 |
<a href="#" |
| 984 |
bdt-tooltip="<?php esc_html_e('Don\'t need unused widget? Click on the Deactivate All button.', 'ultimate-post-kit'); ?>"><?php esc_html_e('Unused', 'ultimate-post-kit'); ?> |
| 985 |
<span class="bdt-badge upk-unused-widget bdt-danger"></span> |
| 986 |
</a> |
| 987 |
</li> |
| 988 |
</ul> |
| 989 |
|
| 990 |
</div> |
| 991 |
<?php endif; ?> |
| 992 |
|
| 993 |
<?php endif; ?> |
| 994 |
</div> |
| 995 |
</div> |
| 996 |
|
| 997 |
|
| 998 |
<div class="bdt-width-auto@l bdt-search-active-wrap bdt-flex bdt-flex-middle bdt-flex-between"> |
| 999 |
<div class="bdt-widget-search"> |
| 1000 |
<input data-id="upk-options-parent-<?php echo esc_attr($i); ?>" onkeyup="filterSearch(this);" |
| 1001 |
bdt-filter-control="" class="bdt-search-input bdt-flex-middle" type="search" |
| 1002 |
placeholder="<?php esc_html_e('Search widget...', 'ultimate-post-kit'); ?>" |
| 1003 |
autofocus> |
| 1004 |
</div> |
| 1005 |
|
| 1006 |
<div> |
| 1007 |
<ul class="bdt-subnav bdt-subnav-pill upk-widget-onoff"> |
| 1008 |
<li> |
| 1009 |
<a href="#" class="upk-active-all-widget"> |
| 1010 |
<?php esc_html_e('Activate All', 'ultimate-post-kit'); ?> |
| 1011 |
</a> |
| 1012 |
</li> |
| 1013 |
<li> |
| 1014 |
<a href="#" class="upk-deactive-all-widget"> |
| 1015 |
<?php esc_html_e('Deactivate All', 'ultimate-post-kit'); ?> |
| 1016 |
</a> |
| 1017 |
</li> |
| 1018 |
</ul> |
| 1019 |
</div> |
| 1020 |
</div> |
| 1021 |
</div> |
| 1022 |
|
| 1023 |
<?php if ($form['id'] == 'ultimate_post_kit_active_modules'): ?> |
| 1024 |
<div class="upk-content-type-filter bdt-margin-top"> |
| 1025 |
<div class="bdt-flex bdt-flex-wrap bdt-flex-middle bdt-visible@l"> |
| 1026 |
<div class="upk-filter-by-text bdt-visible@xl"> |
| 1027 |
<?php esc_html_e('Filter By: ', 'ultimate-post-kit'); ?> |
| 1028 |
</div> |
| 1029 |
<ul class="bdt-nav xbdt-subnav-pill xbdt-dropdown-nav upk-widget-filter upk-widget-content-type bdt-flex bdt-flex-wrap "> |
| 1030 |
<li class="upk-widget-new" bdt-filter-control="filter: [data-content-type*='new']; group: data-widget-type"> |
| 1031 |
<a href="#"><?php esc_html_e('New', 'ultimate-post-kit'); ?></a> |
| 1032 |
</li> |
| 1033 |
<li class="upk-widget-grid" bdt-filter-control="filter: [data-content-type*='grid']; group: data-widget-type"> |
| 1034 |
<a href="#"><?php esc_html_e('Grid', 'ultimate-post-kit'); ?></a> |
| 1035 |
</li> |
| 1036 |
<li class="upk-widget-list" bdt-filter-control="filter: [data-content-type*='list']; group: data-widget-type"> |
| 1037 |
<a href="#"><?php esc_html_e('List', 'ultimate-post-kit'); ?></a> |
| 1038 |
</li> |
| 1039 |
<li class="upk-widget-carousel" bdt-filter-control="filter: [data-content-type*='carousel']; group: data-widget-type"> |
| 1040 |
<a href="#"><?php esc_html_e('Carousel', 'ultimate-post-kit'); ?></a> |
| 1041 |
</li> |
| 1042 |
<li class="upk-widget-slider" bdt-filter-control="filter: [data-content-type*='slider']; group: data-widget-type"> |
| 1043 |
<a href="#"><?php esc_html_e('Slider', 'ultimate-post-kit'); ?></a> |
| 1044 |
</li> |
| 1045 |
<li class="upk-widget-tabs" bdt-filter-control="filter: [data-content-type*='tabs']; group: data-widget-type"> |
| 1046 |
<a href="#"><?php esc_html_e('Tabs', 'ultimate-post-kit'); ?></a> |
| 1047 |
</li> |
| 1048 |
<li class="upk-widget-timeline" bdt-filter-control="filter: [data-content-type*='timeline']; group: data-widget-type"> |
| 1049 |
<a href="#"><?php esc_html_e('Timeline', 'ultimate-post-kit'); ?></a> |
| 1050 |
</li> |
| 1051 |
<li class="upk-widget-template-builder" bdt-filter-control="filter: [data-content-type*='template-builder']; group: data-widget-type"> |
| 1052 |
<a href="#"><?php esc_html_e('Template Builder', 'ultimate-post-kit'); ?></a> |
| 1053 |
</li> |
| 1054 |
<li class="upk-widget-loop" bdt-filter-control="filter: [data-content-type*='loop']; group: data-widget-type"> |
| 1055 |
<a href="#"><?php esc_html_e('Loop Builder', 'ultimate-post-kit'); ?></a> |
| 1056 |
</li> |
| 1057 |
<li class="upk-widget-others" bdt-filter-control="filter: [data-content-type*='others']; group: data-widget-type"> |
| 1058 |
<a href="#"><?php esc_html_e('Others', 'ultimate-post-kit'); ?></a> |
| 1059 |
</li> |
| 1060 |
</ul> |
| 1061 |
</div> |
| 1062 |
</div> |
| 1063 |
<?php endif; ?> |
| 1064 |
|
| 1065 |
</div> |
| 1066 |
|
| 1067 |
</div> |
| 1068 |
|
| 1069 |
<?php endif; ?> |
| 1070 |
|
| 1071 |
<form class="settings-save" method="post" action="admin-ajax.php?action=ultimate_post_kit_settings_save"> |
| 1072 |
<input type="hidden" name="id" value="<?php echo esc_attr($form['id']); ?>"> |
| 1073 |
|
| 1074 |
<?php |
| 1075 |
|
| 1076 |
if (!current_user_can('manage_options')) { |
| 1077 |
return; |
| 1078 |
} |
| 1079 |
|
| 1080 |
wp_nonce_field('ultimate-post-kit-settings-save-nonce'); |
| 1081 |
|
| 1082 |
do_action('wsa_form_top_' . $form['id'], $form); |
| 1083 |
|
| 1084 |
$this->do_settings_sections($form['id']); |
| 1085 |
|
| 1086 |
do_action('wsa_form_bottom_' . $form['id'], $form); |
| 1087 |
|
| 1088 |
?> |
| 1089 |
|
| 1090 |
</form> |
| 1091 |
</div> |
| 1092 |
</div> |
| 1093 |
<?php } |
| 1094 |
} |
| 1095 |
} |
| 1096 |
|
| 1097 |
endif; |
| 1098 |
|