Beispiel #1
0
function my_box_post_layout_save($post_id)
{
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (isset($_POST['mythemes-post-layout']) && isset($_POST['mythemes-use-post-layout']) && (int) $_POST['mythemes-use-post-layout'] == 1) {
        meta::set($post_id, 'post-layout', esc_attr($_POST['mythemes-post-layout']));
        meta::set($post_id, 'use-post-layout', esc_attr($_POST['mythemes-use-post-layout']));
        switch ($_POST['mythemes-post-layout']) {
            case 'left':
            case 'right':
                if (isset($_POST['mythemes-post-sidebar'])) {
                    meta::set($post_id, 'post-sidebar', esc_attr($_POST['mythemes-post-sidebar']));
                }
                break;
            default:
                break;
        }
    } else {
        if (isset($_POST['mythemes-use-post-layout'])) {
            meta::set($post_id, 'mythemes-use-post-layout', esc_attr($_POST['mythemes-use-post-layout']));
        }
        meta::set($post_id, 'post-layout', null);
        meta::set($post_id, 'post-sidebar', null);
    }
}