';
}
echo ' ';
}
/**
* Saving meta's in post
*
* @param int $post_id
*/
function apollo13framework_save_post($post_id){
static $done = 0;
$done++;
if( $done > 1 ){
return;//no double saving same things
}
$input_prefix = A13FRAMEWORK_INPUT_PREFIX;
// verify if this is an auto save routine.
// If it is our form has not been submitted, so we do not want to do anything
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if( ! isset( $_POST['apollo13_noncename'] ) )
return;
if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['apollo13_noncename'] ) ), 'apollo13_customization' ) )
return;
//lets get all fields that need to be saved
/** @noinspection PhpIncludeInspection */
require_once (get_theme_file_path( 'advance/meta.php' ));
$meta_boxes = array();
if( isset( $_POST['post_type'] ) ){
switch( sanitize_text_field( wp_unslash( $_POST['post_type'] ) ) ){
case 'post':
$meta_boxes = apollo13framework_meta_boxes_post();
break;
case 'page':
$meta_boxes = apollo13framework_meta_boxes_page();
break;
case A13FRAMEWORK_CUSTOM_POST_TYPE_ALBUM:
$meta_boxes = array_merge( apollo13framework_meta_boxes_album(), apollo13framework_meta_boxes_images_manager() );
break;
case A13FRAMEWORK_CUSTOM_POST_TYPE_WORK:
$meta_boxes = array_merge( apollo13framework_meta_boxes_work(), apollo13framework_meta_boxes_images_manager() );
break;
case A13FRAMEWORK_CUSTOM_POST_TYPE_PEOPLE:
$meta_boxes = apollo13framework_meta_boxes_people();
break;
}
//saving meta
$is_prototype = false;
foreach ( $meta_boxes as $meta_tab ) {
foreach( $meta_tab as $meta ) {
//check is it prototype
if ( $meta['type'] === 'fieldset' ) {
if( isset( $meta['is_prototype'] ) ){
$is_prototype = true;
}
else{
$is_prototype = false;
}
continue;
}
//don't save fields of prototype
if($is_prototype){
continue;
}
if( isset( $meta['id'] ) && isset( $_POST[ $input_prefix . $meta['id'] ] ) ){
$val = sanitize_text_field( wp_unslash( $_POST[ $input_prefix . $meta['id'] ] ) );
update_post_meta( $post_id, '_' . $meta['id'], apply_filters( 'apollo13framework_save_post_meta', $val, $meta['id'] ) );
}
}
}
}
}
add_action( 'save_post', 'apollo13framework_save_post' );