-
Notifications
You must be signed in to change notification settings - Fork 4
/
query-vars.php
83 lines (70 loc) · 2.52 KB
/
query-vars.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Plugin Name: Query Vars
* Description: Adds acceptable query vars to the site for WordPress DB queries.
* Plugin URI: https://github.com/cityofnewyork/working-nyc
* Author: NYC Opportunity
* Author URI: nyc.gov/opportunity
*/
add_filter('query_vars', function($vars) {
/**
* Please note, custom query parameters must use the prefix
* to prevent conflicts with the WordPress Query
*
* @author NYC Opportunity
*/
$prefix = 'wnyc_';
/**
* Google Optimize (or other) A/B testing query parameter
*/
array_push($vars, $prefix . 'v'); // version
/**
* Query Vars to map to the WP Archive Vue history state. These are different
* from registered query vars so that they don't interfere with the WordPress
* Query.
*
* These are mapped in the following scripts
*
* wp-content/themes/workingnyc/src/js/programs-archive.js
* wp-content/themes/workingnyc/src/js/jobs-archive.js
* wp-content/themes/workingnyc/src/js/employer-programs-archive.js
*
* @author NYC Opportunity
*/
array_push($vars, $prefix . 'agy'); // agency
array_push($vars, $prefix . 'ser'); // services
array_push($vars, $prefix . 'rst'); // recruitment_status
array_push($vars, $prefix . 'sch'); // schedule
array_push($vars, $prefix . 'dur'); // duration
array_push($vars, $prefix . 'loc'); // locations
array_push($vars, $prefix . 'pop'); // populations
array_push($vars, $prefix . 'age'); // age_ranges_served
array_push($vars, $prefix . 'sec'); // sectors
array_push($vars, $prefix . 'src'); // source
array_push($vars, $prefix . 'sal'); // salary
array_push($vars, $prefix . 'emn'); // employer_needs
array_push($vars, $prefix . 'ind'); // industries
array_push($vars, $prefix . 'avl'); // talent_availability
array_push($vars, $prefix . 'occ'); // occupations
/**
* These need to be added to support mapping the previous /programs archive
* query variables to the new variable set up. The Questionnaire on the
* homepage uses the old query variables to filter results.
*
* @author NYC Opportunity
*/
array_push($vars, 'services');
array_push($vars, 'populations');
array_push($vars, 'age_ranges_served');
array_push($vars, 'sectors');
array_push($vars, 'recruitment_status');
array_push($vars, 'schedule');
array_push($vars, 'duration');
array_push($vars, 'locations');
array_push($vars, 'agency');
/**
* Add Public Query Variable for Open Graph Images
*/
array_push($vars, $prefix . 'ogi');
return $vars;
});