Plugin Directory

Changeset 1676057


Ignore:
Timestamp:
06/11/2017 05:38:57 PM (9 years ago)
Author:
gchoyal1
Message:

HIde/Show Popup for loggedin Users setting option

Location:
choyal-subscription-popup/tags/2.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • choyal-subscription-popup/tags/2.0/csp-settings.php

    r1675416 r1676057  
    2020       
    2121        <tr>
     22            <th scope="row"><label for="csp_popup_disable">Disable Popup</label></th>
     23            <td><input name="csp_popup_disable" type="checkbox" id="csp_popup_disable" value="yes" <?php if( sanitize_text_field( get_option('disable-popup') ) == 'yes' ){ echo 'checked'; } ?> ></td>
     24        </tr>
     25       
     26        <tr>
     27            <th scope="row"><label for="csp_hide_popup_login_users">Hide Popup for loggedin users</label></th>
     28            <td><input name="csp_hide_popup_login_users" type="checkbox" id="csp_hide_popup_login_users" value="yes" <?php if( sanitize_text_field( get_option('csp-hide-popup-login-users') ) == 'yes' ){ echo 'checked'; } ?> ></td>
     29        </tr>
     30       
     31        <tr>
     32            <th scope="row"><label for="csp_popup_fname_lname">Disable First/Last Name field</label></th>
     33            <td>
     34            <input name="csp_popup_fname_lname" type="checkbox" id="csp_popup_fname_lname" value="yes" <?php if( sanitize_text_field( get_option('disable-fname-lname') ) == 'yes' ){ echo 'checked'; } ?> >
     35            </td>
     36        </tr>
     37       
     38        <tr>
    2239        <th scope="row"><label for="csp_popup_title">Popup Title</label></th>
    2340        <td><input name="csp_popup_title" type="text" id="csp_popup_title" value="<?php echo esc_html( stripslashes( get_option('csp-popup-title') ) ); ?>" placeholder="Join our subscribers" class="regular-text code">
     
    2946        <td>
    3047            <textarea name="csp_popup_text" id="csp_popup_text" placeholder="Sign up here and we'll keep you in the loop on all things product" class="regular-text code" ><?php echo esc_textarea( stripslashes( get_option('csp-popup-text') ) ); ?></textarea>
    31         </td>
    32         </tr>
    33        
    34         <tr>
    35             <th scope="row"><label for="csp_popup_disable">Disable Popup</label></th>
    36             <td><input name="csp_popup_disable" type="checkbox" id="csp_popup_disable" value="yes" <?php if( sanitize_text_field( get_option('disable-popup') ) == 'yes' ){ echo 'checked'; } ?> ></td>
    37         </tr>
    38        
    39         <tr>
    40         <th scope="row"><label for="csp_popup_fname_lname">Disable First/Last Name field's in Subscription form</label></th>
    41         <td>
    42         <input name="csp_popup_fname_lname" type="checkbox" id="csp_popup_fname_lname" value="yes" <?php if( sanitize_text_field( get_option('disable-fname-lname') ) == 'yes' ){ echo 'checked'; } ?> >
    4348        </td>
    4449        </tr>
     
    5560       
    5661        </tbody></table>
    57    
    58     <hr>
    5962   
    6063    <div class="csp-mailchimp-setting">
  • choyal-subscription-popup/tags/2.0/plugin.php

    r1675421 r1676057  
    1717function csp_enqueue_style() {
    1818   
    19     $disablePopup = get_option('disable-popup');
    20    
    21     if( !$disablePopup || $disablePopup == 'no' ){
    22        
    23         wp_enqueue_style( 'csp-style', CSP_ASSETS_PATH. 'css/style.css', false );
     19    if( csp_popup_trigger_display_setting() ){
     20   
     21        wp_enqueue_style( 'csp-style', CSP_ASSETS_PATH. 'css/style.css', false );
    2422   
    2523    }
     
    2927function csp_enqueue_script() {
    3028   
    31     $disablePopup = get_option('disable-popup');
    32    
    33     if( !$disablePopup || $disablePopup == 'no' ){
     29    if( csp_popup_trigger_display_setting() ){
    3430       
    3531        wp_enqueue_script( 'csp-js-validate', CSP_ASSETS_PATH. 'js/jquery.validate.min.js', array('jquery', 'csp-js'), '1.0.0', true );
     
    5349    $textPopup = esc_textarea( stripslashes( get_option('csp-popup-text') ) );
    5450   
    55     $disablePopup = get_option('disable-popup');
    5651    $disableFnameLname = get_option('disable-fname-lname');
    5752   
    58     if( !$disablePopup || $disablePopup == 'no' ){
     53    if( csp_popup_trigger_display_setting() ){
    5954   
    6055    ?>
     
    142137function csp_design_setting(){
    143138   
    144     if( esc_html( get_option('csp-popup-overlay') ) == 'yes' ){
    145    
    146         $overlay = true;
    147        
    148     }else{
    149        
    150         $overlay = false;
    151        
    152     }
    153    
    154     if( floatval( get_option('csp-background-overlay-transparency') ) > 0 ){
    155 
    156         $opacity = floatval( get_option('csp-background-overlay-transparency') );
    157        
    158     }else{
    159 
    160         $opacity = '0.4';
    161        
    162     }
    163    
    164     $style = '<style>';
    165    
    166     if( $overlay ){
    167        
    168         $style .= '.csp_overlay{
    169                     width: 100%;
    170                     height:1200px;
    171                     position: fixed;
    172                     background: rgba(0,0,0,'. $opacity .');
    173                     z-index: 99999999;
    174                     top: 0;
    175                     left: 0;
    176                 }';
    177    
    178     }
    179    
    180     $style .= '</style>';
    181    
    182     echo $style;
     139    if( csp_popup_trigger_display_setting() ){
     140   
     141        if( esc_html( get_option('csp-popup-overlay') ) == 'yes' ){
     142       
     143            $overlay = true;
     144           
     145        }else{
     146           
     147            $overlay = false;
     148           
     149        }
     150       
     151        if( floatval( get_option('csp-background-overlay-transparency') ) > 0 ){
     152
     153            $opacity = floatval( get_option('csp-background-overlay-transparency') );
     154           
     155        }else{
     156
     157            $opacity = '0.4';
     158           
     159        }
     160       
     161        $style = '<style>';
     162       
     163        if( $overlay ){
     164           
     165            $style .= '.csp_overlay{
     166                        width: 100%;
     167                        height:1200px;
     168                        position: fixed;
     169                        background: rgba(0,0,0,'. $opacity .');
     170                        z-index: 99999999;
     171                        top: 0;
     172                        left: 0;
     173                    }';
     174       
     175        }
     176       
     177        $style .= '</style>';
     178       
     179        echo $style;
     180   
     181    }
    183182   
    184183}
     
    526525        }
    527526       
     527        //Hide popup for loggedin user setting option
     528        if( sanitize_text_field( $_POST['csp_hide_popup_login_users'] )!='' ){
     529       
     530            $arySettings['csp-hide-popup-login-users'] = sanitize_text_field( $_POST['csp_hide_popup_login_users'] );
     531       
     532        }else{
     533           
     534            $arySettings['csp-hide-popup-login-users'] = 'no';
     535           
     536        }
     537       
    528538        if( sanitize_text_field( $_POST['csp_popup_mailchimp_integration'] )!='' ){
    529539       
     
    915925
    916926add_action( 'wp_ajax_csp_search_subscribers', 'csp_search_subscribers' );
     927
     928//check popup show or hide setting
     929function csp_popup_trigger_display_setting(){ //Return true/false to show popup
     930   
     931    $showPopup = false;
     932   
     933    $disablePopup = get_option('disable-popup');
     934   
     935    if( !$disablePopup || $disablePopup == 'no' ){
     936       
     937        $hidePopupLoggedin = get_option('csp-hide-popup-login-users');
     938       
     939        if( $hidePopupLoggedin == 'yes' ){
     940           
     941            if( !is_user_logged_in() ){
     942               
     943                $showPopup = true;
     944               
     945            }
     946           
     947        }else{
     948       
     949            $showPopup = true;
     950       
     951        }
     952       
     953    }
     954   
     955    return $showPopup;
     956   
     957}
Note: See TracChangeset for help on using the changeset viewer.