Plugin Directory

Changeset 994181


Ignore:
Timestamp:
09/21/2014 12:44:17 PM (11 years ago)
Author:
numixtech
Message:

Added Sticky popup enable and disable feature

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sticky-popup/trunk/class-sticky-popup.php

    r983626 r994181  
    4848
    4949    /**
     50     * Stores popup active status
     51     *
     52     * @since 1.1
     53     *
     54     * @var string
     55     */
     56    protected $popup_active;
     57
     58    /**
    5059     * Stores popup title option
    5160     *
     
    153162    public function __construct() {
    154163
     164        $this->popup_active = get_option( 'sp_popup_active' );
    155165        $this->popup_title  = get_option( 'sp_popup_title' );
    156166        $this->popup_title_color  = get_option( 'sp_popup_title_color' );
     
    183193       
    184194        $show_sticky_poup=false;
    185         if($this->show_on_homepage!=1 && $this->show_on_posts!=1 && $this->show_on_pages!=1 )
     195        if($this->popup_active)
    186196        {
    187             $show_sticky_poup=true;
    188                
    189         }
    190         else
    191         {               
    192             if( $this->show_on_homepage==1 && is_front_page() )
    193             {
    194                 $show_sticky_poup=true;                 
    195             }
    196             if( $this->show_on_posts==1 && ( is_single() || is_home() || is_archive() ) )
    197             {
    198                 $show_sticky_poup=true;
    199             }
    200             if( $this->show_on_pages==1 && is_page() )
     197            if($this->show_on_homepage!=1 && $this->show_on_posts!=1 && $this->show_on_pages!=1 )
    201198            {
    202199                $show_sticky_poup=true;
    203             }
    204         }
    205         if($show_sticky_poup)
    206         {
    207             add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    208             add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    209             add_action( 'wp_head', array( $this, 'head_styles' ) );
    210             add_filter( 'wp_footer', array( $this, 'get_sticky_popup' ) );
    211             add_action( 'wp_footer', array( $this, 'footer_scripts' ) );
     200                   
     201            }
     202            else
     203            {               
     204                if( $this->show_on_homepage==1 && is_front_page() )
     205                {
     206                    $show_sticky_poup=true;                 
     207                }
     208                if( $this->show_on_posts==1 && ( is_single() || is_home() || is_archive() ) )
     209                {
     210                    $show_sticky_poup=true;
     211                }
     212                if( $this->show_on_pages==1 && is_page() )
     213                {
     214                    $show_sticky_poup=true;
     215                }
     216            }
     217            if($show_sticky_poup)
     218            {
     219                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
     220                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
     221                add_action( 'wp_head', array( $this, 'head_styles' ) );
     222                add_filter( 'wp_footer', array( $this, 'get_sticky_popup' ) );
     223                add_action( 'wp_footer', array( $this, 'footer_scripts' ) );
     224            }
    212225        }
    213226    }
     
    301314        if ( ! empty( $_POST ) && check_admin_referer( 'sticky_popup', 'save_sticky_popup' ) ) {
    302315
     316
     317           
     318
     319            //add or update sticky popup active stats
     320            if ( $this->popup_active !== false ) {
     321                update_option( 'sp_popup_active', $_POST['popup_active'] );
     322            } else {
     323                add_option( 'sp_popup_active', $_POST['popup_active'], null, 'no' );
     324            }
     325
    303326            //add or update sticky popup title options
    304327            if ( $this->popup_title !== false ) {
     
    382405                <div class="sticky_popup_form">
    383406                    <table class="form-table" width="100%">
     407                        <tr>
     408                            <th scope="row"></th>
     409                            <td>                               
     410                                <input type="checkbox" name="popup_active" id="popup_active" value="1" <?php if($this->popup_active)  echo 'checked="checked"'; else '';?>>&nbsp;<label for="popup_active"><strong><?php _e( 'Enable', 'sticky-popup' );?></strong></label></td>
     411                        </tr>
    384412                        <tr>
    385413                            <th scope="row"><label for="popup_title"><?php _e( 'Popup Title', 'sticky-popup' );?></label></th>
     
    510538     */
    511539    public function get_sticky_popup(){
     540        $this->popup_active = get_option( 'sp_popup_active' );
    512541        $this->popup_place  = get_option( 'sp_popup_place' );
    513542        $this->popup_title  = get_option( 'sp_popup_title' );
Note: See TracChangeset for help on using the changeset viewer.