rework commit action handling

This commit is contained in:
John Bintz 2009-12-09 21:15:08 -05:00
parent 509330ed99
commit 9641d10cc9
2 changed files with 22 additions and 30 deletions

View File

@ -1,21 +1,13 @@
<?php
class ComicPressPostMediaHandlingMetabox {
// @codeCoverageIgnoreStart
function __comicpress_init() {
add_action('admin_menu', array('ComicPressPostMediaHandlingMetabox', 'admin_menu'));
}
function handle_update() {}
// @codeCoverageIgnoreEnd
function _get_valid_types() {
return array_keys(ComicPressMediaHandling::_bundle_global_variables());
}
function handle_post_media_update($info) {
if (isset($info['post_id'])) {
if (is_numeric($info['post_id'])) {
function save_post($post_id) {
if (__comicpress_verify_nonce() == 'post-media-update') {
$info = $_REQUEST['cp'];
$result = array();
if (isset($info['urls'])) {
if (is_array($info['urls'])) {
@ -27,8 +19,7 @@ class ComicPressPostMediaHandlingMetabox {
}
}
}
update_post_meta($info['post_id'], 'backend_url_images', $result);
}
update_post_meta($post_id, 'backend_url_images', $result);
}
}
@ -51,3 +42,6 @@ class ComicPressPostMediaHandlingMetabox {
include('partials/post-media-handling/metabox.inc');
}
}
add_action('admin_menu', array('ComicPressPostMediaHandlingMetabox', 'admin_menu'));
add_action('save_post', array('ComicPressPostMediaHandlingMetabox', 'save_post'));

View File

@ -42,23 +42,20 @@ function __comicpress_init() {
do_action('comicpress_init');
if (isset($_REQUEST['cp'])) {
if (is_array($_REQUEST['cp'])) {
if (($_REQUEST['cp']['post_id'] <= 0) && ($_POST['post_ID'] > 0)) {
$_REQUEST['cp']['post_id'] = $_POST['post_ID'];
if ($verified_nonce = __comicpress_verify_nonce()) {
do_action("comicpress_init-${verified_nonce}");
}
}
function __comicpress_verify_nonce() {
if (isset($_REQUEST['cp'])) {
if (is_array($_REQUEST['cp'])) {
if (isset($_REQUEST['cp']['_nonce'])) {
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
if (isset($_REQUEST['cp']['action'])) {
if (isset($_REQUEST['cp']['_action_nonce'])) {
if (wp_verify_nonce($_REQUEST['cp']['_action_nonce'], 'comicpress-' . $_REQUEST['cp']['action'])) {
$method_name = 'handle_' . str_replace('-', '_', $_REQUEST['cp']['action']);
foreach ($__comicpress_handlable_classes as $class_name) {
if (method_exists($class_name, $method_name)) {
call_user_func(array($class_name, $method_name), $_REQUEST['cp']);
}
}
return $_REQUEST['cp']['action'];
}
}
}
@ -66,6 +63,7 @@ function __comicpress_init() {
}
}
}
return false;
}
add_action('widgets_init', '__comicpress_widgets_init');