コード例 #1
0
ファイル: meta-post.php プロジェクト: chowy1026/jenny
function mfn_post_save_data($post_id)
{
    global $mfn_post_meta_box;
    // verify nonce
    if (key_exists('mfn_post_meta_nonce', $_POST)) {
        if (!wp_verify_nonce($_POST['mfn_post_meta_nonce'], basename(__FILE__))) {
            return $post_id;
        }
    }
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // check permissions
    if (key_exists('post_type', $_POST) && 'page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return $post_id;
        }
    } elseif (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    mfn_builder_save($post_id);
    // check and save fields ( $mfn_page_meta_box['fields'] )
    foreach ($mfn_post_meta_box['fields'] as $field) {
        $old = get_post_meta($post_id, $field['id'], true);
        if (key_exists($field['id'], $_POST)) {
            $new = $_POST[$field['id']];
        } else {
            //			$new = ""; // problem with "quick edit"
            continue;
        }
        if (isset($new) && $new != $old) {
            update_post_meta($post_id, $field['id'], $new);
        } elseif ('' == $new && $old) {
            delete_post_meta($post_id, $field['id'], $old);
        }
    }
}
コード例 #2
0
ファイル: meta-template.php プロジェクト: nguyenhuusao/rang
function mfn_template_save_data($post_id)
{
    global $mfn_template_meta_box;
    // verify nonce
    if (key_exists('mfn_template_meta_nonce', $_POST)) {
        if (!wp_verify_nonce($_POST['mfn_template_meta_nonce'], basename(__FILE__))) {
            return $post_id;
        }
    }
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // check permissions
    if (key_exists('post_type', $_POST) && 'page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return $post_id;
        }
    } elseif (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    mfn_builder_save($post_id);
}