Ejemplo n.º 1
0
/**
 * Enqueue scripts and styles.
 */
function listable_scripts()
{
    $theme = wp_get_theme();
    //if there is no mapbox token use Google Maps instead
    if ('' == listable_get_option('mapbox_token', '')) {
        wp_deregister_script('google-maps');
        wp_enqueue_script('google-maps', '//maps.google.com/maps/api/js?v=3.exp&libraries=places', array(), '3.22', true);
        $listable_scripts_deps[] = 'google-maps';
    } elseif (wp_script_is('google-maps') || listable_using_facetwp()) {
        wp_deregister_script('google-maps');
        wp_enqueue_script('google-maps', '//maps.google.com/maps/api/js?v=3.exp&libraries=places', array(), '3.22', false);
        $listable_scripts_deps[] = 'google-maps';
    }
    wp_deregister_style('wc-paid-listings-packages');
    wp_deregister_style('wc-bookings-styles');
    $main_style_deps = array();
    //only enqueue the de default font if Customify is not present
    if (!class_exists('PixCustomifyPlugin')) {
        wp_enqueue_style('listable-default-fonts', 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,600,700');
        $main_style_deps[] = 'listable-default-fonts';
    }
    if (!is_rtl()) {
        wp_enqueue_style('listable-style', get_template_directory_uri() . '/style.css', $main_style_deps, $theme->get('Version'));
    }
    if (class_exists('LoginWithAjax')) {
        wp_enqueue_style('listable-login-with-ajax', get_template_directory_uri() . '/assets/css/login-with-ajax.css', $main_style_deps, $theme->get('Version'));
    }
    global $post;
    $listable_scripts_deps = array('jquery');
    if (isset($post->post_content) && has_shortcode($post->post_content, 'jobs') && true === listable_jobs_shortcode_get_show_map_param($post->post_content) || is_single() && 'job_listing' == $post->post_type || is_search() || isset($post->post_content) && is_archive() && 'job_listing' == $post->post_type || is_tax(array('job_listing_category', 'job_listing_tag', 'job_listing_region')) || isset($post->post_content) && has_shortcode($post->post_content, 'submit_job_form')) {
        wp_enqueue_script('leafletjs', get_template_directory_uri() . '/assets/js/plugins/leaflet.js', array('jquery'), '1.0.0', true);
        $listable_scripts_deps[] = 'leafletjs';
    }
    wp_enqueue_script('listable-scripts', get_template_directory_uri() . '/assets/js/main.js', $listable_scripts_deps, $theme->get('Version'), true);
    if (is_singular() && comments_open() && get_option('thread_comments')) {
        wp_enqueue_script('comment-reply');
    }
    wp_localize_script('listable-scripts', 'listable_params', array('login_url' => rtrim(esc_url(wp_login_url()), '/'), 'strings' => array('wp-job-manager-file-upload' => esc_html__('Add Photo', 'listable'), 'no_job_listings_found' => esc_html__('No results', 'listable'), 'results-no' => esc_html__('Results', 'listable'))));
}
Ejemplo n.º 2
0
function listable_listings_page_shortcode_get_show_map_param()
{
    //if there is a page set in the Listings settings use that
    $listings_page_id = get_option('job_manager_jobs_page_id', false);
    if (false !== $listings_page_id) {
        $listings_page = get_post($listings_page_id);
        if (!is_wp_error($listings_page)) {
            return listable_jobs_shortcode_get_show_map_param($listings_page->post_content);
        }
    }
    //by default we will show the map
    return true;
}