starting on meta box for post meta data management
This commit is contained in:
parent
94487ac423
commit
e72cb6ae9d
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
class ComicPressPostMediaHandlingMetabox {
|
||||
function __comicpress_init() {
|
||||
$n = new ComicPressPostMediaHandlingMetabox();
|
||||
|
||||
if (isset($_REQUEST['cp'])) {
|
||||
if (is_array($_REQUEST['cp'])) {
|
||||
if (isset($_REQUEST['cp']['_nonce'])) {
|
||||
if (wp_verify_nonce('comicpress', $_REQUEST['cp']['_nonce'])) {
|
||||
if (isset($_REQUEST['cp']['action'])) {
|
||||
if (isset($_REQUEST['cp']['_action_nonce'])) {
|
||||
if (wp_verify_nonce('comicpress-' . $_REQUEST['cp']['action'], $_REQUEST['cp']['_action_nonce'])) {
|
||||
$method_name = str_replace('-', '_', $_REQUEST['cp']['_action_nonce']);
|
||||
if (method_exists($n, $method_name)) {
|
||||
$n->{$method_name}($_REQUEST['cp']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handle_update($info) {
|
||||
|
||||
}
|
||||
}
|
|
@ -18,6 +18,18 @@ function __comicpress_widgets_init() {
|
|||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['cp'])) {
|
||||
if (is_array($_REQUEST['cp'])) {
|
||||
if (isset($_REQUEST['cp']['post_id'])) {
|
||||
if (($_REQUEST['cp']['post_id'] <= 0) && ($_POST['post_ID'] > 0)) {
|
||||
$_REQUEST['cp']['post_id'] = $_POST['post_ID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do_action('comicpress_init');
|
||||
}
|
||||
|
||||
function __comicpress_init() {
|
||||
|
@ -39,6 +51,11 @@ function __comicpress_init() {
|
|||
if (function_exists('id_get_comment_number')) {
|
||||
remove_filter('comments_number','id_get_comment_number');
|
||||
}
|
||||
|
||||
if (($_REQUEST['cp']['post_id'] <= 0) && ($_POST['post_ID'] > 0)) {
|
||||
$_REQUEST['cp']['post_id'] = $_POST['post_ID'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', '__comicpress_widgets_init');
|
||||
|
@ -179,10 +196,18 @@ if ($comicpress_options['remove_wptexturize']) {
|
|||
}
|
||||
|
||||
// WIDGETS WP 2.8 compatible ONLY, no backwards compatibility here.
|
||||
$dirs_to_search = array_unique(array(get_template_directory(),get_stylesheet_directory()));
|
||||
$dirs_to_search = array_unique(array(get_template_directory(), get_stylesheet_directory()));
|
||||
foreach ($dirs_to_search as $dir) {
|
||||
foreach (array('widgets' => 'php', 'functions' => 'php', 'classes' => 'inc') as $folder => $extension) {
|
||||
foreach (glob($dir . "/${folder}/*.${extension}") as $__file) { require_once($__file); }
|
||||
foreach (glob($dir . "/${folder}/*.${extension}") as $__file) {
|
||||
require_once($__file);
|
||||
$__class_name = preg_replace('#\..*$#', '', basename($__file));
|
||||
if (class_exists($__class_name)) {
|
||||
if (method_exists($__class_name, '__comicpress_init')) {
|
||||
add_action('comicpress_init', array($__class_name, '__comicpress_init'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
require_once('PHPUnit/Framework.php');
|
||||
require_once('MockPress/mockpress.php');
|
||||
require_once(dirname(__FILE__) . '/../classes/ComicPressPostMediaHandlingMetabox.inc');
|
||||
|
||||
class ComicPressPostMediaHandlingMetaboxTest extends PHPUnit_Framework_TestCase {
|
||||
function providerTestUpdate() {
|
||||
return array(
|
||||
array(array(), array())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestUpdate
|
||||
*/
|
||||
function testUpdate($input, $expected_post_metadata) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue