2009-12-04 00:13:10 +00:00
< ? php
class ComicPressPostMediaHandlingMetabox {
2009-12-05 03:36:00 +00:00
function _get_valid_types () {
return array_keys ( ComicPressMediaHandling :: _bundle_global_variables ());
}
2009-12-10 12:32:28 +00:00
function _verify_nonce () { return __comicpress_verify_nonce (); }
2009-12-10 02:15:08 +00:00
function save_post ( $post_id ) {
2009-12-10 12:32:28 +00:00
if ( $this -> _verify_nonce () == 'post-media-update' ) {
2009-12-10 02:15:08 +00:00
$info = $_REQUEST [ 'cp' ];
$result = array ();
if ( isset ( $info [ 'urls' ])) {
if ( is_array ( $info [ 'urls' ])) {
$valid_types = ComicPressPostMediaHandlingMetabox :: _get_valid_types ();
foreach ( $info [ 'urls' ] as $field => $value ) {
if ( in_array ( $field , $valid_types )) {
$result [ $field ] = strip_tags ( $value );
2009-12-05 03:36:00 +00:00
}
}
}
}
2009-12-10 02:15:08 +00:00
update_post_meta ( $post_id , 'backend_url_images' , $result );
2009-12-05 03:36:00 +00:00
}
}
2009-12-05 04:00:29 +00:00
// @codeCoverageIgnoreStart
2009-12-05 02:53:38 +00:00
function admin_menu () {
2009-12-05 03:36:00 +00:00
add_meta_box ( 'comicpress-post-media-handling' , __ ( 'ComicPress Post Media' , 'comicpress' ), array ( 'ComicPressPostMediaHandlingMetabox' , 'metabox' ), 'post' , 'normal' , 'low' );
2009-12-05 02:53:38 +00:00
}
2009-12-05 04:00:29 +00:00
// @codeCoverageIgnoreEnd
2009-12-05 02:53:38 +00:00
function metabox () {
global $post ;
$media_info = get_post_meta ( $post -> ID , 'backend_url_images' , true );
if ( ! is_array ( $media_info )) {
$media_info = array ();
}
$nonce = wp_create_nonce ( 'comicpress' );
$action_nonce = wp_create_nonce ( 'comicpress-post-media-update' );
include ( 'partials/post-media-handling/metabox.inc' );
}
2009-12-04 00:13:10 +00:00
}
2009-12-10 02:15:08 +00:00
add_action ( 'admin_menu' , array ( 'ComicPressPostMediaHandlingMetabox' , 'admin_menu' ));
add_action ( 'save_post' , array ( 'ComicPressPostMediaHandlingMetabox' , 'save_post' ));