/** * Constructor. */ public function __construct() { add_action('wp', array($this, 'process')); $this->steps = (array) apply_filters('submit_job_steps', array('submit' => array('name' => __('Submit Details', 'wp-job-manager'), 'view' => array($this, 'submit'), 'handler' => array($this, 'submit_handler'), 'priority' => 10), 'preview' => array('name' => __('Preview', 'wp-job-manager'), 'view' => array($this, 'preview'), 'handler' => array($this, 'preview_handler'), 'priority' => 20), 'done' => array('name' => __('Done', 'wp-job-manager'), 'view' => array($this, 'done'), 'priority' => 30))); uasort($this->steps, array($this, 'sort_by_priority')); // Get step/job if (isset($_POST['step'])) { $this->step = is_numeric($_POST['step']) ? max(absint($_POST['step']), 0) : array_search($_POST['step'], array_keys($this->steps)); } elseif (!empty($_GET['step'])) { $this->step = is_numeric($_GET['step']) ? max(absint($_GET['step']), 0) : array_search($_GET['step'], array_keys($this->steps)); } $this->job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0; // Allow resuming from cookie. if (!$this->job_id && !empty($_COOKIE['wp-job-manager-submitting-job-id']) && !empty($_COOKIE['wp-job-manager-submitting-job-key'])) { $job_id = absint($_COOKIE['wp-job-manager-submitting-job-id']); $job_status = get_post_status($job_id); if ('preview' === $job_status && get_post_meta($job_id, '_submitting_key', true) === $_COOKIE['wp-job-manager-submitting-job-key']) { $this->job_id = $job_id; } } // Load job details if ($this->job_id) { $job_status = get_post_status($this->job_id); if ('expired' === $job_status) { if (!job_manager_user_can_edit_job($this->job_id)) { $this->job_id = 0; $this->step = 0; } } elseif (!in_array($job_status, apply_filters('job_manager_valid_submit_job_statuses', array('preview')))) { $this->job_id = 0; $this->step = 0; } } }
/** * Constructor */ public static function init() { self::$job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0; if (!job_manager_user_can_edit_job(self::$job_id)) { self::$job_id = 0; } }
/** * Constructor */ public function __construct() { $this->job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0; if (!job_manager_user_can_edit_job($this->job_id)) { $this->job_id = 0; } }
/** * Init form */ public static function init() { add_action('wp', array(__CLASS__, 'process')); self::$steps = (array) apply_filters('submit_job_steps', array('submit' => array('name' => __('Submit Details', 'wp-job-manager'), 'view' => array(__CLASS__, 'submit'), 'handler' => array(__CLASS__, 'submit_handler'), 'priority' => 10), 'preview' => array('name' => __('Preview', 'wp-job-manager'), 'view' => array(__CLASS__, 'preview'), 'handler' => array(__CLASS__, 'preview_handler'), 'priority' => 20), 'done' => array('name' => __('Done', 'wp-job-manager'), 'view' => array(__CLASS__, 'done'), 'priority' => 30))); uasort(self::$steps, array(__CLASS__, 'sort_by_priority')); // Get step/job if (isset($_POST['step'])) { self::$step = is_numeric($_POST['step']) ? max(absint($_POST['step']), 0) : array_search($_POST['step'], array_keys(self::$steps)); } elseif (!empty($_GET['step'])) { self::$step = is_numeric($_GET['step']) ? max(absint($_GET['step']), 0) : array_search($_GET['step'], array_keys(self::$steps)); } self::$job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0; if (self::$job_id) { $job_status = get_post_status(self::$job_id); if ('expired' === $job_status) { if (!job_manager_user_can_edit_job(self::$job_id)) { self::$job_id = 0; self::$step = 0; } } elseif (!in_array($job_status, apply_filters('job_manager_valid_submit_job_statuses', array('preview')))) { self::$job_id = 0; self::$step = 0; } } }
/** * Handles actions on job dashboard */ public function job_dashboard_handler() { if (!empty($_REQUEST['action']) && !empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'job_manager_my_job_actions')) { $action = sanitize_title($_REQUEST['action']); $job_id = absint($_REQUEST['job_id']); try { // Get Job $job = get_post($job_id); // Check ownership if (!job_manager_user_can_edit_job($job_id)) { throw new Exception(__('Invalid ID', 'wp-job-manager')); } switch ($action) { case 'mark_filled': // Check status if ($job->_filled == 1) { throw new Exception(__('This position has already been filled', 'wp-job-manager')); } // Update update_post_meta($job_id, '_filled', 1); // Message $this->job_dashboard_message = '<div class="job-manager-message">' . sprintf(__('%s has been filled', 'wp-job-manager'), $job->post_title) . '</div>'; break; case 'mark_not_filled': // Check status if ($job->_filled != 1) { throw new Exception(__('This position is not filled', 'wp-job-manager')); } // Update update_post_meta($job_id, '_filled', 0); // Message $this->job_dashboard_message = '<div class="job-manager-message">' . sprintf(__('%s has been marked as not filled', 'wp-job-manager'), $job->post_title) . '</div>'; break; case 'delete': // Trash it wp_trash_post($job_id); // Message $this->job_dashboard_message = '<div class="job-manager-message">' . sprintf(__('%s has been deleted', 'wp-job-manager'), $job->post_title) . '</div>'; break; case 'relist': // redirect to post page wp_redirect(add_query_arg(array('job_id' => absint($job_id)), job_manager_get_permalink('submit_job_form'))); break; default: do_action('job_manager_job_dashboard_do_action_' . $action); break; } do_action('job_manager_my_job_do_action', $action, $job_id); } catch (Exception $e) { $this->job_dashboard_message = '<div class="job-manager-error">' . $e->getMessage() . '</div>'; } } }
/** * Show applications on the job dashboard */ public function show_applications($atts) { $job_id = absint($_REQUEST['job_id']); $job = get_post($job_id); extract(shortcode_atts(array('posts_per_page' => '20'), $atts)); remove_filter('the_title', array($this, 'add_breadcrumb_to_the_title')); // Permissions if (!job_manager_user_can_edit_job($job_id)) { _e('You do not have permission to view this job.', 'wp-job-manager-applications'); return; } wp_enqueue_script('wp-job-manager-applications-dashboard'); $args = apply_filters('job_manager_job_applications_args', array('post_type' => 'job_application', 'post_status' => array_diff(array_merge(array_keys(get_job_application_statuses()), array('publish')), array('archived')), 'ignore_sticky_posts' => 1, 'posts_per_page' => $posts_per_page, 'offset' => (max(1, get_query_var('paged')) - 1) * $posts_per_page, 'post_parent' => $job_id)); // Filters $application_status = !empty($_GET['application_status']) ? sanitize_text_field($_GET['application_status']) : ''; $application_orderby = !empty($_GET['application_orderby']) ? sanitize_text_field($_GET['application_orderby']) : ''; if ($application_status) { $args['post_status'] = $application_status; } switch ($application_orderby) { case 'name': $args['order'] = 'ASC'; $args['orderby'] = 'post_title'; break; case 'rating': $args['order'] = 'DESC'; $args['orderby'] = 'meta_value'; $args['meta_key'] = '_rating'; break; default: $args['order'] = 'DESC'; $args['orderby'] = 'date'; break; } $applications = new WP_Query(); $columns = apply_filters('job_manager_job_applications_columns', array('name' => __('Name', 'wp-job-manager-applications'), 'email' => __('Email', 'wp-job-manager-applications'), 'date' => __('Date Received', 'wp-job-manager-applications'))); get_job_manager_template('job-applications.php', array('applications' => $applications->query($args), 'job_id' => $job_id, 'max_num_pages' => $applications->max_num_pages, 'columns' => $columns, 'application_status' => $application_status, 'application_orderby' => $application_orderby), 'wp-job-manager-applications', JOB_MANAGER_APPLICATIONS_PLUGIN_DIR . '/templates/'); }
" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data"> <?php if (apply_filters('submit_job_form_show_signin', true)) { ?> <?php get_job_manager_template('account-signin.php'); ?> <?php } ?> <?php if (job_manager_user_can_post_job() || job_manager_user_can_edit_job($job_id)) { ?> <!-- Job Information Fields --> <?php do_action('submit_job_form_job_fields_start'); ?> <?php foreach ($job_fields as $key => $field) { ?> <fieldset class="fieldset-<?php esc_attr_e($key); ?> "> <label for="<?php