public function callback($post, $args)
    {
        // If autosave...
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
            return isset($post->ID) ? $post->ID : null;
        }

        // Get field
        $fields = isset($args['args']) ? $args['args'] : null;

        // Check if fields are defined
        if (!$fields || empty($fields)) {
            throw new MetaboxException(Translate::t('metabox.errors.no_type_is_defined'));
        }

        $vars = [];

        // Display fields
        foreach ($fields as $field) {
            if (!$field) {
                continue;
            }

            $vars['fields'][] = $field->render([], [
                'template' => 'metabox',
                'post' => $post,
            ], false);
        }

        // Render view
        Render::view('metabox.html.twig', $vars, 'metabox');

        // Return post if it is asked
        return isset($post->ID) ? $post->ID : null;
    }
public function callback($post, $args)
    {
        // If autosave...
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
            return isset($post->ID) ? $post->ID : null;
        }

        // Get field
        $fields = isset($args['args']) ? $args['args'] : null;

        // Check if fields are defined
        if (!$fields || empty($fields)) {
            throw new MetaboxException(Translate::t('metabox.errors.no_type_is_defined'));
        }

        $vars = [];

        // Display fields
        foreach ($fields as $field) {
            if (!$field) {
                continue;
            }

            $vars['fields'][] = $field->render([], [
                'template' => 'metabox',
                'post' => $post,
            ], false);
        }

        // Render view
        Render::view('metabox.html.twig', $vars, 'metabox');

        // Return post if it is asked
        return isset($post->ID) ? $post->ID : null;
    }
public function callback ( $ post , $ args ) { // If autosave... if ( defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return isset ( $ post -> ID ) ? $ post -> ID : null ; } // Get field $ fields = isset ( $ args [ 'args' ] ) ? $ args [ 'args' ] : null ; // Check if fields are defined if ( ! $ fields || empty ( $ fields ) ) { throw new MetaboxException ( Translate :: t ( 'metabox.errors.no_type_is_defined' ) ) ; } $ vars = [ ] ; // Display fields foreach ( $ fields as $ field ) { if ( ! $ field ) { continue ; } $ vars [ 'fields' ] [ ] = $ field -> render ( [ ] , [ 'template' => 'metabox' , 'post' => $ post , ] , false ) ; } // Render view Render :: view ( 'metabox.html.twig' , $ vars , 'metabox' ) ; // Return post if it is asked return isset ( $ post -> ID ) ? $ post -> ID : null ; }
Callback function.

@param array $post
@param array $args
@return int|null
Callback function .