PluginProbe
WP Job Manager / 1.23.1
WP Job Manager v1.23.1
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.11.0 1.11.1 1.12.0 1.12.1 1.13.0 1.14.0 1.15.0 All 154 releases
wp-job-manager / wp-job-manager.php
wp-job-manager.php
167 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WP Job Manager
4 Plugin URI: https://wpjobmanager.com/
5 Description: Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.
6 Version: 1.23.1
7 Author: Mike Jolley
8 Author URI: http://mikejolley.com
9 Requires at least: 4.1
10 Tested up to: 4.2
11 Text Domain: wp-job-manager
12 Domain Path: /languages
13
14 Copyright: 2015 Mike Jolley
15 License: GNU General Public License v3.0
16 License URI: http://www.gnu.org/licenses/gpl-3.0.html
17 */
18
19 // Exit if accessed directly
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 /**
25 * WP_Job_Manager class.
26 */
27 class WP_Job_Manager {
28
29 /**
30 * Constructor - get the plugin hooked in and ready
31 */
32 public function __construct() {
33 // Define constants
34 define( 'JOB_MANAGER_VERSION', '1.23.1' );
35 define( 'JOB_MANAGER_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
36 define( 'JOB_MANAGER_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
37
38 // Includes
39 include( 'includes/class-wp-job-manager-install.php' );
40 include( 'includes/class-wp-job-manager-post-types.php' );
41 include( 'includes/class-wp-job-manager-ajax.php' );
42 include( 'includes/class-wp-job-manager-shortcodes.php' );
43 include( 'includes/class-wp-job-manager-api.php' );
44 include( 'includes/class-wp-job-manager-forms.php' );
45 include( 'includes/class-wp-job-manager-geocode.php' );
46 include( 'includes/class-wp-job-manager-cache-helper.php' );
47
48 if ( is_admin() ) {
49 include( 'includes/admin/class-wp-job-manager-admin.php' );
50 }
51
52 // Init classes
53 $this->forms = new WP_Job_Manager_Forms();
54 $this->post_types = new WP_Job_Manager_Post_Types();
55
56 // Activation - works with symlinks
57 register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( 'WP_Job_Manager_Ajax', 'add_endpoint' ), 10 );
58 register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( $this->post_types, 'register_post_types' ), 10 );
59 register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( 'WP_Job_Manager_Install', 'install' ), 10 );
60 register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), 'flush_rewrite_rules', 15 );
61
62 // Switch theme
63 add_action( 'switch_theme', array( 'WP_Job_Manager_Ajax', 'add_endpoint' ), 10 );
64 add_action( 'switch_theme', array( $this->post_types, 'register_post_types' ), 10 );
65 add_action( 'switch_theme', 'flush_rewrite_rules', 15 );
66
67 // Actions
68 add_action( 'after_setup_theme', array( $this, 'load_plugin_textdomain' ) );
69 add_action( 'after_setup_theme', array( $this, 'include_template_functions' ), 11 );
70 add_action( 'widgets_init', array( $this, 'widgets_init' ) );
71 add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );
72 add_action( 'admin_init', array( $this, 'updater' ) );
73 }
74
75 /**
76 * Handle Updates
77 */
78 public function updater() {
79 if ( version_compare( JOB_MANAGER_VERSION, get_option( 'wp_job_manager_version' ), '>' ) ) {
80 WP_Job_Manager_Install::install();
81 }
82 }
83
84 /**
85 * Localisation
86 */
87 public function load_plugin_textdomain() {
88 load_textdomain( 'wp-job-manager', WP_LANG_DIR . "/wp-job-manager/wp-job-manager-" . apply_filters( 'plugin_locale', get_locale(), 'wp-job-manager' ) . ".mo" );
89 load_plugin_textdomain( 'wp-job-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
90 }
91
92 /**
93 * Load functions
94 */
95 public function include_template_functions() {
96 include( 'wp-job-manager-functions.php' );
97 include( 'wp-job-manager-template.php' );
98 }
99
100 /**
101 * Widgets init
102 */
103 public function widgets_init() {
104 include_once( 'includes/class-wp-job-manager-widgets.php' );
105 }
106
107 /**
108 * Register and enqueue scripts and css
109 */
110 public function frontend_scripts() {
111 $ajax_url = WP_Job_Manager_Ajax::get_endpoint();
112 $ajax_filter_deps = array( 'jquery', 'jquery-deserialize' );
113
114 // WPML workaround until this is standardized
115 if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
116 $ajax_url = add_query_arg( 'lang', ICL_LANGUAGE_CODE, $ajax_url );
117 }
118
119 if ( apply_filters( 'job_manager_chosen_enabled', true ) ) {
120 wp_register_script( 'chosen', JOB_MANAGER_PLUGIN_URL . '/assets/js/jquery-chosen/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
121 wp_register_script( 'wp-job-manager-term-multiselect', JOB_MANAGER_PLUGIN_URL . '/assets/js/term-multiselect.min.js', array( 'jquery', 'chosen' ), JOB_MANAGER_VERSION, true );
122 wp_register_script( 'wp-job-manager-multiselect', JOB_MANAGER_PLUGIN_URL . '/assets/js/multiselect.min.js', array( 'jquery', 'chosen' ), JOB_MANAGER_VERSION, true );
123 wp_enqueue_style( 'chosen', JOB_MANAGER_PLUGIN_URL . '/assets/css/chosen.css' );
124 $ajax_filter_deps[] = 'chosen';
125 }
126
127 if ( apply_filters( 'job_manager_ajax_file_upload_enabled', true ) ) {
128 wp_register_script( 'jquery-iframe-transport', JOB_MANAGER_PLUGIN_URL . '/assets/js/jquery-fileupload/jquery.iframe-transport.js', array( 'jquery' ), '1.8.3', true );
129 wp_register_script( 'jquery-fileupload', JOB_MANAGER_PLUGIN_URL . '/assets/js/jquery-fileupload/jquery.fileupload.js', array( 'jquery', 'jquery-iframe-transport', 'jquery-ui-widget' ), '5.42.3', true );
130 wp_register_script( 'wp-job-manager-ajax-file-upload', JOB_MANAGER_PLUGIN_URL . '/assets/js/ajax-file-upload.min.js', array( 'jquery', 'jquery-fileupload' ), JOB_MANAGER_VERSION, true );
131
132 ob_start();
133 get_job_manager_template( 'form-fields/uploaded-file-html.php', array( 'name' => '', 'value' => '', 'extension' => 'jpg' ) );
134 $js_field_html_img = ob_get_clean();
135
136 ob_start();
137 get_job_manager_template( 'form-fields/uploaded-file-html.php', array( 'name' => '', 'value' => '', 'extension' => 'zip' ) );
138 $js_field_html = ob_get_clean();
139
140 wp_localize_script( 'wp-job-manager-ajax-file-upload', 'job_manager_ajax_file_upload', array(
141 'ajax_url' => $ajax_url,
142 'js_field_html_img' => esc_js( str_replace( "\n", "", $js_field_html_img ) ),
143 'js_field_html' => esc_js( str_replace( "\n", "", $js_field_html ) ),
144 'i18n_invalid_file_type' => __( 'Invalid file type. Accepted types:', 'wp-job-manager' )
145 ) );
146 }
147
148 wp_register_script( 'jquery-deserialize', JOB_MANAGER_PLUGIN_URL . '/assets/js/jquery-deserialize/jquery.deserialize.js', array( 'jquery' ), '1.2.1', true );
149 wp_register_script( 'wp-job-manager-ajax-filters', JOB_MANAGER_PLUGIN_URL . '/assets/js/ajax-filters.min.js', $ajax_filter_deps, JOB_MANAGER_VERSION, true );
150 wp_register_script( 'wp-job-manager-job-dashboard', JOB_MANAGER_PLUGIN_URL . '/assets/js/job-dashboard.min.js', array( 'jquery' ), JOB_MANAGER_VERSION, true );
151 wp_register_script( 'wp-job-manager-job-application', JOB_MANAGER_PLUGIN_URL . '/assets/js/job-application.min.js', array( 'jquery' ), JOB_MANAGER_VERSION, true );
152 wp_register_script( 'wp-job-manager-job-submission', JOB_MANAGER_PLUGIN_URL . '/assets/js/job-submission.min.js', array( 'jquery' ), JOB_MANAGER_VERSION, true );
153 wp_localize_script( 'wp-job-manager-ajax-filters', 'job_manager_ajax_filters', array(
154 'ajax_url' => $ajax_url,
155 'is_rtl' => is_rtl() ? 1 : 0,
156 'i18n_load_prev_listings' => __( 'Load previous listings', 'wp-job-manager' )
157 ) );
158 wp_localize_script( 'wp-job-manager-job-dashboard', 'job_manager_job_dashboard', array(
159 'i18n_confirm_delete' => __( 'Are you sure you want to delete this listing?', 'wp-job-manager' )
160 ) );
161
162 wp_enqueue_style( 'wp-job-manager-frontend', JOB_MANAGER_PLUGIN_URL . '/assets/css/frontend.css' );
163 }
164 }
165
166 $GLOBALS['job_manager'] = new WP_Job_Manager();
167