Last active
October 22, 2015 22:23
-
-
Save vodanh1213/6d2682cb76057905ae83 to your computer and use it in GitHub Desktop.
Job location field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Jobs & Experts Job location field | |
Author: Hoang Ngo | |
Version: 1.0 | |
*/ | |
add_filter('je_job_additions_field', 'job_add_location_field'); | |
function job_add_location_field($fields) | |
{ | |
$fields = array_merge($fields, array( | |
'job_location', | |
)); | |
return $fields; | |
} | |
add_filter('je_job_validation_rules', 'job_add_location_validation_rule'); | |
function job_add_location_validation_rule($rules) | |
{ | |
$rules = array_merge($rules, array( | |
'job_location' => 'required', | |
)); | |
return $rules; | |
} | |
add_filter('je_job_field_name', 'job_location_field_name'); | |
function job_location_field_name($names) | |
{ | |
$names = array_merge($names, array( | |
'job_location' => 'Location' | |
)); | |
return $names; | |
} | |
add_filter('je_job_relations', 'job_location_relations'); | |
function job_location_relations($relations) | |
{ | |
$relations = array_merge($relations, array( | |
array( | |
'type' => 'meta', | |
'key' => 'job_location', | |
'map' => 'job_location' | |
), | |
)); | |
return $relations; | |
} | |
add_action('je_job_after_form', 'add_location_form_field', 10, 2); | |
function add_location_form_field(JE_Job_Model $model, IG_Active_Form $form) | |
{ | |
if(is_admin()){ | |
?> | |
<div class="form-group <?php echo $model->has_error("job_location") ? "has-error" : null ?>"> | |
<?php $form->label("job_location", array("text" => __("Location", je()->domain), "attributes" => array("class" => "col-lg-2 control-label"))) ?> | |
<div class="col-lg-10"> | |
<?php $form->text("job_location", array("attributes" => array("class" => "form-control"))) ?> | |
<span class="help-block m-b-none error-job_title"><?php $form->error("job_location") ?></span> | |
</div> | |
<div class="clearfix"></div> | |
</div> | |
<?php | |
}else { | |
?> | |
<div class="form-group <?php echo $model->has_error("job_location") ? "has-error" : null ?>"> | |
<?php $form->label("job_location", array("text" => __("Location", je()->domain), "attributes" => array("class" => "col-lg-3 control-label"))) ?> | |
<div class="col-lg-9"> | |
<?php $form->text("job_location", array("attributes" => array("class" => "form-control"))) ?> | |
<span class="help-block m-b-none error-job_title"><?php $form->error("job_location") ?></span> | |
</div> | |
<div class="clearfix"></div> | |
</div> | |
<?php | |
} | |
} | |
add_action('je_job_single_before_attachments', 'job_display_location_single'); | |
function job_display_location_single($model) | |
{ | |
if ($model->job_location) { | |
?> | |
<div class="row"> | |
<div class="col-md-12"> | |
<strong><?php _e("Location", je()->domain) ?></strong>: | |
<?php echo $model->job_location ?> | |
</div> | |
</div> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment