示例#1
0
function idf_lightbox()
{
    wp_register_script('idf-lite', plugins_url('js/idf-lite.js', __FILE__));
    wp_register_script('idf', plugins_url('js/idf.js', __FILE__));
    wp_register_style('magnific', plugins_url('lib/magnific/magnific.css', __FILE__));
    wp_register_script('magnific', plugins_url('lib/magnific/magnific.js', __FILE__));
    wp_register_style('idf', plugins_url('css/idf.css', __FILE__));
    wp_enqueue_script('jquery');
    if (idf_enable_checkout()) {
        $checkout_url = '';
        $platform = idf_platform();
        if ($platform == 'wc' && !is_admin()) {
            if (class_exists('WooCommerce')) {
                global $woocommerce;
                $checkout_url = $woocommerce->cart->get_checkout_url();
            }
        } else {
            if ($platform == 'edd' && class_exists('Easy_Digital_Downloads') && !is_admin()) {
                $checkout_url = edd_get_checkout_uri();
            } else {
                if ($platform == 'itexchange' && class_exists('IT_Exchange') && !is_admin()) {
                    // Getting checkout URL for iT exchange product
                    global $post;
                    $post_id = $post->ID;
                    $checkout_links = array();
                    // Get levels and setting url for each level
                    $number_of_levels = get_post_meta($post_id, "ign_product_level_count", true);
                    for ($i = 1; $i <= $number_of_levels; $i++) {
                        $iditexch_project_id = get_post_meta($post_id, 'iditexch_level_pairing_' . $i, true);
                        $checkout_links[$i]['url'] = get_permalink($iditexch_project_id);
                        $checkout_links[$i]['product'] = $iditexch_project_id;
                    }
                    $checkout_url = json_encode($checkout_links);
                }
            }
        }
        wp_enqueue_style('magnific');
        wp_enqueue_style('idf');
        wp_enqueue_script('idf');
        wp_enqueue_script('magnific');
        wp_localize_script('idf', 'idf_platform', $platform);
        // Let's set the ajax url
        $idf_ajaxurl = site_url('/wp-admin/admin-ajax.php');
        wp_localize_script('idf', 'idf_siteurl', site_url());
        wp_localize_script('idf', 'idf_ajaxurl', $idf_ajaxurl);
        if (isset($checkout_url)) {
            wp_localize_script('idf', 'idf_checkout_url', $checkout_url);
        }
    } else {
        wp_enqueue_script('idf-lite');
    }
}
示例#2
0
文件: idf.php 项目: mariuskarma/wp
function idf_lightbox()
{
    wp_register_script('idf-lite', plugins_url('js/idf-lite.js', __FILE__));
    wp_register_script('idf', plugins_url('js/idf.js', __FILE__));
    wp_register_style('magnific', plugins_url('lib/magnific/magnific.css', __FILE__));
    wp_register_script('magnific', plugins_url('lib/magnific/magnific.js', __FILE__));
    wp_register_style('idf', plugins_url('css/idf.css', __FILE__));
    wp_enqueue_script('jquery');
    if (idf_enable_checkout()) {
        $platform = idf_platform();
        if ($platform == 'wc' && class_exists('WooCommerce') && !is_admin()) {
            global $woocommerce;
            $checkout_url = $woocommerce->cart->get_checkout_url();
        } else {
            if ($platform == 'edd' && class_exists('Easy_Digital_Downloads') && !is_admin()) {
                $checkout_url = edd_get_checkout_uri();
            }
        }
        wp_enqueue_style('magnific');
        wp_enqueue_style('idf');
        wp_enqueue_script('idf');
        wp_enqueue_script('magnific');
        wp_localize_script('idf', 'idf_platform', $platform);
        // Let's set the ajax url
        $idf_ajaxurl = site_url('/wp-admin/admin-ajax.php');
        wp_localize_script('idf', 'idf_siteurl', site_url());
        wp_localize_script('idf', 'idf_ajaxurl', $idf_ajaxurl);
        if (isset($checkout_url)) {
            wp_localize_script('idf', 'idf_checkout_url', $checkout_url);
        }
    } else {
        wp_enqueue_script('idf-lite');
    }
    wp_register_style('magnific', plugins_url('lib/magnific/magnific.css', __FILE__));
    wp_enqueue_style('magnific');
}