diff --git a/addons/Core/Core.inc b/addons/Core/Core.inc index f7b84cd..b4dae99 100644 --- a/addons/Core/Core.inc +++ b/addons/Core/Core.inc @@ -5,7 +5,7 @@ class ComicPressAddonCore extends ComicPressAddon { * Initialize the addon. * @param ComicPress $comicpress The master ComicPress object. */ - function init($comicpress) { + function init(&$comicpress) { add_action('admin_menu', array(&$this, 'setup_admin_interface')); add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2); add_action('show_comic', array(&$this, 'show_comic'), 1, 1); @@ -372,6 +372,7 @@ class ComicPressAddonCore extends ComicPressAddon { * Update ComicPress options. */ function handle_update_comicpress_options() { + $this->comicpress->comicpress_options['helpers'] = array(); foreach ($this->comicpress->comicpress_options as $option => $value) { if (isset($_POST['cp'][$option])) { switch ($option) { @@ -415,7 +416,12 @@ class ComicPressAddonCore extends ComicPressAddon { case 'category_page_usage': case 'layout'; $this->comicpress->comicpress_options[$option] = $_POST['cp'][$option]; - break; + break; + case 'helpers': + foreach ($_POST['cp'][$option] as $helper => $set) { + $this->comicpress->comicpress_options['helpers'][$helper] = true; + } + break; } } } diff --git a/addons/Core/partials/options-admin.inc b/addons/Core/partials/options-admin.inc index 7a3dff5..cd7d6ae 100644 --- a/addons/Core/partials/options-admin.inc +++ b/addons/Core/partials/options-admin.inc @@ -2,7 +2,8 @@

- +

+
+
@@ -93,10 +94,23 @@
+

+ - - + +
 " /> + Enable editing helpers + + __('Show partials info', 'comicpress') + ) as $key => $label) { ?> + + +
-
+ " /> diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index cb2e567..f46da31 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -14,7 +14,8 @@ class ComicPress { 'blogpost_count' => 10, 'comic_space' => 'comic_only', 'category_page_usage' => 'archive_list', - 'layout' => 'classic.inc' + 'layout' => 'classic.inc', + 'helpers' => array() ); var $additional_stylesheets = array(); @@ -56,6 +57,17 @@ class ComicPress { $this->sort_comic_categories(); add_action('wp_head', array(&$this, 'wp_head')); + + if (current_user_can('edit_themes')) { + if (!empty($this->comicpress_options['helpers'])) { + if (isset($this->comicpress_options['helpers']['show_partials_info'])) { + add_filter('comicpress_partial', array(&$this, 'comicpress_partial'), 10, 2); + add_action('wp_head', array(&$this, 'setup_comicpress_partial')); + } + + add_action('wp_footer', array(&$this, 'announce_activated_helpers')); + } + } } function wp_head() { @@ -66,6 +78,43 @@ class ComicPress { [ Activated ComicPress helpers: " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]"; + } + + function setup_comicpress_partial() { ?> + + + ' . substr(realpath($target), strlen(realpath(get_template_directory())) + 1) . '' . $content; + } /** * Flatten all WP categories into nodes like 0/3/5. diff --git a/functions.php b/functions.php index 1ad7611..4e31553 100644 --- a/functions.php +++ b/functions.php @@ -95,7 +95,11 @@ function include_partial($partials = '') { $target = $comicpress->get_partial_path($partials); - if ($target !== false) { include($target); } + if ($target !== false) { + ob_start(); + include($target); + echo apply_filters("comicpress_partial", ob_get_clean(), $target); + } } function in_comic_category() {