Example #1
0
 /**
  * Set or use default Modal Fields
  *
  * @since 1.1.9
  *
  * @param array $fields
  *
  * @return array|mixed|void
  */
 function set_modal_fields($fields = array())
 {
     if (empty($fields)) {
         $this->modal_fields = array('label' => __('Configuration', 'wp-job-manager-field-editor'), 'id' => '108101543', 'master' => 'meta_key', 'tabs' => array('config' => array('label' => __('Config', 'wp-job-manager-field-editor'), 'fields' => array('meta_key' => array('label' => __('Meta Key', 'wp-job-manager-field-editor'), 'caption' => __('Should be something unique and lowercase, like <code>job_pay</code>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'default' => '', 'placeholder' => 'job_position_shift'), 'type' => array('label' => __('Type', 'wp-job-manager-field-editor'), 'placeholder' => __('Textbox, WP-Editor, Dropdown, Upload, etc.', 'wp-job-manager-field-editor'), 'caption' => '', 'type' => 'dropdown', 'default' => $this->field_types()->get_field_types(FALSE, $this->list_field_group)), 'multiple' => array('label' => __('Multiple', 'wp-job-manager-field-editor'), 'caption' => __('Allow multiple files to be selected in select file window.', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'default' => '1||Enabled', 'hidden' => TRUE), 'default' => array('label' => __('Default', 'wp-job-manager-field-editor'), 'caption' => __('Default item(s) to select, not required.', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'default' => '', 'placeholder' => ''), 'taxonomy' => array('label' => __('Taxonomy', 'wp-job-manager-field-editor'), 'caption' => __('<a target="_blank" href="http://codex.wordpress.org/Taxonomies">WordPress Taxonomy</a>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'default' => '', 'placeholder' => 'custom_taxonomy', 'help' => array('icon' => 'question', 'url' => 'https://plugins.smyl.es/docs-kb/how-to-createadd-a-custom-taxonomy-to-use-with-checklist-dropdown-or-multiselect/')), 'label' => array('label' => __('Label', 'wp-job-manager-field-editor'), 'caption' => '', 'type' => 'textfield', 'default' => '', 'placeholder' => __('This will be the label next to or above your field.', 'wp-job-manager-field-editor')), 'description' => array('label' => __('Description', 'wp-job-manager-field-editor'), 'caption' => '', 'type' => 'textbox', 'default' => '', 'placeholder' => __('This should be the help text below the field.', 'wp-job-manager-field-editor')), 'placeholder' => array('label' => __('Placeholder', 'wp-job-manager-field-editor'), 'caption' => '', 'type' => 'textfield', 'default' => '', 'placeholder' => __('This text you are reading.', 'wp-job-manager-field-editor')), 'priority' => array('label' => __('Priority', 'wp-job-manager-field-editor'), 'caption' => __('Highest number will be the last field on the form, can include decimal.', 'wp-job-manager-field-editor'), 'default' => '', 'type' => 'textfield', 'placeholder' => '4.5'), 'maxlength' => array('label' => __('Max Length', 'wp-job-manager-field-editor'), 'caption' => __('Max characters allowed in field (including spaces)', 'wp-job-manager-field-editor'), 'default' => '', 'type' => 'textfield', 'placeholder' => '50', 'hidden' => TRUE), 'admin_only' => array('label' => __('Visibility', 'wp-job-manager-field-editor'), 'caption' => __('If enabled this field will not show on frontend.', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'default' => '1||Admin Only'), 'required' => array('label' => __('Required', 'wp-job-manager-field-editor'), 'caption' => '', 'type' => 'checkbox', 'default' => '1||Required'))), 'options' => array('label' => __('Options', 'wp-job-manager-field-editor'), 'multiple' => true, 'fields' => array('option_value' => array('label' => __('Value', 'wp-job-manager-field-editor'), 'caption' => __('', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'default' => '', 'placeholder' => '', 'multiple' => TRUE), 'option_label' => array('label' => __('Label', 'wp-job-manager-field-editor'), 'caption' => __('', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'default' => '', 'placeholder' => '', 'multiple' => true), 'option_default' => array('label' => __('Default Selection', 'wp-job-manager-field-editor'), 'caption' => __('', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'class' => 'jmfe-option-default', 'default' => '1||', 'multiple' => TRUE, 'template_style' => TRUE), 'option_disabled' => array('label' => __('Disabled Option', 'wp-job-manager-field-editor'), 'caption' => __('', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'class' => 'jmfe-option-disabled', 'default' => '1||', 'multiple' => TRUE, 'template_style' => TRUE))), 'output' => array('label' => __('Output', 'wp-job-manager-field-editor'), 'help' => array('icon' => 'question', 'url' => 'https://plugins.smyl.es/docs-kb/field-output-configuration/'), 'fields' => array('output' => array('label' => __('Output', 'wp-job-manager-field-editor'), 'caption' => __('Automatically output on the Job/Resume listing.', 'wp-job-manager-field-editor'), 'type' => 'dropdown', 'placeholder' => __('Do not automatically output the value', 'wp-job-manager-field-editor'), 'default' => $this->auto_output()->get_options(FALSE, $this->list_field_group)), 'output_as' => array('label' => __('Output As', 'wp-job-manager-field-editor'), 'caption' => __('Choose what you want the value to be output as.', 'wp-job-manager-field-editor'), 'type' => 'dropdown', 'default' => $this->auto_output()->get_output_as(FALSE, $this->list_field_group), 'hidden' => TRUE), 'output_oembed_width' => array('label' => __('oEmbed Width', 'wp-job-manager-field-editor'), 'caption' => __('Set a specific width for oEmbed (in pixels), use only numbers do not include px.', 'wp-job-manager-field-editor') . __('<strong>(optional)</strong>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => '500', 'default' => '', 'hidden' => TRUE), 'output_oembed_height' => array('label' => __('oEmbed Height', 'wp-job-manager-field-editor'), 'caption' => __('Set a specific height for oEmbed (in pixels), use only numbers do not include px.', 'wp-job-manager-field-editor') . __('<strong>(optional)</strong>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => '700', 'default' => '', 'hidden' => TRUE), 'output_video_allowdl' => array('label' => __('Allow Download', 'wp-job-manager-field-editor'), 'caption' => __("Will display a download link for browsers incompatible with HTML5 video.", 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'default' => '1||', 'hidden' => TRUE), 'output_video_poster' => array('label' => __('Poster URL', 'wp-job-manager-field-editor'), 'caption' => __("A URL for an image to show until the user plays or seeks. If not specified, the first frame of video will be used when it becomes available.", 'wp-job-manager-field-editor') . __('<strong>(optional)</strong>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => 'http://somedomain.com/video-poster.png', 'default' => '', 'hidden' => TRUE), 'output_video_height' => array('label' => __('Video Height', 'wp-job-manager-field-editor'), 'caption' => __('Set a specific height for video (in pixels), use only numbers do not include px.', 'wp-job-manager-field-editor') . __('<strong>(optional)</strong>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => '700', 'default' => '', 'hidden' => TRUE), 'output_video_width' => array('label' => __('Video Width', 'wp-job-manager-field-editor'), 'caption' => __('Set a specific width for video (in pixels), use only numbers do not include px.', 'wp-job-manager-field-editor') . __('<strong>(optional)</strong>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => '500', 'default' => '', 'hidden' => TRUE), 'output_check_true' => array('label' => __('Checkbox True', 'wp-job-manager-field-editor'), 'caption' => __('Custom caption to use if checkbox field type is checked.', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => __('Yes', 'wp-job-manager-field-editor'), 'default' => '', 'hidden' => TRUE), 'output_check_false' => array('label' => __('Checkbox False', 'wp-job-manager-field-editor'), 'caption' => __('Custom caption to use if checkbox field type is not checked', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => __('No', 'wp-job-manager-field-editor'), 'default' => '', 'hidden' => TRUE), 'output_caption' => array('label' => __('Caption', 'wp-job-manager-field-editor'), 'caption' => __('Choose what you want the value to be output as.', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => __('My Link', 'wp-job-manager-field-editor'), 'default' => '', 'hidden' => TRUE), 'output_classes' => array('label' => __('Classes', 'wp-job-manager-field-editor'), 'caption' => __('Add any additional classes separated by spaces', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => __('my-class my-custom-class my-other-class', 'wp-job-manager-field-editor'), 'default' => '', 'hidden' => TRUE), 'output_priority' => array('label' => __('Priority', 'wp-job-manager-field-editor'), 'caption' => __('<strong>optional</strong>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => __('1.5', 'wp-job-manager-field-editor'), 'default' => '', 'hidden' => TRUE), 'output_show_label' => array('label' => __('Show Label', 'wp-job-manager-field-editor'), 'caption' => '', 'type' => 'checkbox', 'default' => '1||Show Label', 'hidden' => TRUE))), 'populate' => array('label' => __('Populate', 'wp-job-manager-field-editor'), 'help' => array('icon' => 'question', 'url' => 'https://plugins.smyl.es/docs-kb/auto-populate-from-user-meta-feature/'), 'footer' => array('content' => __('You can view, edit, or add user meta using my free open source <strong><a target="_blank" href="https://wordpress.org/plugins/user-meta-display/">User Meta Display</a></strong> plugin.', 'wp-job-manager-field-editor')), 'fields' => array('populate_enable' => array('label' => __('Auto Populate', 'wp-job-manager-field-editor'), 'caption' => __('This box must be checked to enable auto populate.', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'default' => '1||Enable'), 'populate_save' => array('label' => __('Auto Save', 'wp-job-manager-field-editor'), 'caption' => __('Automatically save value to user\'s meta.', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'default' => '1||Enable'), 'populate_default' => array('label' => __('Default', 'wp-job-manager-field-editor'), 'caption' => __('Default value for logged in users.', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => '', 'default' => ''), 'populate_meta_key' => array('label' => __('Meta Key', 'wp-job-manager-field-editor'), 'caption' => __('Specify the <strong>USER</strong> meta key to auto populate this field from if it exists (and user is logged in).  If meta key is set and meta exists for user, it will take priority over default value.<br /><br />If using a meta key from WPJM or WPRM you <strong>must</strong> prepend it with an underscore.  <i>As example, company_website would be <code>_company_website</code></i>', 'wp-job-manager-field-editor'), 'type' => 'textfield', 'placeholder' => __('_company_facebook', 'wp-job-manager-field-editor'), 'default' => '')))), 'multiple' => FALSE);
     } else {
         $this->modal_fields = $fields;
     }
     // Only show packages for job and company
     $package_group = array('job', 'company');
     if (in_array($this->list_field_group, $package_group)) {
         // and if wcpl flow is set to before
         if (defined('JOB_MANAGER_WCPL_VERSION') && 'before' === get_option('job_manager_paid_listings_flow')) {
             $packages = WP_Job_Manager_Field_Editor_Package_WC::get_packages();
             if ($packages) {
                 $this->modal_fields['tabs']['packages'] = array('label' => __('Packages', 'wp-job-manager-field-editor'), 'help' => array('icon' => 'question', 'url' => 'https://plugins.smyl.es/docs-kb/showhide-specific-fields-based-on-selected-package/'), 'fields' => array('packages_require' => array('label' => __('Require', 'wp-job-manager-field-editor'), 'caption' => __('Require specific packages to display this field', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'default' => '1||Enable'), 'packages_show' => array('label' => __('Packages', 'wp-job-manager-field-editor'), 'caption' => __('Select packages you want this field to show for.  Require must be enabled for this to work.', 'wp-job-manager-field-editor'), 'type' => 'checkbox', 'default' => $packages)));
             }
         }
     }
     return apply_filters('field_editor_default_modal_fields', $this->modal_fields);
 }
 /**
  * Initialize Resume Fields
  *
  * Called by WP Job Manager filter in init_fields() to return
  * resume fields with user customization.
  *
  * @since 1.1.9
  *
  * @param array $fields
  *
  * @return mixed
  */
 function init_fields($fields)
 {
     if (!$this->was_filter_forced()) {
         $fields = $this->merge_with_custom_fields($fields);
         // Remove job fields after merge
         if (isset($fields['job'])) {
             unset($fields['job']);
         }
         // Remove company fields after merge
         if (isset($fields['company'])) {
             unset($fields['company']);
         }
         $product_id = isset($_REQUEST['wcpl_jmfe_product_id']) ? intval($_REQUEST['wcpl_jmfe_product_id']) : '';
         $resume_package = isset($_REQUEST['resume_package']) ? sanitize_text_field($_REQUEST['resume_package']) : $product_id;
         $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : FALSE;
         $resume_id = isset($_REQUEST['resume_id']) ? intval($_REQUEST['resume_id']) : FALSE;
         // Admin only filter
         $fields = $this->admin_only_fields($fields);
         // Product/Package Handling, get job_package from post meta
         if ($resume_id && empty($resume_package)) {
             $resume_package = WP_Job_Manager_Field_Editor_Package_WC::get_post_package_id($resume_id);
         }
         // If listing is tied to package, filter so only fields for that package are shown
         if ($resume_package) {
             $fields = WP_Job_Manager_Field_Editor_Package_WC::filter_fields($fields, $resume_package);
         }
         // If fields init by post new resume, return fields with disabled removed
         if ($this->validate_errors || !empty($resume_package) || !$resume_id || isset($_POST['submit_resume']) && !empty($_POST['submit_resume'])) {
             $fields = $this->new_resume_fields($fields);
         }
         // If called by force validation, set fields equal to field config for validation
         if ($this->force_validate) {
             $fields = $this->validation_fields($fields);
         }
     }
     return $fields;
 }
 /**
  * Initialize Job and Company Fields
  *
  * Called by WP Job Manager filter in init_fields() to return job and
  * company fields with user customization.
  *
  * Will return ALL fields including disabled fields
  *
  * @since 1.1.9
  *
  * @param array $fields
  *
  * @return mixed
  */
 function init_fields($fields)
 {
     if (!$this->was_filter_forced()) {
         $fields = $this->merge_with_custom_fields($fields);
         // Remove resume fields after merge
         if (isset($fields['resume_fields'])) {
             unset($fields['resume_fields']);
         }
         $product_id = isset($_REQUEST['wcpl_jmfe_product_id']) ? intval($_REQUEST['wcpl_jmfe_product_id']) : '';
         $job_package = isset($_REQUEST['job_package']) ? sanitize_text_field($_REQUEST['job_package']) : $product_id;
         $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : false;
         $job_id = isset($_REQUEST['job_id']) ? intval($_REQUEST['job_id']) : false;
         // Admin only filter
         $fields = $this->admin_only_fields($fields);
         // Product/Package Handling, get job_package from post meta
         if ($job_id && empty($job_package)) {
             $job_package = WP_Job_Manager_Field_Editor_Package_WC::get_post_package_id($job_id);
         }
         // If listing is tied to package, filter so only fields for that package are shown
         if ($job_package) {
             $fields = WP_Job_Manager_Field_Editor_Package_WC::filter_fields($fields, $job_package);
         }
         // If fields not init by preview, or save, return standard fields ( customizations returned in new_job_fields )
         if ($this->validate_errors || !empty($job_package) || !$job_id || isset($_POST['submit_job']) && !empty($_POST['submit_job'])) {
             $fields = $this->new_job_fields($fields);
         }
         // If called by force validation, set fields equal to field config for validation
         if ($this->force_validate) {
             $fields = $this->validation_fields($fields);
         }
     }
     return $fields;
 }
 /**
  * Initialize Job and Company Fields
  *
  * Called by WP Job Manager filter in init_fields() to return job and
  * company fields with user customization.
  *
  * Will return ALL fields including disabled fields
  *
  * @since 1.1.9
  *
  * @param array $fields
  *
  * @return mixed
  */
 function init_fields($fields)
 {
     if (!$this->was_filter_forced()) {
         $fields = $this->merge_with_custom_fields($fields);
         // Remove resume fields after merge
         if (isset($fields['resume_fields'])) {
             unset($fields['resume_fields']);
         }
         $product_id = isset($_REQUEST['wcpl_jmfe_product_id']) ? intval($_REQUEST['wcpl_jmfe_product_id']) : '';
         $job_package = isset($_REQUEST['job_package']) ? sanitize_text_field($_REQUEST['job_package']) : $product_id;
         $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : false;
         $job_id = isset($_REQUEST['job_id']) ? intval($_REQUEST['job_id']) : false;
         // Product/Package Handling
         if ($job_id && empty($job_package)) {
             // If there's a job_id try and get package/product id from post meta first
             $job_package = get_post_meta($job_id, "_wcpl_jmfe_product_id", TRUE);
             // Edit called from Job Dashboard
             if ($action === 'edit' && empty($job_package)) {
                 $usr_package = get_post_meta($job_id, "_user_package_id", TRUE);
                 $job_package = !empty($usr_package) ? 'user-' . $usr_package : $job_package;
             }
         }
         // Admin only filter
         $fields = $this->admin_only_fields($fields);
         // If listing is tied to package, filter so only fields for that package are shown
         if ($job_package) {
             $fields = WP_Job_Manager_Field_Editor_Package_WC::filter_fields($fields, $job_package);
         }
         // If fields not init by preview, or save, return standard fields ( customizations returned in new_job_fields )
         if ($this->validate_errors || !empty($job_package) || !$job_id) {
             $fields = $this->new_job_fields($fields);
         }
         // If called by force validation, set fields equal to field config for validation
         if ($this->force_validate) {
             $fields = $this->validation_fields($fields);
         }
     }
     return $fields;
 }