• Resolved jrxpress

    (@jrxpress)


    This plugin is perfect and exactly what I need for my current project.

    Whatever I am not able to select it to only display on the selected page, for example: Home Page only.

    Popup Settings –> Page –> Select Page: doesn’t matter what page we choose it will always display on “All Pages”.

    I would like to be able to have the popup only available on the Home Page and not on each single page, over and over!

    Is there any little fix to resolve it?

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter jrxpress

    (@jrxpress)

    I was able to fix it and here is my code just in case someone else has the same issue. Just update the cs-popup-maker.php file with the code bellow:

    
    if ( ! defined( 'ABSPATH' ) )
        exit;
    
    define( 'CSP_VERSION', '1.0.1' );
    define( 'CSP_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
    define( 'CSP_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
    
    if ( !class_exists( 'casqrPopupInit' ) ) {
        class casqrPopupInit {
    
            public function __construct() {
                if ( is_admin() ) {
                    require_once( CSP_PLUGIN_DIR . '/includes/Admin.class.php' );
                    new csPopupSettings();
                } else {
                    add_action('wp', array( $this, 'show_popup' ) );
                }
            }
    
            public function enqueue_scripts() {
                $min = '';
                if( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
                    $min = '.min';
                }
                wp_register_style( 'cspopup-style', CSP_PLUGIN_URL.'/css/cs-popupmaker'. $min . '.css', array(), CSP_VERSION );
                wp_enqueue_style( 'cspopup-style' );
                
                wp_register_script( 'cspopup-main-script', CSP_PLUGIN_URL.'/js/cs-main-script'. $min . '.js', array( 'jquery', 'underscore' ), CSP_VERSION );
                wp_enqueue_script( 'cspopup-main-script');
                # Localize the script with new data                
                wp_localize_script( 'cspopup-main-script', 'cs_obj', $this->localized_script() );
            }
            
            public function show_popup() {
                global $wp_query;
    
                $post_id = $wp_query->post->ID;
                $cspopup = get_option('cs-popup');
                $flag = 0;
                if ( isset($cspopup['cs_popup_status']) && $cspopup['cs_popup_status'] == 1 ) {
                if ( $cspopup['cs_popup_page'] != '' ){
                    if ( $cspopup['cs_popup_page'] == -1 ){
                        $flag = 1;
                    } else {
                    if ( $cspopup['cs_popup_page'] == 0 && ( is_home() || is_front_page() ) ) {
                        $flag = 1;
                    }
                    else if ( $post_id == $cspopup['cs_popup_page'] ) {
                        $flag = 1;
                    }
                    }
                }
                }
                if ( $flag == 1 ) {
                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
                }
            }
            
            public function localized_script() {
                $cspopup = get_option( 'cs-popup' );
                $cspopup_settings = array();
                $cspopup_settings['cs_popup_status'] = ( isset($cspopup['cs_popup_status'] ) && 1 == $cspopup['cs_popup_status'] ) ? 1 : 0;
                $cspopup_settings['image_url'] = $cspopup['cs_popup_image'];
                $cspopup_settings['target_url'] = $cspopup['cs_popup_target'];
                $cspopup_settings['close_link'] = CSP_PLUGIN_URL.'/images/close.png';
                return $cspopup_settings;
            }
        }
    }
    
    new casqrPopupInit();
    
    • This reply was modified 5 years, 1 month ago by jrxpress.
Viewing 1 replies (of 1 total)
  • The topic ‘Popup Settings’ is closed to new replies.