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
state.php
115 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Roles 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 Roles 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_state($args) |
| 25 | { ?> |
| 26 | <li class="extended-widget-opts-tab-roles"> |
| 27 | <a href="#extended-widget-opts-tab-<?php echo $args['id']; ?>-roles" title="<?php _e('Roles', 'widget-options'); ?>"><span class="dashicons dashicons-admin-users"></span> <span class="tabtitle"><?php _e('Roles', 'widget-options'); ?></span></a> |
| 28 | </li> |
| 29 | <?php |
| 30 | } |
| 31 | add_action('extended_widget_opts_tabs', 'widgetopts_tab_state', 3); |
| 32 | |
| 33 | /** |
| 34 | * Called on 'extended_widget_opts_tabcontent' |
| 35 | * create new tab content options for alignment options |
| 36 | */ |
| 37 | function widgetopts_tabcontent_state($args) |
| 38 | { |
| 39 | $roles = get_editable_roles(); |
| 40 | $state = ''; |
| 41 | if (isset($args['params']['roles']['state'])) { |
| 42 | $state = $args['params']['roles']['state']; |
| 43 | } |
| 44 | ?> |
| 45 | <div id="extended-widget-opts-tab-<?php echo $args['id']; ?>-roles" class="extended-widget-opts-tabcontent extended-widget-opts-tabcontent-roles"> |
| 46 | <p class="widgetopts-subtitle"><?php _e('User Login State', 'widget-options'); ?></p> |
| 47 | <p> |
| 48 | <select class="widefat" name="<?php echo $args['namespace']; ?>[extended_widget_opts][roles][state]"> |
| 49 | <option value=""><?php _e('Select Visibility Option', 'widget-options'); ?></option> |
| 50 | <option value="in" <?php if ($state == 'in') { |
| 51 | echo 'selected="selected"'; |
| 52 | } ?>><?php _e('Show only for Logged-in Users', 'widget-options'); ?></option> |
| 53 | <option value="out" <?php if ($state == 'out') { |
| 54 | echo 'selected="selected"'; |
| 55 | } ?>><?php _e('Show only for Logged-out Users', 'widget-options'); ?></option> |
| 56 | </select> |
| 57 | </p> |
| 58 | <p><small><?php _e('Restrict widget visibility for logged-in and logged-out users. ', 'widget-options'); ?></small></p> |
| 59 | |
| 60 | <div class="extended-widget-opts-demo-feature"> |
| 61 | <div class="extended-widget-opts-demo-warning"> |
| 62 | <p class="widgetopts-unlock-features"> |
| 63 | <span class="dashicons dashicons-lock"></span><br> |
| 64 | Unlock all Features<br> |
| 65 | <a href="https://widget-options.com/?utm_source=wordpressadmin&utm_medium=widgettabs&utm_campaign=widgetoptsprotab" class="button-primary" target="_blank">Learn More</a> |
| 66 | </p> |
| 67 | </div> |
| 68 | <p class="widgetopts-subtitle"><?php _e('User Roles', 'widget-options'); ?></p> |
| 69 | <p> |
| 70 | <strong><?php _e('Hide/Show', 'widget-options'); ?></strong> |
| 71 | <select class="widefat" readonly> |
| 72 | <option value="hide"><?php _e('Hide on checked roles', 'widget-options'); ?></option> |
| 73 | <option value="show"><?php _e('Show on checked roles', 'widget-options'); ?></option> |
| 74 | </select> |
| 75 | </p> |
| 76 | <div class="extended-widget-opts-inner-roles" style="max-height: 230px;padding: 5px;overflow:auto;"> |
| 77 | <table class="form-table"> |
| 78 | <tbody> |
| 79 | <tr valign="top"> |
| 80 | <td scope="row"><strong><?php _e('Roles', 'widget-options'); ?></strong></td> |
| 81 | <td> </td> |
| 82 | </tr> |
| 83 | <?php foreach ($roles as $role_name => $role_info) { |
| 84 | if (isset($args['params']) && isset($args['params']['roles'])) { |
| 85 | if (isset($args['params']['roles'][$role_name])) { |
| 86 | $checked = 'checked="checked"'; |
| 87 | } else { |
| 88 | $checked = ''; |
| 89 | } |
| 90 | } else { |
| 91 | $checked = ''; |
| 92 | } |
| 93 | ?> |
| 94 | <tr valign="top"> |
| 95 | <td scope="row"><label for="extended_widget_opts-<?php echo $args['id']; ?>-role-<?php echo $role_name; ?>"><?php echo $role_info['name']; ?></label></td> |
| 96 | <td> |
| 97 | <input type="checkbox" value="1" readonly /> |
| 98 | </td> |
| 99 | </tr> |
| 100 | <?php } ?> |
| 101 | <tr valign="top"> |
| 102 | <td scope="row"><?php _e('Guests', 'widget-options'); ?></td> |
| 103 | <td> |
| 104 | <input type="checkbox" value="1" readonly /> |
| 105 | </td> |
| 106 | </tr> |
| 107 | </tbody> |
| 108 | </table> |
| 109 | </div> |
| 110 | <p><small><?php _e('Restrict widget visibility per user roles.', 'widget-options'); ?></small></p> |
| 111 | </div> |
| 112 | </div> |
| 113 | <?php |
| 114 | } |
| 115 | add_action('extended_widget_opts_tabcontent', 'widgetopts_tabcontent_state'); ?> |