diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index 20af209..72ac4eb 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -31,6 +31,7 @@ class ComicPress { ), 'helpers' => array(), 'storyline_order' => '', + 'active_backends' => null ); var $backends = array(); @@ -141,6 +142,8 @@ class ComicPress { } // @codeCoverageIgnoreStart + function _get_declared_classes() { return get_declared_classes(); } + // @codeCoverageIgnoreEnd /** * Initialize the class. @@ -153,13 +156,28 @@ class ComicPress { $this->normalize_image_size_options(); - foreach (get_declared_classes() as $class) { - if (preg_match('#^ComicPressBackend.+Factory$#', $class) > 0) { - $this->backends[] = new $class(); - } - } + foreach ($this->normalize_active_backends() as $class) { + $this->backends[] = new $class(); + } } + function normalize_active_backends() { + $available_backends = array(); + foreach ($this->_get_declared_classes() as $class) { + if (preg_match('#^ComicPressBackend(.*)Factory$#', $class, $matches) > 0) { + $available_backends[] = $class; + } + } + + if (!is_array($this->comicpress_options['active_backends'])) { + $this->comicpress_options['active_backends'] = array(); + } + + $this->comicpress_options['active_backends'] = array_intersect($available_backends, $this->comicpress_options['active_backends']); + } + + // @codeCoverageIgnoreStart + function announce_activated_helpers() { echo "
[ Activated ComicPress helpers: " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]
"; } @@ -248,5 +266,3 @@ class ComicPress { return false; } } - -?> diff --git a/classes/backends/ComicPressBackendAttachment.inc b/classes/backends/ComicPressBackendAttachment.inc index 3fe52db..35abfc3 100644 --- a/classes/backends/ComicPressBackendAttachment.inc +++ b/classes/backends/ComicPressBackendAttachment.inc @@ -46,6 +46,10 @@ class ComicPressBackendAttachment extends ComicPressBackend { } class ComicPressBackendAttachmentFactory { + function __construct() { + $this->description = __('Uses post attachments as comic images.', 'comicpress'); + } + function generate_from_post($post) { $result = array(); if (is_object($post)) { @@ -71,7 +75,6 @@ class ComicPressBackendAttachmentFactory { return $result; } - function generate_from_id($id) { if (strpos($id, 'attachment-') === 0) { $id = str_replace('attachment-', '', $id); diff --git a/classes/backends/ComicPressBackendFilesystem.inc b/classes/backends/ComicPressBackendFilesystem.inc index 913745a..f014177 100644 --- a/classes/backends/ComicPressBackendFilesystem.inc +++ b/classes/backends/ComicPressBackendFilesystem.inc @@ -239,6 +239,10 @@ class ComicPressBackendFilesystemFactory { // @codeCoverageIgnoreStart class ComicPressBackendFilesystemAdmin { + function __construct() { + $this->description = __('Uses files on the filesystem as comic images, similar to ComicPress Legacy.', 'comicpress'); + } + function options_admin() { $pattern = ComicPressBackendFilesystemFactory::_get_search_pattern(); diff --git a/classes/backends/ComicPressBackendURL.inc b/classes/backends/ComicPressBackendURL.inc index 91c42eb..774b30f 100644 --- a/classes/backends/ComicPressBackendURL.inc +++ b/classes/backends/ComicPressBackendURL.inc @@ -56,6 +56,10 @@ class ComicPressBackendURL extends ComicPressBackend { } class ComicPressBackendURLFactory { + function __construct() { + $this->description = __('Uses URLs assigned to posts as comic images.', 'comicpress'); + } + function generate_from_id($id) { if (preg_match('#^url-([0-9]+)-(.+)$#', $id, $matches) > 0) { list($all, $post_id, $key) = $matches; diff --git a/classes/backends/partials/backend-filesystem/options-admin.inc b/classes/backends/partials/backend-filesystem/options-admin.inc index 53afe3b..6fef2d2 100644 --- a/classes/backends/partials/backend-filesystem/options-admin.inc +++ b/classes/backends/partials/backend-filesystem/options-admin.inc @@ -16,6 +16,7 @@