Beispiel #1
0
function save_option_meta($post_id)
{
    // Verification
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (!isset($_POST['myplugin_noncename'])) {
        return;
    }
    if (!wp_verify_nonce($_POST['myplugin_noncename'], plugin_basename(__FILE__))) {
        return;
    }
    // Save data of page
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
        save_page_option_meta($post_id);
        // Save data of post
    } else {
        if ('post' == $_POST['post_type']) {
            if (!current_user_can('edit_post', $post_id)) {
                return;
            }
            save_post_option_meta($post_id);
        } else {
            if ('portfolio' == $_POST['post_type']) {
                if (!current_user_can('edit_post', $post_id)) {
                    return;
                }
                save_portfolio_option_meta($post_id);
            } else {
                if ('testimonial' == $_POST['post_type']) {
                    if (!current_user_can('edit_post', $post_id)) {
                        return;
                    }
                    save_testimonial_option_meta($post_id);
                } else {
                    if ('price_table' == $_POST['post_type']) {
                        if (!current_user_can('edit_post', $post_id)) {
                            return;
                        }
                        save_price_table_option_meta($post_id);
                    } else {
                        if ('gallery' == $_POST['post_type']) {
                            if (!current_user_can('edit_post', $post_id)) {
                                return;
                            }
                            save_gallery_option_meta($post_id);
                        }
                    }
                }
            }
        }
    }
}
function save_option_meta($post_id)
{
    // Save data of page
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
        save_page_option_meta($post_id);
        // Save data of post
    } else {
        if ('post' == $_POST['post_type']) {
            if (!current_user_can('edit_post', $post_id)) {
                return;
            }
            save_post_option_meta($post_id);
        } else {
            if ('portfolio' == $_POST['post_type']) {
                if (!current_user_can('edit_post', $post_id)) {
                    return;
                }
                save_portfolio_option_meta($post_id);
            } else {
                if ('testimonial' == $_POST['post_type']) {
                    if (!current_user_can('edit_post', $post_id)) {
                        return;
                    }
                    save_testimonial_option_meta($post_id);
                } else {
                    if ('price_table' == $_POST['post_type']) {
                        if (!current_user_can('edit_post', $post_id)) {
                            return;
                        }
                        save_price_table_option_meta($post_id);
                    } else {
                        if ('personnal' == $_POST['post_type']) {
                            if (!current_user_can('edit_post', $post_id)) {
                                return;
                            }
                            save_personnal_option_meta($post_id);
                        } else {
                            if ('gdl-gallery' == $_POST['post_type']) {
                                if (!current_user_can('edit_post', $post_id)) {
                                    return;
                                }
                                save_gallery_option_meta($post_id);
                            }
                        }
                    }
                }
            }
        }
    }
}