alignment.php
1 month ago
animation.php
1 month ago
behavior.php
1 month ago
days-dates.php
1 month ago
devices.php
1 month ago
settings.php
1 month ago
state.php
1 month ago
styling.php
1 month ago
upsell.php
1 month ago
visibility.php
1 month ago
devices.php
105 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Devices Visibility Widget Options |
| 5 | * |
| 6 | * @copyright Copyright (c) 2015, Jeffrey Carandang |
| 7 | * @since 1.0 |
| 8 | */ |
| 9 | |
| 10 | // Exit if accessed directly |
| 11 | if (!defined('ABSPATH')) exit; |
| 12 | |
| 13 | /** |
| 14 | * Add Alignment Widget Options Tab |
| 15 | * |
| 16 | * @since 1.0 |
| 17 | * @return void |
| 18 | */ |
| 19 | |
| 20 | /** |
| 21 | * Called on 'extended_widget_opts_tabs' |
| 22 | * create new tab navigation for alignment options |
| 23 | */ |
| 24 | function widgetopts_tab_devices($args) |
| 25 | { ?> |
| 26 | <li class="extended-widget-opts-tab-devices"> |
| 27 | <a href="#extended-widget-opts-tab-<?php echo $args['id']; ?>-devices" title="<?php _e('Devices', 'widget-options'); ?>"><span class="dashicons dashicons-smartphone"></span> <span class="tabtitle"><?php _e('Devices', 'widget-options'); ?></span></a> |
| 28 | </li> |
| 29 | <?php |
| 30 | } |
| 31 | add_action('extended_widget_opts_tabs', 'widgetopts_tab_devices', 4); |
| 32 | |
| 33 | /** |
| 34 | * Called on 'extended_widget_opts_tabcontent' |
| 35 | * create new tab content options for devices visibility options |
| 36 | */ |
| 37 | function widgetopts_tabcontent_devices($args) |
| 38 | { |
| 39 | $desktop = ''; |
| 40 | $tablet = ''; |
| 41 | $mobile = ''; |
| 42 | $options_role = ''; |
| 43 | if (isset($args['params']) && isset($args['params']['devices'])) { |
| 44 | if (isset($args['params']['devices']['options'])) { |
| 45 | $options_role = $args['params']['devices']['options']; |
| 46 | } |
| 47 | if (isset($args['params']['devices']['desktop'])) { |
| 48 | $desktop = $args['params']['devices']['desktop']; |
| 49 | } |
| 50 | if (isset($args['params']['devices']['tablet'])) { |
| 51 | $tablet = $args['params']['devices']['tablet']; |
| 52 | } |
| 53 | if (isset($args['params']['devices']['mobile'])) { |
| 54 | $mobile = $args['params']['devices']['mobile']; |
| 55 | } |
| 56 | } |
| 57 | ?> |
| 58 | <div id="extended-widget-opts-tab-<?php echo $args['id']; ?>-devices" class="extended-widget-opts-tabcontent extended-widget-opts-tabcontent-devices"> |
| 59 | <p> |
| 60 | <strong><?php _e('Hide/Show', 'widget-options'); ?></strong> |
| 61 | <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][devices][options]"> |
| 62 | <option value="hide" <?php if ($options_role == 'hide') { |
| 63 | echo 'selected="selected"'; |
| 64 | } ?>><?php _e('Hide on checked devices', 'widget-options'); ?></option> |
| 65 | <option value="show" <?php if ($options_role == 'show') { |
| 66 | echo 'selected="selected"'; |
| 67 | } ?>><?php _e('Show on checked devices', 'widget-options'); ?></option> |
| 68 | </select> |
| 69 | </p> |
| 70 | <table class="form-table"> |
| 71 | <tbody> |
| 72 | <tr valign="top"> |
| 73 | <td scope="row"><strong><?php _e('Devices', 'widget-options'); ?></strong></td> |
| 74 | <td> </td> |
| 75 | </tr> |
| 76 | <tr valign="top"> |
| 77 | <td scope="row"><span class="dashicons dashicons-desktop"></span> <label for="extended_widget_opts-<?php echo $args['id']; ?>-devices-desktop"><?php _e('Desktop', 'widget-options'); ?></label></td> |
| 78 | <td> |
| 79 | <input type="checkbox" name="<?php echo $args['namespace']; ?>[extended_widget_opts][devices][desktop]" value="1" id="extended_widget_opts-<?php echo $args['id']; ?>-devices-desktop" <?php if (!empty($desktop)) { |
| 80 | echo 'checked="checked"'; |
| 81 | } ?> /> |
| 82 | </td> |
| 83 | </tr> |
| 84 | <tr valign="top"> |
| 85 | <td scope="row"><span class="dashicons dashicons-tablet"></span> <label for="extended_widget_opts-<?php echo $args['id']; ?>-devices-table"><?php _e('Tablet', 'widget-options'); ?></label></td> |
| 86 | <td> |
| 87 | <input type="checkbox" name="<?php echo $args['namespace']; ?>[extended_widget_opts][devices][tablet]" value="1" id="extended_widget_opts-<?php echo $args['id']; ?>-devices-table" <?php if (!empty($tablet)) { |
| 88 | echo 'checked="checked"'; |
| 89 | } ?> /> |
| 90 | </td> |
| 91 | </tr> |
| 92 | <tr valign="top"> |
| 93 | <td scope="row"><span class="dashicons dashicons-smartphone"></span> <label for="extended_widget_opts-<?php echo $args['id']; ?>-devices-mobile"><?php _e('Mobile', 'widget-options'); ?></label></td> |
| 94 | <td> |
| 95 | <input type="checkbox" name="<?php echo $args['namespace']; ?>[extended_widget_opts][devices][mobile]" value="1" id="extended_widget_opts-<?php echo $args['id']; ?>-devices-mobile" <?php if (!empty($mobile)) { |
| 96 | echo 'checked="checked"'; |
| 97 | } ?> /> |
| 98 | </td> |
| 99 | </tr> |
| 100 | </tbody> |
| 101 | </table> |
| 102 | </div> |
| 103 | <?php |
| 104 | } |
| 105 | add_action('extended_widget_opts_tabcontent', 'widgetopts_tabcontent_devices'); ?> |