comic image order sorting working in edit post
This commit is contained in:
parent
de57ff0444
commit
2ce436ef45
@ -175,6 +175,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
if (isset($_REQUEST['post'])) {
|
if (isset($_REQUEST['post'])) {
|
||||||
$comic_post = new ComicPressComicPost(get_post($_REQUEST['post']), &$this->comicpress);
|
$comic_post = new ComicPressComicPost(get_post($_REQUEST['post']), &$this->comicpress);
|
||||||
$ordering = $comic_post->normalize_comic_image_ordering();
|
$ordering = $comic_post->normalize_comic_image_ordering();
|
||||||
|
echo '<input type="hidden" name="cp[_nonce]" value="' . wp_create_nonce('comicpress') . '" />';
|
||||||
if (is_array($ordering)) {
|
if (is_array($ordering)) {
|
||||||
foreach ($ordering as $type => $attachment_ids) {
|
foreach ($ordering as $type => $attachment_ids) {
|
||||||
echo '<h3>' . $this->comic_image_types[$type] . '</h3>';
|
echo '<h3>' . $this->comic_image_types[$type] . '</h3>';
|
||||||
@ -428,6 +429,15 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handle_update_comic_ordering() {
|
||||||
|
if (is_numeric($_POST['post_ID'])) {
|
||||||
|
if ($post = get_post($_POST['post_ID'])) {
|
||||||
|
$comic_post = new ComicPressComicPost(&$post);
|
||||||
|
$comic_post->change_comic_image_ordering($_POST['cp']['ordering']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an update.
|
* Handle an update.
|
||||||
*/
|
*/
|
||||||
@ -435,8 +445,22 @@ class ComicPressAddonCore extends ComicPressAddon {
|
|||||||
if (isset($_POST['attachments'])) {
|
if (isset($_POST['attachments'])) {
|
||||||
//coming from media editor
|
//coming from media editor
|
||||||
$this->handle_update_attachments();
|
$this->handle_update_attachments();
|
||||||
} else if (isset($_POST['cp']['ordering'])) {
|
} else if (is_array($_POST['cp']['ordering'])) {
|
||||||
// comic ordering
|
// comic ordering
|
||||||
|
|
||||||
|
$meta_key_to_ignore = false;
|
||||||
|
foreach ($_POST['meta'] as $meta_key => $params) {
|
||||||
|
foreach ($params as $type => $value) {
|
||||||
|
if ($type == "key" && $value == "comic_ordering") {
|
||||||
|
$meta_key_to_ignore = $meta_key; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($meta_key_to_ignore !== false) {
|
||||||
|
unset($_POST['meta'][$meta_key_to_ignore]);
|
||||||
|
}
|
||||||
|
|
||||||
$this->handle_update_comic_ordering();
|
$this->handle_update_comic_ordering();
|
||||||
} else {
|
} else {
|
||||||
//coming from us
|
//coming from us
|
||||||
|
@ -169,8 +169,10 @@ class ComicPressComicPost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function change_comic_image_ordering($requested_new_order) {
|
function change_comic_image_ordering($requested_new_order) {
|
||||||
|
$orderings = array();
|
||||||
if (($order_string = get_post_meta($this->post->ID, 'comic_ordering', true)) !== false) {
|
if (($order_string = get_post_meta($this->post->ID, 'comic_ordering', true)) !== false) {
|
||||||
$orderings = $this->breakdown_comic_ordering_string($order_string);
|
$orderings = $this->breakdown_comic_ordering_string($order_string);
|
||||||
|
}
|
||||||
|
|
||||||
$new_order = array();
|
$new_order = array();
|
||||||
|
|
||||||
@ -202,6 +204,5 @@ class ComicPressComicPost {
|
|||||||
update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($new_order));
|
update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($new_order));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user