public function pre_get_comments($query) { if (!is_singular('job_listing')) { return; } $sort = isset($_GET['sort-comments']) ? esc_attr($_GET['sort-comments']) : false; $allowed_keys = array_keys(self::get_sort_options()); if (!($sort && in_array($sort, $allowed_keys))) { return; } $args = array('post_id' => get_post()->ID); if (listify_has_integration('wp-job-manager-reviews')) { $key = 'review_average'; } else { $key = 'rating'; } if ('date-desc' == $sort) { } elseif ('date-asc' == $sort) { $query->query_vars['order'] = 'asc'; } elseif ('rating-desc' == $sort) { $query->query_vars['meta_key'] = $key; $query->query_vars['orderby'] = array($key); } elseif ('rating-asc' == $sort) { $query->query_vars['meta_key'] = $key; $query->query_vars['orderby'] = array($key); $query->query_vars['order'] = 'asc'; } elseif ('popular' == $sort) { } // Run the meta query again because for some reason the hook fires too late. $query->meta_query = new WP_Meta_Query(); $query->meta_query->parse_query_vars($query->query_vars); }
public function add_controls($wp_customize) { $this->controls = array('label-singular' => array('label' => __('Singular Label', 'listify')), 'label-plural' => array('label' => __('Plural Label', 'listify')), 'region-bias' => array('label' => __('Base Country', 'listify'), 'type' => 'select', 'description' => __('This controls autocomplete priority, distance units, and more.', 'listify'), 'choices' => listify_has_integration('woocommerce') ? array_merge(array('' => __('None', 'listify')), WC()->countries->get_countries()) : array()), 'social-association' => array('label' => __('Social Profiles', 'listify'), 'type' => 'select', 'description' => __('If associated with a listing the fields will appear on the submission form', 'listify'), 'choices' => array('listing' => __('Associate with listing', 'listify'), 'user' => __('Associate with user', 'listify'))), 'custom-submission' => array('label' => __('Use "directory" submission fields', 'listify'), 'type' => 'checkbox'), 'gallery-comments' => array('label' => __('Allow comments on gallery images', 'listify'), 'type' => 'checkbox'), 'categories-only' => array('label' => __('Use categories only', 'listify'), 'type' => 'checkbox', 'description' => __('Categories will be used to create map markers, and types will be hidden from all other areas. Categories must be enabled in Listings > Settings. <br /><br />Refresh this page in your browser after saving.', 'listify'))); return $wp_customize; }
public function visual_composer($page_templates) { if (listify_has_integration('visual-composer')) { return $page_templates; } unset($page_templates['page-templates/template-home-vc.php']); return $page_templates; }
public function add_controls($wp_customize) { $this->controls = array('nav-cart' => array('label' => __('Display cart icon', 'listify'), 'type' => 'checkbox'), 'nav-search' => array('label' => __('Display search icon', 'listify'), 'type' => 'checkbox'), 'nav-megamenu' => array('label' => __('Secondary Mega Menu Taxonomy', 'listify'), 'type' => 'select', 'choices' => array_merge(array('none' => __('None', 'listify')), $this->get_taxonomies()))); if (listify_has_integration('facetwp')) { unset($this->controls['nav-search']); } return $wp_customize; }
public function add_controls($wp_customize) { $this->controls = array('map-behavior-api-key' => array('label' => __('Google Maps API Key (optional)', 'listify')), 'map-behavior-trigger' => array('label' => __('Info Bubble Trigger', 'listify'), 'type' => 'select', 'choices' => array('mouseover' => __('Hover', 'listify'), 'click' => __('Click', 'listify'))), 'map-behavior-clusters' => array('label' => __('Use Clusters', 'listify'), 'type' => 'checkbox'), 'map-behavior-grid-size' => array('label' => __('Cluster Grid Size (px)', 'listify')), 'map-behavior-autofit' => array('label' => __('Autofit on load', 'listify'), 'type' => 'checkbox'), 'map-behavior-center' => array('label' => __('Default Center Coordinate', 'listify')), 'map-behavior-zoom' => array('label' => __('Default Zoom Level', 'listify'), 'type' => 'select', 'choices' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18')), 'map-behavior-max-zoom' => array('label' => __('Max Zoom In Level', 'listify'), 'type' => 'select', 'choices' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18')), 'map-behavior-max-zoom-out' => array('label' => __('Max Zoom Out Level', 'listify'), 'type' => 'select', 'choices' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18')), 'map-behavior-scrollwheel' => array('label' => __('Zoom with Scrollwheel', 'listify'), 'type' => 'checkbox')); if (!listify_has_integration('facetwp')) { global $listify_job_manager; $this->controls['map-behavior-search-min'] = array('label' => sprintf(__('Search Radius Min (%s)', 'listify'), $listify_job_manager->map->template->unit())); $this->controls['map-behavior-search-max'] = array('label' => sprintf(__('Search Radius Max (%s)', 'listify'), $listify_job_manager->map->template->unit())); $this->controls['map-behavior-search-default'] = array('label' => sprintf(__('Search Radius Default (%s)', 'listify'), $listify_job_manager->map->template->unit())); } return $wp_customize; }
public function setup_actions() { if (!listify_has_integration('wp-job-manager-reviews')) { add_action('comment_form_top', array($this, 'comment_form_top')); add_action('comment_post', array($this, 'comment_post')); add_action('wp_set_comment_status', array($this, 'wp_set_comment_status'), 10, 2); add_action('submit_job_form_save_job_data', array($this, 'open_comments')); add_action('single_job_listing_meta_start', array($this, 'the_rating'), 40); add_action('listify_content_job_listing_footer', array($this, 'the_rating')); add_action('listify_listings_by_term_after', array($this, 'the_rating')); add_action('listify_comment_author_end', array($this, 'output_rating')); } }
public function enqueue_scripts($force = false) { if (!$this->page_needs_map($force)) { return; } wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?v=3&libraries=geometry,places'); wp_enqueue_script('listify-job-manager-map', Listify_Integration::get_url() . 'js/wp-job-manager-map.min.js', array('jquery', 'jquery-ui-slider', 'google-maps', 'underscore'), 20141204); $settings = array('facetwp' => listify_has_integration('facetwp'), 'canvas' => 'job_listings-map-canvas', 'useClusters' => listify_theme_mod('map-behavior-clusters'), 'gridSize' => listify_theme_mod('map-behavior-grid-size'), 'autoFit' => listify_theme_mod('map-behavior-autofit'), 'mapOptions' => array('zoom' => listify_theme_mod('map-behavior-zoom'), 'maxZoom' => listify_theme_mod('map-behavior-max-zoom')), 'searchRadius' => array('min' => listify_theme_mod('map-behavior-search-min'), 'max' => listify_theme_mod('map-behavior-search-max'))); if ('' != ($center = listify_theme_mod('map-behavior-center'))) { $settings['mapOptions']['center'] = $center; } wp_localize_script('listify-job-manager-map', 'listifyMapSettings', apply_filters('listify_map_settings', $settings)); }
function listify_job_listing_archive_has_sidebar() { global $listify_job_manager; $sidebar = is_active_sidebar('archive-job_listing'); $map = 'side' == $listify_job_manager->map->template->position(); $facetwp = false; if (listify_has_integration('facetwp')) { global $listify_facetwp; if ('side' == $listify_facetwp->template->position()) { $facetwp = true; } } if ($sidebar || $facetwp || has_action('listify_sidebar_archive_job_listing_after') && !$map) { return true; } return false; }
<a href="#" class="navigation-bar-toggle"> <i class="ion-navicon-round"></i> <?php echo listify_get_theme_menu_name('primary'); ?> </a> <div class="navigation-bar-wrapper"> <?php wp_nav_menu(array('theme_location' => 'primary', 'container_class' => 'primary nav-menu', 'menu_class' => 'primary nav-menu')); wp_nav_menu(array('theme_location' => 'secondary', 'container_class' => 'secondary nav-menu', 'menu_class' => 'secondary nav-menu')); ?> </div> <?php if (!listify_has_integration('facetwp') && listify_theme_mod('nav-search')) { ?> <a href="#search-navigation" data-toggle="#search-navigation" class="ion-search search-overlay-toggle"></a> <div id="search-navigation" class="search-overlay"> <?php locate_template(array('searchform-header.php', 'searchform.php'), true, false); ?> <a href="#search-navigation" data-toggle="#search-navigation" class="ion-close search-overlay-toggle"></a> </div> <?php } ?> </div> </nav><!-- #site-navigation --> </header><!-- #masthead -->
get_template_part('content', 'none'); ?> <?php } wp_reset_query(); ?> </section> <?php do_action('listify_author_profile_after_listings'); ?> <?php if (listify_has_integration('wp-job-manager-bookmarks')) { ?> <?php global $job_manager_bookmarks; $bookmarks = $job_manager_bookmarks->get_user_bookmarks($author->ID); if (!empty($bookmarks)) { $bookmarks = wp_list_pluck($bookmarks, 'post_id'); $wp_query = new WP_Query(array('post_type' => 'job_listing', 'post__in' => $bookmarks, 'post_status' => 'publish', 'posts_per_page' => 6, 'is_author' => true)); ?> <section id="bookmarks"> <h3 class="section-title"><?php printf(__('%s\'s Favorites (%d)', 'listify'), $display, $wp_query->found_posts);
public function search_icon($items, $args) { if ('primary' != $args->theme_location || !listify_theme_mod('nav-search')) { return $items; } if (listify_has_integration('facetwp')) { return '<li class="menu-item menu-type-link"><a href="' . get_post_type_archive_link('job_listing') . '" class="search-overlay-toggle"></a></li>' . $items; } else { return '<li class="menu-item menu-type-link"><a href="#search-header" data-toggle="#search-header" class="search-overlay-toggle"></a></li>' . $items; } }
/** * Add a title and display switcher below the filters and above the listings. * * @since Listify 1.0.0 * * @return void */ public function style_switcher() { global $wp_query; $style = $this->get_archive_display_style(); ?> <div class="archive-job_listing-filter-title"> <div class="archive-job_listing-layout-wrapper"> <?php do_action('archive_job_listing_layout_before'); ?> <a href="#" data-style="grid" class="archive-job_listing-layout button<?php echo 'grid' == $style ? ' active' : ''; ?> "><span class="ion-grid"></span></a> <a href="#" data-style="list" class="archive-job_listing-layout button<?php echo 'list' == $style ? ' active' : ''; ?> "><span class="ion-navicon-round"></span></a> <?php do_action('archive_job_listing_layout_after'); ?> </div> <h3 class="archive-job_listing-found"> <?php printf(__('<span class="results-found">%s</span> Results Found', 'listify'), listify_has_integration('facetwp') ? do_shortcode('[facetwp counts="true"]') : apply_filters('listify_results_found_default', 0)); ?> </h3> </div> <?php }
/** * Add a submit button to the bottom of the Job Manager filters * * @since Listify 1.0.0 * * @return void */ public function add_submit_button() { if (listify_has_integration('facetwp')) { return; } $label = 'Update Results'; if (is_front_page()) { $label = 'Search'; } $refreshing = __('Loading...', 'listify'); echo '<button type="submit" data-refresh="' . $refreshing . '" data-label="' . $label . '" name="update_results" class="update_results">' . $label . '</button>'; }
<?php do_action('listify_page_before'); ?> <div id="primary" class="container"> <div class="content-area"> <main id="main" class="site-main" role="main"> <?php get_template_part('content', 'page'); ?> <?php if (listify_has_integration('wp-job-manager-wc-paid-listings')) { $defaults = array('before_widget' => '<aside class="listify_widget_wcpl">', 'after_widget' => '</aside>', 'before_title' => '<div class="home-widget-section-title"><h3 class="home-widget-title">', 'after_title' => '%s</h3></div>', 'widget_id' => ''); the_widget('Listify_Widget_WCPL_Pricing_Table', array('title' => '', 'description' => ''), $defaults); } ?> </main> </div> </div> <?php } ?> <?php
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $description = isset($instance['description']) ? esc_attr($instance['description']) : false; $after_title = '<h2 class="home-widget-description">' . $description . '</h2>' . $after_title; ob_start(); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } if (listify_has_integration('facetwp')) { global $listify_facetwp; $facets = isset($instance['facets']) ? array_map('trim', explode(',', $instance['facets'])) : listify_theme_mod('listing-archive-facetwp-defaults'); $_facets = $listify_facetwp->get_homepage_facets($facets); $count = count($_facets); $column = 0 == $count ? 12 : round(12 / $count); if ($count > 4) { $column = 4; } $done = 0; ?> <div class="job_search_form"> <div class="row"> <?php foreach ($_facets as $facet) { ?> <?php if ($count > 4 && $done == 3) { ?> </div><div class="row"> <?php } ?> <div class="search_<?php echo $facet['name']; ?> col-xs-12 col-sm-4 col-md-<?php echo $column; ?> "> <?php echo do_shortcode('[facetwp facet="' . $facet['name'] . '"]'); ?> </div> <?php $done++; } ?> </div> <div class="facetwp-submit row"> <div class="col-xs-12"> <input type="submit" value="<?php _e('Search', 'listify'); ?> " onclick="fwp_redirect()" /> </div> </div> <div style="display: none;"> <?php echo do_shortcode('[facetwp template="listings"]'); ?> </div> </div> <script> function fwp_redirect() { if ('get' == FWP.permalink_type) { var query_string = FWP.build_query_string(); if ('' != query_string) { query_string = '?' + query_string; } var url = query_string; } else { var url = window.location.hash; } window.location.href = '<?php echo get_post_type_archive_link('job_listing'); ?> ' + url; } </script> <?php } else { locate_template(array('job-filters-flat.php', 'job-filters.php'), true, false); } echo $after_widget; $content = ob_get_clean(); echo apply_filters($this->widget_id, $content); $this->cache_widget($args, $content); }
public function enqueue_scripts($force = false) { $deps = array('jquery', 'jquery-ui-slider', 'google-maps', 'wp-backbone', 'wp-job-manager-ajax-filters'); if (class_exists('WP_Job_Manager_Extended_Location')) { $deps[] = 'wpjm-extended-location'; } $deps[] = 'listify'; $bias = strtolower(listify_theme_mod('region-bias')); $base = '//maps.googleapis.com/maps/api/js'; $args = array('v' => 3, 'libraries' => 'geometry,places', 'key' => listify_theme_mod('map-behavior-api-key'), 'language' => get_locale() ? substr(get_locale(), 0, 2) : ''); if ('' != $bias) { $args['region'] = $bias; } wp_enqueue_script('google-maps', esc_url_raw(add_query_arg($args, $base))); wp_enqueue_script('listify-app-map', Listify_Integration::get_url() . 'js/map/app.min.js', $deps, '20150213', true); $settings = array('displayMap' => (bool) $this->display(), 'facetwp' => listify_has_integration('facetwp'), 'useClusters' => (bool) listify_theme_mod('map-behavior-clusters'), 'autoFit' => (bool) listify_theme_mod('map-behavior-autofit'), 'trigger' => listify_theme_mod('map-behavior-trigger'), 'mapOptions' => array('zoom' => listify_theme_mod('map-behavior-zoom'), 'maxZoom' => listify_theme_mod('map-behavior-max-zoom'), 'maxZoomOut' => listify_theme_mod('map-behavior-max-zoom-out'), 'gridSize' => listify_theme_mod('map-behavior-grid-size'), 'scrollwheel' => listify_theme_mod('map-behavior-scrollwheel') == 'on' ? true : false), 'searchRadius' => array('min' => listify_theme_mod('map-behavior-search-min'), 'max' => listify_theme_mod('map-behavior-search-max'), 'default' => listify_theme_mod('map-behavior-search-default'))); if ('' != ($center = listify_theme_mod('map-behavior-center'))) { $settings['mapOptions']['center'] = array_map('trim', explode(',', $center)); } if (has_filter('job_manager_geolocation_region_cctld')) { $settings['autoComplete']['componentRestrictions'] = array('country' => $bias); } $settings = apply_filters('listify_map_settings', $settings); wp_localize_script('listify-app-map', 'listifyMapSettings', apply_filters('listify_map_settings', $settings)); }
/** * "Cover" images for pages and other content. * * If on an archive the current query will be used. Otherwise it will * look for a single item's featured image or an image from its gallery. * * @since Listify 1.0.0 * * @param string $class * @return string $atts */ function listify_cover($class, $args = array()) { $defaults = apply_filters('listify_cover_defaults', array('images' => false, 'object_ids' => false, 'size' => 'large')); $args = wp_parse_args($args, $defaults); $image = false; $atts = array(); global $post, $wp_query; // special for WooCommerce if (function_exists('is_shop') && is_shop() || is_singular('product')) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(wc_get_page_id('shop')), $args['size']); } else { if (is_home() && !in_the_loop()) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')), $args['size']); } else { if (!did_action('loop_start') && is_archive() || ($args['images'] || $args['object_ids'])) { $image = listify_get_cover_from_group($args); } else { if (is_a($post, 'WP_Post')) { if (!listify_has_integration('wp-job-manager') || has_post_thumbnail($post->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(), $args['size']); } else { $gallery = Listify_WP_Job_Manager_Gallery::get($post->ID); $args['images'] = $gallery; unset($args['object_ids']); if ($gallery) { $image = listify_get_cover_from_group($args); } } } } } } $image = apply_filters('listify_cover_image', $image, $args); if (!$image) { $class .= ' no-image'; return sprintf('class="%s"', $class); } $class .= ' has-image'; $atts[] = sprintf('style="background-image: url(%s);"', $image[0]); $atts[] = sprintf('class="%s"', $class); return implode(' ', $atts); }
?> <?php } ?> </main> <div id="secondary" class="widget-area col-md-4 col-sm-5 col-xs-12" role="complementary"> <?php the_widget('WP_Widget_Recent_Posts', array('title' => __('Recent Blog Posts', 'listify'), 'icon' => 'clipboard'), array('id' => 'widget-area-sidebar-1', 'before_widget' => '<aside class="widget widget_recent_posts">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title ion-clipboard">', 'after_title' => '</h3>')); ?> <?php if (listify_has_integration('woocommerce')) { ?> <?php the_widget('Listify_Widget_Listing_Social_Profiles', array('title' => __('Social Profiles', 'listify'), 'icon' => 'share'), array('before_widget' => '<aside id="widget-social-profiles" class="widget">', 'after_widget' => '</aside>', 'before_title' => '<h1 class="widget-title %s">', 'after_title' => '</h1>', 'widget_id' => '')); ?> <?php } ?> <?php do_action('listify_author_profile_after_sidebar'); ?> </div><!-- #secondary -->
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $description = isset($instance['description']) ? esc_attr($instance['description']) : false; $after_title = '<h2 class="home-widget-description">' . $description . '</h2>' . $after_title; ob_start(); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } if (listify_has_integration('facetwp')) { global $listify_facetwp; $facets = isset($instance['facets']) ? array_map('trim', explode(',', $instance['facets'])) : $listify_facetwp->get_facets(); // limit to 3 $facets = array_splice($facets, 0, 3); if (3 == count($facets)) { $columns = array(4, 3, 3); } elseif (2 == count($facets)) { $columns = array(5, 5); } else { $columns = array(10); } $count = 0; ?> <div class="job_search_form"> <div class="row"> <?php foreach ($facets as $facet) { ?> <div class="search_<?php echo $facet; ?> col-xs-12 col-sm-4 col-md-<?php echo $columns[$count]; ?> "> <?php echo do_shortcode('[facetwp facet="' . $facet . '"]'); ?> </div> <?php } ?> <div class="col-xs-12 col-sm-12 col-md-2"> <input type="submit" value="<?php _e('Search', 'listify'); ?> " onclick="FWP.refresh()" /> </div> </div> <div style="display: none;"> <?php echo do_shortcode('[facetwp template="listings"]'); ?> </div> </div> <script> (function($) { $(function() { FWP.auto_refresh = false; }); $(document).on( 'facetwp-refresh', function() { if ( FWP.loaded ) { FWP.set_hash(); window.location.href = '<?php echo get_post_type_archive_link('job_listing'); ?> ' + window.location.hash; } }); })(jQuery); </script> <?php } else { global $listify_job_manager; add_action('job_manager_job_filters_before', array($listify_job_manager->template, 'temp_remove_ajax_filters')); do_action('listify_output_results'); add_action('job_manager_job_filters_after', array($listify_job_manager->template, 'temp_add_ajax_filters')); } echo $after_widget; $content = ob_get_clean(); echo apply_filters($this->widget_id, $content); $this->cache_widget($args, $content); }