Regions for WP Job Manager - Version 1.3.1

Version Description

Download this release

Release Info

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

Code changes from version 1.2 to 1.3.1

astoundify-job-manager-locations.php DELETED
@@ -1,269 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: Predefined Regions for WP Job Manager
4
- * Plugin URI: https://github.com/astoundify/wp-job-manager-colors
5
- * Description: Create predefined regions that job submissions can associate themselves with.
6
- * Author: Astoundify
7
- * Author URI: http://astoundify.com
8
- * Version: 1.2
9
- * Text Domain: ajmr
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) exit;
14
-
15
- class Astoundify_Job_Manager_Regions {
16
-
17
- /**
18
- * @var $instance
19
- */
20
- private static $instance;
21
-
22
- /**
23
- * Make sure only one instance is only running.
24
- */
25
- public static function instance() {
26
- if ( ! isset ( self::$instance ) ) {
27
- self::$instance = new self;
28
- }
29
-
30
- return self::$instance;
31
- }
32
-
33
- /**
34
- * Start things up.
35
- *
36
- * @since 1.0
37
- */
38
- public function __construct() {
39
- $this->setup_globals();
40
- $this->setup_actions();
41
- }
42
-
43
- /**
44
- * Set some smart defaults to class variables. Allow some of them to be
45
- * filtered to allow for early overriding.
46
- *
47
- * @since 1.0
48
- *
49
- * @return void
50
- */
51
- private function setup_globals() {
52
- $this->file = __FILE__;
53
-
54
- $this->basename = apply_filters( 'ajmr_plugin_basenname', plugin_basename( $this->file ) );
55
- $this->plugin_dir = apply_filters( 'ajmr_plugin_dir_path', plugin_dir_path( $this->file ) );
56
- $this->plugin_url = apply_filters( 'ajmr_plugin_dir_url', plugin_dir_url ( $this->file ) );
57
-
58
- $this->lang_dir = apply_filters( 'ajmr_lang_dir', trailingslashit( $this->plugin_dir . 'languages' ) );
59
-
60
- $this->domain = 'ajmr';
61
- }
62
-
63
- /**
64
- * Setup the default hooks and actions
65
- *
66
- * @since 1.0
67
- *
68
- * @return void
69
- */
70
- private function setup_actions() {
71
- add_action( 'init', array( $this, 'register_post_taxonomy' ) );
72
- add_filter( 'submit_job_form_fields', array( $this, 'form_fields' ) );
73
- add_action( 'job_manager_update_job_data', array( $this, 'update_job_data' ), 10, 2 );
74
-
75
- add_filter( 'the_job_location', array( $this, 'the_job_location' ), 10, 2 );
76
-
77
- $this->load_textdomain();
78
- }
79
-
80
- /**
81
- * Create the `job_listing_region` taxonomy.
82
- *
83
- * @since 1.0
84
- */
85
- public function register_post_taxonomy() {
86
- $admin_capability = 'manage_job_listings';
87
-
88
- $singular = __( 'Job Region', 'ajmr' );
89
- $plural = __( 'Job Regions', 'ajmr' );
90
-
91
- if ( current_theme_supports( 'job-manager-templates' ) ) {
92
- $rewrite = array(
93
- 'slug' => _x( 'job-region', 'Job region slug - resave permalinks after changing this', 'ajmr' ),
94
- 'with_front' => false,
95
- 'hierarchical' => false
96
- );
97
- } else {
98
- $rewrite = false;
99
- }
100
-
101
- register_taxonomy( 'job_listing_region',
102
- array( 'job_listing' ),
103
- array(
104
- 'hierarchical' => true,
105
- 'update_count_callback' => '_update_post_term_count',
106
- 'label' => $plural,
107
- 'labels' => array(
108
- 'name' => $plural,
109
- 'singular_name' => $singular,
110
- 'search_items' => sprintf( __( 'Search %s', 'ajmr' ), $plural ),
111
- 'all_items' => sprintf( __( 'All %s', 'ajmr' ), $plural ),
112
- 'parent_item' => sprintf( __( 'Parent %s', 'ajmr' ), $singular ),
113
- 'parent_item_colon' => sprintf( __( 'Parent %s:', 'ajmr' ), $singular ),
114
- 'edit_item' => sprintf( __( 'Edit %s', 'ajmr' ), $singular ),
115
- 'update_item' => sprintf( __( 'Update %s', 'ajmr' ), $singular ),
116
- 'add_new_item' => sprintf( __( 'Add New %s', 'ajmr' ), $singular ),
117
- 'new_item_name' => sprintf( __( 'New %s Name', 'ajmr' ), $singular )
118
- ),
119
- 'show_ui' => true,
120
- 'query_var' => true,
121
- 'has_archive' => true,
122
- 'capabilities' => array(
123
- 'manage_terms' => $admin_capability,
124
- 'edit_terms' => $admin_capability,
125
- 'delete_terms' => $admin_capability,
126
- 'assign_terms' => $admin_capability,
127
- ),
128
- 'rewrite' => $rewrite,
129
- )
130
- );
131
- }
132
-
133
- /**
134
- * Add the field to the submission form.
135
- *
136
- * @since 1.0
137
- */
138
- function form_fields( $fields ) {
139
- $fields[ 'job' ][ 'job_region' ] = array(
140
- 'label' => __( 'Job Region', 'job_manager' ),
141
- 'type' => 'select',
142
- 'options' => ajmr_get_regions_simple(),
143
- 'required' => true,
144
- 'priority' => 3
145
- );
146
-
147
- return $fields;
148
- }
149
-
150
- /**
151
- * When the form is submitted, update the data.
152
- *
153
- * @since 1.0
154
- */
155
- function update_job_data( $job_id, $values ) {
156
- $region = isset ( $values[ 'job' ][ 'job_region' ] ) ? $values[ 'job' ][ 'job_region' ] : null;
157
-
158
- if ( ! $revion )
159
- return;
160
-
161
- $term = get_term_by( 'slug', $region, 'job_listing_region' );
162
-
163
- wp_set_post_terms( $job_id, array( $term->term_id ), 'job_listing_region', false );
164
- }
165
-
166
- /**
167
- * On a singular job page, append the region to the location.
168
- *
169
- * @since 1.0
170
- */
171
- function the_job_location( $job_location, $post ) {
172
- if ( ! is_singular( 'job_listing' ) )
173
- return $job_location;
174
-
175
- $terms = wp_get_post_terms( $post->ID, 'job_listing_region' );
176
-
177
- if ( is_wp_error( $terms ) || empty( $terms ) )
178
- return $job_location;
179
-
180
- $location = $terms[0];
181
- $locname = $location->name;
182
-
183
- $job_location = sprintf( '%s &mdash; <a href="%s">%s</a>', $job_location, get_term_link( $location, 'job_listing_region' ), $locname );
184
-
185
- return apply_filters( 'ajmr_job_location', $job_location, $location );
186
- }
187
-
188
- /**
189
- * Loads the plugin language files
190
- *
191
- * @since 1.0
192
- */
193
- public function load_textdomain() {
194
- // Traditional WordPress plugin locale filter
195
- $locale = apply_filters( 'plugin_locale', get_locale(), $this->domain );
196
- $mofile = sprintf( '%1$s-%2$s.mo', $this->domain, $locale );
197
-
198
- // Setup paths to current locale file
199
- $mofile_local = $this->lang_dir . $mofile;
200
- $mofile_global = WP_LANG_DIR . '/' . $this->domain . '/' . $mofile;
201
-
202
- // Look in global /wp-content/languages/ajmr folder
203
- if ( file_exists( $mofile_global ) ) {
204
- return load_textdomain( $this->domain, $mofile_global );
205
-
206
- // Look in local /wp-content/plugins/ajmr/languages/ folder
207
- } elseif ( file_exists( $mofile_local ) ) {
208
- return load_textdomain( $this->domain, $mofile_local );
209
- }
210
-
211
- return false;
212
- }
213
- }
214
-
215
- /**
216
- * Start things up.
217
- *
218
- * Use this function instead of a global.
219
- *
220
- * $ajmr = ajmr();
221
- *
222
- * @since 1.0
223
- */
224
- function ajmr() {
225
- return Astoundify_Job_Manager_Regions::instance();
226
- }
227
-
228
- ajmr();
229
-
230
- /**
231
- * Get regions (terms) helper.
232
- *
233
- * @since 1.0
234
- */
235
- function ajmr_get_regions() {
236
- $locations = get_terms( 'job_listing_region', apply_filters( 'ajmr_get_region_args', array( 'hide_empty' => 0 ) ) );
237
-
238
- return $locations;
239
- }
240
-
241
- /**
242
- * Create a key => value pair of term ID and term name.
243
- *
244
- * @since 1.0
245
- */
246
- function ajmr_get_regions_simple() {
247
- $locations = ajmr_get_regions();
248
- $simple = array();
249
-
250
- foreach ( $locations as $location ) {
251
- $simple[ $location->slug ] = $location->name;
252
- }
253
-
254
- return apply_filters( 'ajmr_get_regions_simple', $simple );
255
- }
256
-
257
- /**
258
- * Custom widgets
259
- *
260
- * @since 1.1
261
- */
262
- function ajmr_widgets_init() {
263
- $ajmr = ajmr();
264
-
265
- include_once( $ajmr->plugin_dir . '/widgets.php' );
266
-
267
- register_widget( 'Astoundify_Job_Manager_Regions_Widget' );
268
- }
269
- add_action( 'after_setup_theme', 'ajmr_widgets_init', 11 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -7,7 +7,7 @@ Contributors: SpencerFinnell
7
  Tags: job, job listing, job region
8
  Requires at least: 3.5
9
  Tested up to: 3.5
10
- Stable Tag: 1.2
11
  License: GPLv3
12
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -30,6 +30,14 @@ Astoundify has released the first fully integrated WP Job Manager theme. Check o
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
 
 
33
  = 1.2: July 28, 2013 =
34
 
35
  * Fix: Make sure the taxononmy is properly added.
@@ -41,4 +49,4 @@ Astoundify has released the first fully integrated WP Job Manager theme. Check o
41
 
42
  = 1.0: July 26, 2013 =
43
 
44
- * First official release!
7
  Tags: job, job listing, job region
8
  Requires at least: 3.5
9
  Tested up to: 3.5
10
+ Stable Tag: 1.3.1
11
  License: GPLv3
12
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
13
 
30
 
31
  == Changelog ==
32
 
33
+ = 1.3.1: January 20, 2014 =
34
+
35
+ * Fix: Avoid priority conflict with existing fields.
36
+
37
+ = 1.3: August 13, 2013 =
38
+
39
+ * Fix: Update wp-job-manager-locations.php
40
+
41
  = 1.2: July 28, 2013 =
42
 
43
  * Fix: Make sure the taxononmy is properly added.
49
 
50
  = 1.0: July 26, 2013 =
51
 
52
+ * First official release!
wp-job-manager-locations.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Plugin Name: WP Job Manager - Predefined Regions
4
- * Plugin URI: https://github.com/astoundify/wp-job-manager-colors
5
  * Description: Create predefined regions that job submissions can associate themselves with.
6
  * Author: Astoundify
7
  * Author URI: http://astoundify.com
8
- * Version: 1.2
9
  * Text Domain: ajmr
10
  */
11
 
@@ -50,14 +50,14 @@ class Astoundify_Job_Manager_Regions {
50
  */
51
  private function setup_globals() {
52
  $this->file = __FILE__;
53
-
54
  $this->basename = apply_filters( 'ajmr_plugin_basenname', plugin_basename( $this->file ) );
55
  $this->plugin_dir = apply_filters( 'ajmr_plugin_dir_path', plugin_dir_path( $this->file ) );
56
  $this->plugin_url = apply_filters( 'ajmr_plugin_dir_url', plugin_dir_url ( $this->file ) );
57
 
58
  $this->lang_dir = apply_filters( 'ajmr_lang_dir', trailingslashit( $this->plugin_dir . 'languages' ) );
59
 
60
- $this->domain = 'ajmr';
61
  }
62
 
63
  /**
@@ -71,6 +71,7 @@ class Astoundify_Job_Manager_Regions {
71
  add_action( 'init', array( $this, 'register_post_taxonomy' ) );
72
  add_filter( 'submit_job_form_fields', array( $this, 'form_fields' ) );
73
  add_action( 'job_manager_update_job_data', array( $this, 'update_job_data' ), 10, 2 );
 
74
 
75
  add_filter( 'the_job_location', array( $this, 'the_job_location' ), 10, 2 );
76
 
@@ -84,7 +85,7 @@ class Astoundify_Job_Manager_Regions {
84
  */
85
  public function register_post_taxonomy() {
86
  $admin_capability = 'manage_job_listings';
87
-
88
  $singular = __( 'Job Region', 'ajmr' );
89
  $plural = __( 'Job Regions', 'ajmr' );
90
 
@@ -141,12 +142,24 @@ class Astoundify_Job_Manager_Regions {
141
  'type' => 'select',
142
  'options' => ajmr_get_regions_simple(),
143
  'required' => true,
144
- 'priority' => 3
145
  );
146
 
147
  return $fields;
148
  }
149
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  /**
151
  * When the form is submitted, update the data.
152
  *
@@ -155,7 +168,7 @@ class Astoundify_Job_Manager_Regions {
155
  function update_job_data( $job_id, $values ) {
156
  $region = isset ( $values[ 'job' ][ 'job_region' ] ) ? $values[ 'job' ][ 'job_region' ] : null;
157
 
158
- if ( ! $revion )
159
  return;
160
 
161
  $term = get_term_by( 'slug', $region, 'job_listing_region' );
@@ -260,10 +273,13 @@ function ajmr_get_regions_simple() {
260
  * @since 1.1
261
  */
262
  function ajmr_widgets_init() {
 
 
 
263
  $ajmr = ajmr();
264
 
265
  include_once( $ajmr->plugin_dir . '/widgets.php' );
266
 
267
  register_widget( 'Astoundify_Job_Manager_Regions_Widget' );
268
  }
269
- add_action( 'after_setup_theme', 'ajmr_widgets_init', 11 );
1
  <?php
2
  /**
3
  * Plugin Name: WP Job Manager - Predefined Regions
4
+ * Plugin URI: https://github.com/astoundify/wp-job-manager-locations
5
  * Description: Create predefined regions that job submissions can associate themselves with.
6
  * Author: Astoundify
7
  * Author URI: http://astoundify.com
8
+ * Version: 1.3.1
9
  * Text Domain: ajmr
10
  */
11
 
50
  */
51
  private function setup_globals() {
52
  $this->file = __FILE__;
53
+
54
  $this->basename = apply_filters( 'ajmr_plugin_basenname', plugin_basename( $this->file ) );
55
  $this->plugin_dir = apply_filters( 'ajmr_plugin_dir_path', plugin_dir_path( $this->file ) );
56
  $this->plugin_url = apply_filters( 'ajmr_plugin_dir_url', plugin_dir_url ( $this->file ) );
57
 
58
  $this->lang_dir = apply_filters( 'ajmr_lang_dir', trailingslashit( $this->plugin_dir . 'languages' ) );
59
 
60
+ $this->domain = 'ajmr';
61
  }
62
 
63
  /**
71
  add_action( 'init', array( $this, 'register_post_taxonomy' ) );
72
  add_filter( 'submit_job_form_fields', array( $this, 'form_fields' ) );
73
  add_action( 'job_manager_update_job_data', array( $this, 'update_job_data' ), 10, 2 );
74
+ add_filter( 'submit_job_form_fields_get_job_data', array( $this, 'form_fields_get_job_data' ), 10, 2 );
75
 
76
  add_filter( 'the_job_location', array( $this, 'the_job_location' ), 10, 2 );
77
 
85
  */
86
  public function register_post_taxonomy() {
87
  $admin_capability = 'manage_job_listings';
88
+
89
  $singular = __( 'Job Region', 'ajmr' );
90
  $plural = __( 'Job Regions', 'ajmr' );
91
 
142
  'type' => 'select',
143
  'options' => ajmr_get_regions_simple(),
144
  'required' => true,
145
+ 'priority' => '2.5'
146
  );
147
 
148
  return $fields;
149
  }
150
 
151
+ /**
152
+ * Get the current value for the job region. We can't rely
153
+ * on basic meta value getting, instead we need to find the term.
154
+ *
155
+ * @since 1.0
156
+ */
157
+ function form_fields_get_job_data( $fields, $job ) {
158
+ $fields[ 'job' ][ 'job_region' ][ 'value' ] = current( wp_get_object_terms( $job->ID, 'job_listing_region', array( 'fields' => 'slugs' ) ) );
159
+
160
+ return $fields;
161
+ }
162
+
163
  /**
164
  * When the form is submitted, update the data.
165
  *
168
  function update_job_data( $job_id, $values ) {
169
  $region = isset ( $values[ 'job' ][ 'job_region' ] ) ? $values[ 'job' ][ 'job_region' ] : null;
170
 
171
+ if ( ! $region )
172
  return;
173
 
174
  $term = get_term_by( 'slug', $region, 'job_listing_region' );
273
  * @since 1.1
274
  */
275
  function ajmr_widgets_init() {
276
+ if ( ! class_exists( 'Jobify_Widget' ) )
277
+ return;
278
+
279
  $ajmr = ajmr();
280
 
281
  include_once( $ajmr->plugin_dir . '/widgets.php' );
282
 
283
  register_widget( 'Astoundify_Job_Manager_Regions_Widget' );
284
  }
285
+ add_action( 'after_setup_theme', 'ajmr_widgets_init', 11 );