rework commit action handling
This commit is contained in:
parent
509330ed99
commit
9641d10cc9
|
@ -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'));
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue