Regions for WP Job Manager - Version 1.6.0

Version Description

Download this release

Release Info

Developer adampickering
Plugin Icon wp plugin Regions for WP Job Manager
Version 1.6.0
Comparing to
See all releases

Code changes from version 1.5.2 to 1.6.0

includes/class-template.php CHANGED
@@ -3,9 +3,6 @@
3
  class Astoundify_Job_Manager_Regions_Template extends Astoundify_Job_Manager_Regions {
4
 
5
  public function __construct() {
6
- // Template loader
7
- add_filter( 'job_manager_locate_template', array( $this, 'locate_template' ), 10, 3 );
8
-
9
  add_filter( 'submit_job_form_fields', array( $this, 'submit_job_form_fields' ) );
10
  add_filter( 'the_job_location', array( $this, 'the_job_location' ), 10, 2 );
11
 
@@ -14,29 +11,19 @@ class Astoundify_Job_Manager_Regions_Template extends Astoundify_Job_Manager_Reg
14
  add_action( 'job_manager_job_filters_search_jobs_end', array( $this, 'job_manager_job_filters_search_jobs_end' ) );
15
  } else {
16
  add_action( 'job_manager_job_filters_search_jobs_end', array( $this, 'tax_archive_field' ) );
 
17
  }
18
  }
19
 
20
- public function locate_template( $template, $template_name, $template_path ) {
21
- global $job_manager;
22
-
23
- if ( ! file_exists( $template ) ) {
24
- $default_path = wp_job_manager_regions()->plugin_dir . '/templates/';
25
-
26
- $template = $default_path . $template_name;
27
- }
28
-
29
- return $template;
30
- }
31
-
32
  public function wp_enqueue_scripts() {
33
  wp_enqueue_script( 'job-regions', wp_job_manager_regions()->plugin_url . '/assets/js/main.js', array( 'jquery' ), 20140525, true );
34
  }
35
 
36
  /**
37
  * Add the field to the submission form.
38
- *
39
- * @since 1.0.0
40
  */
