alignment.php
4 years ago
devices.php
4 years ago
settings.php
4 years ago
state.php
4 years ago
upsell.php
4 years ago
visibility.php
4 years ago
state.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Roles Widget Options |
| 4 | * |
| 5 | * @copyright Copyright (c) 2015, Jeffrey Carandang |
| 6 | * @since 1.0 |
| 7 | */ |
| 8 | |
| 9 | // Exit if accessed directly |
| 10 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 11 | |
| 12 | /** |
| 13 | * Add Roles Widget Options Tab |
| 14 | * |
| 15 | * @since 1.0 |
| 16 | * @return void |
| 17 | */ |
| 18 | |
| 19 | /** |
| 20 | * Called on 'extended_widget_opts_tabs' |
| 21 | * create new tab navigation for alignment options |
| 22 | */ |
| 23 | function widgetopts_tab_state( $args ){ ?> |
| 24 | <li class="extended-widget-opts-tab-roles"> |
| 25 | <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> |
| 26 | </li> |
| 27 | <?php |
| 28 | } |
| 29 | add_action( 'extended_widget_opts_tabs', 'widgetopts_tab_state' ); |
| 30 | |
| 31 | /** |
| 32 | * Called on 'extended_widget_opts_tabcontent' |
| 33 | * create new tab content options for alignment options |
| 34 | */ |
| 35 | function widgetopts_tabcontent_state( $args ){ |
| 36 | $roles = get_editable_roles(); |
| 37 | $state = ''; |
| 38 | if( isset( $args['params']['roles'][ 'state' ] ) ){ |
| 39 | $state = $args['params']['roles'][ 'state' ]; |
| 40 | } |
| 41 | ?> |
| 42 | <div id="extended-widget-opts-tab-<?php echo $args['id'];?>-roles" class="extended-widget-opts-tabcontent extended-widget-opts-tabcontent-roles"> |
| 43 | <p class="widgetopts-subtitle"><?php _e( 'User Login State', 'widget-options' );?></p> |
| 44 | <p> |
| 45 | <select class="widefat" name="<?php echo $args['namespace'];?>[extended_widget_opts][roles][state]"> |
| 46 | <option value=""><?php _e( 'Select Visibility Option', 'widget-options' );?></option> |
| 47 | <option value="in" <?php if( $state == 'in' ){ echo 'selected="selected"'; }?> ><?php _e( 'Show only for Logged-in Users', 'widget-options' );?></option> |
| 48 | <option value="out" <?php if( $state == 'out' ){ echo 'selected="selected"'; }?>><?php _e( 'Show only for Logged-out Users', 'widget-options' );?></option> |
| 49 | </select> |
| 50 | </p> |
| 51 | <p><small><?php _e( 'Restrict widget visibility for logged-in and logged-out users. ', 'widget-options' );?></small></p> |
| 52 | </div> |
| 53 | <?php |
| 54 | } |
| 55 | add_action( 'extended_widget_opts_tabcontent', 'widgetopts_tabcontent_state'); ?> |
| 56 |