';
}
// nonce
echo '';
echo '';
?>
';
}
/*
* get_style
*
* @description: called by admin_head to generate acf css style (hide other metaboxes)
* @since 2.0.5
* @created: 23/06/12
*/
function get_style( $acf_id )
{
// vars
$options = apply_filters('acf/field_group/get_options', array(), $acf_id);
$html = '';
// add style to html
if( in_array('the_content',$options['hide_on_screen']) )
{
$html .= '#postdivrich {display: none;} ';
}
if( in_array('excerpt',$options['hide_on_screen']) )
{
$html .= '#postexcerpt, #screen-meta label[for=postexcerpt-hide] {display: none;} ';
}
if( in_array('custom_fields',$options['hide_on_screen']) )
{
$html .= '#postcustom, #screen-meta label[for=postcustom-hide] { display: none; } ';
}
if( in_array('discussion',$options['hide_on_screen']) )
{
$html .= '#commentstatusdiv, #screen-meta label[for=commentstatusdiv-hide] {display: none;} ';
}
if( in_array('comments',$options['hide_on_screen']) )
{
$html .= '#commentsdiv, #screen-meta label[for=commentsdiv-hide] {display: none;} ';
}
if( in_array('slug',$options['hide_on_screen']) )
{
$html .= '#slugdiv, #screen-meta label[for=slugdiv-hide] {display: none;} ';
}
if( in_array('author',$options['hide_on_screen']) )
{
$html .= '#authordiv, #screen-meta label[for=authordiv-hide] {display: none;} ';
}
if( in_array('format',$options['hide_on_screen']) )
{
$html .= '#formatdiv, #screen-meta label[for=formatdiv-hide] {display: none;} ';
}
if( in_array('featured_image',$options['hide_on_screen']) )
{
$html .= '#postimagediv, #screen-meta label[for=postimagediv-hide] {display: none;} ';
}
if( in_array('revisions',$options['hide_on_screen']) )
{
$html .= '#revisionsdiv, #screen-meta label[for=revisionsdiv-hide] {display: none;} ';
}
if( in_array('categories',$options['hide_on_screen']) )
{
$html .= '#categorydiv, #screen-meta label[for=categorydiv-hide] {display: none;} ';
}
if( in_array('tags',$options['hide_on_screen']) )
{
$html .= '#tagsdiv-post_tag, #screen-meta label[for=tagsdiv-post_tag-hide] {display: none;} ';
}
if( in_array('send-trackbacks',$options['hide_on_screen']) )
{
$html .= '#trackbacksdiv, #screen-meta label[for=trackbacksdiv-hide] {display: none;} ';
}
return $html;
}
/*
* ajax_get_input_style
*
* @description: called by input-actions.js to hide / show other metaboxes
* @since 2.0.5
* @created: 23/06/12
*/
function ajax_get_style()
{
// vars
$options = array(
'acf_id' => 0,
'nonce' => ''
);
// load post options
$options = array_merge($options, $_POST);
// verify nonce
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
{
die(0);
}
// return style
echo $this->get_style( $options['acf_id'] );
// die
die;
}
/*
* ajax_render_fields
*
* @description:
* @since 3.1.6
* @created: 23/06/12
*/
function ajax_render_fields()
{
// defaults
$options = array(
'acf_id' => 0,
'post_id' => 0,
'nonce' => ''
);
// load post options
$options = array_merge($options, $_POST);
// verify nonce
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
{
die(0);
}
// get acfs
$acfs = apply_filters('acf/get_field_groups', array());
if( $acfs )
{
foreach( $acfs as $acf )
{
if( $acf['id'] == $options['acf_id'] )
{
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
do_action('acf/create_fields', $fields, $options['post_id']);
break;
}
}
}
die();
}
/*
* save_post
*
* @description: Saves the field / location / option data for a field group
* @since 1.0.0
* @created: 23/06/12
*/
function save_post( $post_id )
{
// do not save if this is an auto save routine
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
{
return $post_id;
}
// verify nonce
if( !isset($_POST['acf_nonce'], $_POST['fields']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
{
return $post_id;
}
// if save lock contains a value, the save_post action is already running for another post.
// this would imply that the user is hooking into an ACF update_value or save_post action and inserting a new post
// if this is the case, we do not want to save all the $POST data to this post.
if( isset($GLOBALS['acf_save_lock']) && $GLOBALS['acf_save_lock'] )
{
return $post_id;
}
// update the post (may even be a revision / autosave preview)
do_action('acf/save_post', $post_id);
}
}
new acf_controller_post();
?>