Ejemplo n.º 1
0
function itro_display_popup()
{
    /* woocommerce shop page identification */
    if (function_exists('is_shop') && function_exists('woocommerce_get_page_id')) {
        if (is_shop()) {
            $woo_shop = true;
            $woo_shop_id = woocommerce_get_page_id('shop');
        }
    } else {
        $woo_shop = NULL;
        $woo_shop_id = NULL;
    }
    /* this condition, control if the popup must or not by displayed in a specified page */
    $selected_page_id = json_decode(itro_get_option('selected_page_id'));
    $id_match = NULL;
    switch (itro_get_option('page_selection')) {
        case 'some':
            if (isset($selected_page_id)) {
                foreach ($selected_page_id as $single_id) {
                    if ($single_id == get_the_id() || $single_id == $woo_shop_id && $woo_shop) {
                        $id_match++;
                    }
                }
            }
            if (is_front_page() && itro_get_option('blog_home') == 'yes' || is_home() && itro_get_option('blog_home') == 'yes') {
                $id_match++;
            }
            if ($id_match != NULL || itro_get_option('preview_id') == get_the_id()) {
                itro_style();
                itro_popup_template();
                itro_popup_js();
            }
            break;
        case 'all':
            itro_style();
            itro_popup_template();
            itro_popup_js();
            break;
        case 'none':
            if (itro_get_option('preview_id') == get_the_id()) {
                itro_style();
                itro_popup_template();
                itro_popup_js();
            }
            break;
    }
}
Ejemplo n.º 2
0
function itro_display_popup()
{
	/* woocommerce shop page identification */
	if( function_exists('is_shop') && function_exists('woocommerce_get_page_id') ) /* if this functions exist, woocommerce is installed! */
	{
		if ( is_shop() ) /* if the actual page is the standard woocommerce shop page */
		{
			$woo_shop = true;
			$woo_shop_id = woocommerce_get_page_id( 'shop' );
		}
	}
	else
	{
		$woo_shop = NULL;
		$woo_shop_id = NULL;
	}	
	
	/* this condition, control if the popup must or not by displayed in a specified page */
	$selected_page_id = json_decode(itro_get_option('selected_page_id'));
	$id_match = NULL;
	/* get the page id */
	global $wp_query;
    $current_page_id = $wp_query->get_queried_object_id();
	
	switch (itro_get_option('page_selection'))
	{
		case 'some':
			if( isset($selected_page_id) ) 
			{
				foreach ($selected_page_id as $single_id)
				{
					if ( $single_id == $current_page_id || ( $single_id == $woo_shop_id && $woo_shop ) ) /* if the selected id is the current page id popup will be displayed OR if the woo_shop_id has been selected and you are in the woocommerce standard shop page ($woo_shop == true), popup will be displayed.  */
					{
						$id_match++;
					}
				}
			}
			if( (is_front_page() && itro_get_option('blog_home') == 'yes') || (is_home() && itro_get_option('blog_home') == 'yes') )
			{
				$id_match++;
			}
			if( $id_match != NULL || itro_get_option('preview_id') == $current_page_id )
			{
				itro_style();
				itro_popup_template();
				itro_popup_js();
			}
		break;
		case 'all':
			itro_style();
			itro_popup_template();
			itro_popup_js();
		break;
		case 'none':
			if( itro_get_option('preview_id') == $current_page_id )
			{
				itro_style();
				itro_popup_template();
				itro_popup_js();
			}
		break;
		
	}
}
/**
 * Shortcode for popup appearing
 *
 * @since 4.9
 *
 */
function itro_popup_shortcode()
{
    global $popup_fired;
    //it check if there is a popup visualization via shortcode or via automatic visualization
    $popup_fired = true;
    ob_start();
    itro_style();
    itro_popup_template();
    itro_popup_js();
    return ob_get_clean();
}