41
  public function submit_job_form_fields( $fields ) {
42
  $fields[ 'job' ][ 'job_region' ] = array(
@@ -51,12 +38,15 @@ class Astoundify_Job_Manager_Regions_Template extends Astoundify_Job_Manager_Reg
51
  return $fields;
52
  }
53
 
 
 
 
54
  public function job_manager_job_filters_search_jobs_end( $atts ) {
55
  if ( ( ! isset( $atts[ 'selected_region' ] ) || '' == $atts[ 'selected_region' ] ) && isset( $_GET[ 'search_region' ] ) ) {
56
  $atts[ 'selected_region' ] = absint( $_GET[ 'search_region' ] );
57
  }
58
 
59
- wp_dropdown_categories( array(
60
  'show_option_all' => __( 'All Regions', 'wp-job-manager-locations' ),
61
  'hierarchical' => true,
62
  'taxonomy' => 'job_listing_region',
@@ -64,9 +54,13 @@ class Astoundify_Job_Manager_Regions_Template extends Astoundify_Job_Manager_Reg
64
  'class' => 'search_region',
65
  'hide_empty' => 0,
66
  'selected' => isset( $atts[ 'selected_region' ] ) ? $atts[ 'selected_region' ] : ''
67
- ) );
68
  }
69
 
 
 
 
 
70
  public function tax_archive_field( $atts ) {
71
  if ( ( ! isset( $atts[ 'selected_region' ] ) || '' == $atts[ 'selected_region' ] ) && isset( $_GET[ 'search_region' ] ) ) {
72
  $atts[ 'selected_region' ] = absint( $_GET[ 'search_region' ] );
@@ -76,6 +70,17 @@ class Astoundify_Job_Manager_Regions_Template extends Astoundify_Job_Manager_Reg
76
  'selected_region' ]. '" />';
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  /**
81
  * Replace location output with the region.
@@ -83,15 +88,6 @@ class Astoundify_Job_Manager_Regions_Template extends Astoundify_Job_Manager_Reg
83
  * @since 1.0.0
84
  */
85
  public function the_job_location( $job_location, $post ) {
86
- $terms = wp_get_post_terms( $post->ID, 'job_listing_region' );
87
-
88
- if ( is_wp_error( $terms ) || empty( $terms ) ) {
89
- return $job_location;
90
- }
91
-
92
- $location = $terms[0];
93
-
94
- return $location->name;
95
  }
96
-
97
  }
3
  class Astoundify_Job_Manager_Regions_Template extends Astoundify_Job_Manager_Regions {
4
 
5
  public function __construct() {
 
 
 
6
  add_filter( 'submit_job_form_fields', array( $this, 'submit_job_form_fields' ) );
7
  add_filter( 'the_job_location', array( $this, 'the_job_location' ), 10, 2 );
8
 
11
  add_action( 'job_manager_job_filters_search_jobs_end', array( $this, 'job_manager_job_filters_search_jobs_end' ) );
12
  } else {
13
  add_action( 'job_manager_job_filters_search_jobs_end', array( $this, 'tax_archive_field' ) );
14
+ add_filter( 'body_class', array( $this, 'body_class' ) );
15
  }
16
  }
17
 
18
+ /**
19
+ * Frontend scripts.
20
+ */
 
 
 
 
 
 
 
 
 
21
  public function wp_enqueue_scripts() {
22
  wp_enqueue_script( 'job-regions', wp_job_manager_regions()->plugin_url . '/assets/js/main.js', array( 'jquery' ), 20140525, true );
23
  }
24
 
25
  /**
26
  * Add the field to the submission form.
 
 
27
  */
28
  public function submit_job_form_fields( $fields ) {
29
  $fields[ 'job' ][ 'job_region' ] = array(
38
  return $fields;
39
  }
40
 
41
+ /**
42
+ * Add the field to the filters
43
+ */
44
  public function job_manager_job_filters_search_jobs_end( $atts ) {
45
  if ( ( ! isset( $atts[ 'selected_region' ] ) || '' == $atts[ 'selected_region' ] ) && isset( $_GET[ 'search_region' ] ) ) {
46
  $atts[ 'selected_region' ] = absint( $_GET[ 'search_region' ] );
47
  }
48
 
49
+ wp_dropdown_categories( apply_filters( 'job_manager_regions_dropdown_args', array(
50
  'show_option_all' => __( 'All Regions', 'wp-job-manager-locations' ),
51
  'hierarchical' => true,
52
  'taxonomy' => 'job_listing_region',
54
  'class' => 'search_region',
55
  'hide_empty' => 0,
56
  'selected' => isset( $atts[ 'selected_region' ] ) ? $atts[ 'selected_region' ] : ''
57
+ ) ) );
58
  }
59
 
60
+ /**
61
+ * If we are not using regions on the filter set a hidden field so the AJAX
62
+ * call still only looks in that area.
63
+ */
64
  public function tax_archive_field( $atts ) {
65
  if ( ( ! isset( $atts[ 'selected_region' ] ) || '' == $atts[ 'selected_region' ] ) && isset( $_GET[ 'search_region' ] ) ) {
66
  $atts[ 'selected_region' ] = absint( $_GET[ 'search_region' ] );
70
  'selected_region' ]. '" />';
71
  }
72
 
73
+ /**
74
+ * If we are not using regions on the filter set a body class so themes can hide the text
75
+ * input field so they don't have false thoughts about searching.
76
+ */
77
+ public function body_class( $classes ) {
78
+ if ( is_tax( 'job_listing_region' ) ) {
79
+ $classes[] = 'wp-job-manager-regions-no-filter';
80
+ }
81
+
82
+ return $classes;
83
+ }
84
 
85
  /**
86
  * Replace location output with the region.
88
  * @since 1.0.0
89
  */
90
  public function the_job_location( $job_location, $post ) {
91
+ return get_the_term_list( $post->ID, 'job_listing_region', '', ', ', '' );
 
 
 
 
 
 
 
 
92
  }
 
93
  }
readme.txt CHANGED
@@ -3,11 +3,11 @@
3
  Author URI: http://astoundify.com
4
  Plugin URI: http://astoundify.com
5
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=contact@appthemer.com&item_name=Donation+for+Astoundify WP Job Manager Regions
6
- Contributors: SpencerFinnell
7
  Tags: job, job listing, job region
8
- Requires at least: 3.9.0
9
- Tested up to: 4.0.0
10
- Stable Tag: 1.5.2
11
  License: GPLv3
12
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -17,9 +17,11 @@ Add predefined regions to WP Job Manager submission form.
17
 
18
  Adds a "Job Region" taxonomy so the site administrator can control a set of predefined regions listings can be assigned to.
19
 
 
 
20
  = Where can I use this? =
21
 
22
- Astoundify has released the first fully integrated WP Job Manager theme. Check out ["Jobify"](http://themeforest.net/item/jobify-job-board-wordpress-theme/5247604?ref=Astoundify)
23
 
24
  == Installation ==
25
 
@@ -30,6 +32,12 @@ Astoundify has released the first fully integrated WP Job Manager theme. Check o
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
33
  = 1.5.2: November 25, 2014 =
34
 
35
  * Tweak: Turn off region dropdown for new installs.
3
  Author URI: http://astoundify.com
4
  Plugin URI: http://astoundify.com
5
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=contact@appthemer.com&item_name=Donation+for+Astoundify WP Job Manager Regions
6
+ Contributors: Astoundify, SpencerFinnell
7
  Tags: job, job listing, job region
8
+ Requires at least: 3.6
9
+ Tested up to: 4.1
10
+ Stable Tag: 1.6.0
11
  License: GPLv3
12
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
13
 
17
 
18
  Adds a "Job Region" taxonomy so the site administrator can control a set of predefined regions listings can be assigned to.
19
 
20
+ **Note:** Listings are not filtered by regions. They are simply used as an organization tool.
21
+
22
  = Where can I use this? =
23
 
24
+ Astoundify has released two themes that are fully integrated with the WP Job Manager plugin. Check out ["Jobify"](http://themeforest.net/item/jobify-job-board-wordpress-theme/5247604?ref=Astoundify) and our WordPress Directory theme ["Listify"](http://themeforest.net/item/listify-wordpress-directory-theme/9602611?ref=Astoundify)
25
 
26
  == Installation ==
27
 
32
 
33
  == Changelog ==
34
 
35
+ = 1.6.0: December 17, 2014 =
36
+
37
+ * New: Add a class to the theme's body tag so the location field can be hidden on term archive pages when filters are off.
38
+ * New: Add a filter to allow dropdown arguments to be modified.
39
+ * Fix: General code cleanup.
40
+
41
  = 1.5.2: November 25, 2014 =
42
 
43
  * Tweak: Turn off region dropdown for new installs.
wp-job-manager-locations.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Create predefined regions/locations that job submissions can associate themselves with.
6
  * Author: Astoundify
7
  * Author URI: http://astoundify.com
8
- * Version: 1.5.2
9
  * Text Domain: wp-job-manager-locations
10
  */
11
 
@@ -73,7 +73,7 @@ class Astoundify_Job_Manager_Regions {
73
  add_filter( 'job_manager_get_listings', array( $this, 'job_manager_get_listings' ) );
74
  add_filter( 'job_manager_get_listings_args', array( $this, 'job_manager_get_listings_args' ) );
75
 
76
- $this->load_textdomain();
77
  }
78
 
79
  /**
@@ -96,6 +96,12 @@ class Astoundify_Job_Manager_Regions {
96
  return $settings;
97
  }
98
 
 
 
 
 
 
 
99
  public function job_manager_output_jobs_defaults( $defaults ) {
100
  $defaults[ 'selected_region' ] = '';
101
 
@@ -139,11 +145,29 @@ class Astoundify_Job_Manager_Regions {
139
  add_filter( 'job_manager_get_listings_custom_filter_rss_args', array( $this, 'custom_filter_rss' ) );
140
  }
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
 
143
 
144
  return $args;
145
  }
146
 
 
 
 
 
147
  public function job_manager_get_listings_args( $args ) {
148
  $params = array();
149
 
@@ -161,8 +185,7 @@ class Astoundify_Job_Manager_Regions {
161
  }
162
 
163
  /**
164
- * Append 'showing' text
165
- * @return string
166
  */
167
  public function custom_filter_text( $text ) {
168
  $params = array();
@@ -177,8 +200,7 @@ class Astoundify_Job_Manager_Regions {
177
  }
178
 
179
  /**
180
- * apply_tag_filter_rss
181
- * @return array
182
  */
183
  public function custom_filter_rss( $args ) {
184
  $params = array();
@@ -192,23 +214,9 @@ class Astoundify_Job_Manager_Regions {
192
 
193
  /**
194
  * Loads the plugin language files
195
- *
196
- * @since 1.0.0
197
  */
198
  public function load_textdomain() {
199
- $locale = apply_filters( 'plugin_locale', get_locale(), $this->domain );
200
- $mofile = sprintf( '%1$s-%2$s.mo', $this->domain, $locale );
201
-
202
- $mofile_local = $this->lang_dir . $mofile;
203
- $mofile_global = WP_LANG_DIR . '/' . $this->domain . '/' . $mofile;
204
-
205
- if ( file_exists( $mofile_global ) ) {
206
- return load_textdomain( $this->domain, $mofile_global );
207
- } elseif ( file_exists( $mofile_local ) ) {
208
- return load_textdomain( $this->domain, $mofile_local );
209
- }
210
-
211
- return false;
212
  }
213
  }
214
  add_action( 'plugins_loaded', array( 'Astoundify_Job_Manager_Regions', 'instance' ) );
5
  * Description: Create predefined regions/locations that job submissions can associate themselves with.
6
  * Author: Astoundify
7
  * Author URI: http://astoundify.com
8
+ * Version: 1.6.0
9
  * Text Domain: wp-job-manager-locations
10
  */
11
 
73
  add_filter( 'job_manager_get_listings', array( $this, 'job_manager_get_listings' ) );
74
  add_filter( 'job_manager_get_listings_args', array( $this, 'job_manager_get_listings_args' ) );
75
 
76
+ add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
77
  }
78
 
79
  /**
96
  return $settings;
97
  }
98
 
99
+ /**
100
+ * Modify the default shortcode attributes for displaying listings.
101
+ *
102
+ * If we are on a listing region term archive set the selected_region so
103
+ * we can preselect the dropdown value. This is needed when filtering by region.
104
+ */
105
  public function job_manager_output_jobs_defaults( $defaults ) {
106
  $defaults[ 'selected_region' ] = '';
107
 
145
  add_filter( 'job_manager_get_listings_custom_filter_rss_args', array( $this, 'custom_filter_rss' ) );
146
  }
147
 
148
+ } elseif ( isset( $_GET[ 'selected_region' ] ) ) {
149
+ $region = $_GET[ 'selected_region' ];
150
+
151
+ if ( is_int( $region ) ) {
152
+ $region = array( $region );
153
+ }
154
+
155
+ $args[ 'tax_query' ][] = array(
156
+ 'taxonomy' => 'job_listing_region',
157
+ 'field' => 'id',
158
+ 'terms' => $region,
159
+ 'operator' => 'IN'
160
+ );
161
  }
162
+
163
 
164
  return $args;
165
  }
166
 
167
+ /**
168
+ * Filter the AJAX request to set the search location to null if a region
169
+ * is being passed as well.
170
+ */
171
  public function job_manager_get_listings_args( $args ) {
172
  $params = array();
173
 
185
  }
186
 
187
  /**
188
+ * Filter the AJAX to update the "showing" text.
 
189
  */
190
  public function custom_filter_text( $text ) {
191
  $params = array();
200
  }
201
 
202
  /**
203
+ * Filter the AJAX request to update the RSS feed URL.
 
204
  */
205
  public function custom_filter_rss( $args ) {
206
  $params = array();
214
 
215
  /**
216
  * Loads the plugin language files
 
 
217
  */
218
  public function load_textdomain() {
219
+ load_plugin_textdomain( 'wp-job-manager-locations', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
 
 
 
 
 
 
 
 
 
 
 
 
220
  }
221
  }
222
  add_action( 'plugins_loaded', array( 'Astoundify_Job_Manager_Regions', 'instance' ) );