Пример #1
0
/**
 * Enqueue scripts and styles.
 *
 * @since Twenty Fifteen 1.0
 */
function iscp_scripts()
{
    wp_enqueue_style('style', get_template_directory_uri() . '/assets/css/styles.css');
    wp_register_script('transit', get_template_directory_uri() . '/assets/js/jquery.transit.min.js', array('jquery'));
    wp_register_script('jquery-ui', get_template_directory_uri() . '/assets/js/jquery-ui.min.js', array('jquery'));
    wp_register_script('imagesloaded', get_template_directory_uri() . '/assets/js/imagesloaded.pkgd.min.js', array('jquery'));
    wp_register_script('masonry', get_template_directory_uri() . '/assets/js/masonry.pkgd.min.js', array('jquery'));
    wp_register_script('main', get_template_directory_uri() . '/assets/js/main.js', array('jquery', 'masonry', 'transit', 'jquery-ui'));
    wp_enqueue_script('webglearth', 'http://www.webglearth.com/v2/api.js');
    wp_enqueue_script('transit');
    wp_enqueue_script('jquery-ui');
    wp_enqueue_script('masonry');
    wp_enqueue_script('imagesloaded');
    wp_enqueue_script('main');
    global $post;
    $page_slug = $post->post_name;
    $with_map = array('map', 'past-residents', 'current-residents');
    if (in_array($page_slug, $with_map)) {
        $countries_query = array('post_type' => 'country', 'posts_per_page' => -1, 'post_status' => 'publish');
        $countries = new WP_Query($countries_query);
        $countries_array = array();
        while ($countries->have_posts()) {
            $countries->the_post();
            global $post;
            setup_postdata($post);
            $country_id = $post->ID;
            $country = array('name' => $post->post_title, 'slug' => $post->post_name, 'lat' => get_field('latitude', $country_id), 'lng' => get_field('longitude', $country_id), 'count' => get_resident_count('country', $country_id));
            $countries_array[] = $country;
            wp_reset_postdata();
        }
        $json = json_decode(json_encode($countries_array), true);
        wp_localize_script('main', 'countries', $json);
    }
    global $wp_query;
    wp_localize_script('main', 'ajaxpagination', array('ajaxurl' => admin_url('admin-ajax.php'), 'query_vars' => json_encode($wp_query->query)));
    wp_localize_script('main', 'wp_info', array('theme_url' => get_stylesheet_directory_uri()));
}
Пример #2
0
    }
}
?>
	</div>
</div>

<div class="filter-list type <?php 
echo $slug;
?>
" data-filter="type">
	<div class="options">
		<?php 
$resident_types = array('artist', 'curator');
foreach ($resident_types as $type) {
    if ($short_slug == 'current' || $page_type == 'sponsor') {
        $type_count = get_resident_count('type', $type, $count_query);
    } else {
        $type_count = true;
    }
    if ($type_count) {
        $classes = $type;
        if ($type_param == $type) {
            $classes .= ' selected';
            $remove = true;
        } else {
            $remove = false;
        }
        $type_title = ucwords($type);
        $filter_url = query_url('type', $type, $page_url, $short_slug, $remove);
        echo '<div class="option ' . $classes . '">';
        echo '<a href="' . $filter_url . '" data-value="' . $type . '">';
Пример #3
0
<?php

if ($query_vars) {
    $pageType = $query_vars['pagename'];
    if (strpos($pageType, 'residents')) {
        $pageType = 'residents';
    }
    include locate_template('sections/params/' . $pageType . '.php');
    $query_vars = json_decode(stripslashes($_POST['query_vars']), true);
    $options = $query_vars['options'];
    $counts = array();
    foreach ($options as $index => $option) {
        $type = $option['type'];
        $value = $option['value'];
        $_value = $value;
        if ($type == 'country' && !is_numeric($value)) {
            $value = get_page_by_path($value, OBJECT, 'country')->ID;
        }
        $count = get_resident_count($type, $value, $query);
        $array = array('type' => $type, 'value' => $_value, 'count' => $count);
        $counts[$index] = $array;
    }
    echo json_encode($counts);
}