*/
class Simple_Job_Board_Meta_Box_Job_Features {
/**
* Meta box for Job Features.
*
* @since 2.2.3
*/
public static function sjb_meta_box_output($post) {
global $jobfields;
// Add a nonce field so we can check for it later.
wp_nonce_field('sjb_jobpost_meta_box', 'jobpost_meta_box_nonce');
/*
* Use get_post_meta() to retrieve an existing value
* from the database and use the value for the form.
*/
?>
ID);
//getting setting page saved options
$settings_options = unserialize(get_option('jobfeature_settings_options'));
//check Array differnce when $keys is not NULL
if (NULL == $keys) {
//"Add New" job check
$removed_options = $settings_options;
} elseif (NULL == $settings_options) {
$removed_options = '';
} else {
//Remove the same option from post meta and options
$removed_options = array_diff_key($settings_options, get_post_meta($post->ID));
}
if (NULL != $keys):
foreach ($keys as $key):
if (substr($key, 0, 11) == 'jobfeature_') {
$val = get_post_meta($post->ID, $key, TRUE);
if (is_serialized($val)) {
$val = unserialize( $val );
$val = ( is_array( $val ) ) ? array_map('esc_attr', $val ) : esc_attr( $val );
}
/**
* New Label Index Insertion:
*
* - Addition of new index "label"
* - Data Legacy Checking
*/
$label = isset($val['label']) ? $val['label'] : __(ucwords(str_replace('_', ' ', substr($key, 11))), 'simple-job-board');
$value = isset($val['value']) ? $val['value'] : $val;
echo '
'
. '';
// Setting options meta Fileds button to Empty
$button = '
' . esc_html__('Delete', 'simple-job-board') . '
';
echo ' ' . $button . '
';
}
endforeach;
endif;
// Adding setting page features to jobpost
if (NULL != $removed_options):
if ( !isset( $_GET['action'] ) ):
foreach ($removed_options as $key => $val):
if (substr($key, 0, 11) == 'jobfeature_') {
$val = ( is_array( $val ) )? array_map('esc_attr', $val ) : esc_attr( $val );
/**
* New Label Index Insertion:
*
* - Addition of new index "label"
* - Data Legacy Checking
*/
$label = isset($val['label']) ? $val['label'] : __(ucwords(str_replace('_', ' ', substr($key, 11))), 'simple-job-board');
$value = isset($val['value']) ? $val['value'] : $val;
// Convert Empty Value Parameter to NULL
if ('empty' === $value) {
$value = '';
}
echo '
'
. '';
echo '
' . esc_html__('Delete', 'simple-job-board') . '
';
}
endforeach;
endif;
endif;
?>
$val):
if ( substr($val, 0, 11) == 'jobfeature_' ) {
delete_post_meta($post_id, $val); //Remove meta from the db.
}
endforeach;
$POST_data = filter_input_array( INPUT_POST );
// Add new value.
foreach( $POST_data as $key => $val ):
if ( substr($key, 0, 11 ) == 'jobfeature_' ) { // Make sure that it is set.
$key = preg_replace('/[^\p{L} 0-9]/u', '_', $key);
$data = serialize( array_map('sanitize_text_field', filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ) ) );
update_post_meta( $post_id, $key, $data ); // Add new value.
}
endforeach;
}
}