array( 'comic' => array( 'default' => true, 'name' => 'Comic', 'dimensions' => '760x' ), 'rss' => array( 'default' => false, 'name' => 'RSS', 'dimensions' => '350x' ), 'archive' => array( 'default' => false, 'name' => 'Archive', 'dimensions' => '125x' ), 'mini' => array( 'default' => false, 'name' => 'Minithumb', 'dimensions' => '100x' ), ), 'helpers' => array(), 'storyline_order' => '', ); var $backends = array(); function &get_instance() { static $instance; if (!$instance) { $instance = array(new ComicPress()); } return $instance[0]; } /** * Load ComicPress options. */ function load() { $result = get_option('comicpress-options'); if (is_array($result)) { $this->comicpress_options = $this->_array_merge_replace_recursive($this->comicpress_options, $result); } } function _array_merge_replace_recursive() { $args = func_get_args(); foreach ($args as $arg) { if (!is_array($arg)) { return end($args); } } $all_keys = array(); $result = array(); foreach ($args as $arg) { $all_keys = array_merge($all_keys, array_keys($arg)); } foreach ($all_keys as $key) { $parts_to_merge = array(); foreach ($args as $arg) { if (isset($arg[$key])) { $parts_to_merge[] = $arg[$key]; } } $result[$key] = call_user_func_array(array($this, '_array_merge_replace_recursive'), $parts_to_merge); } return $result; } /** * Save ComicPress options. */ function save() { if (is_array($this->comicpress_options)) { update_option('comicpress-options', $this->comicpress_options); } } // WordPress Filters function intermediate_image_sizes($sizes) { return array_merge($sizes, array_keys($this->comicpress_options['image_types'])); } function editor_max_image_size($current_max, $size) { if (isset($this->comicpress_options['image_types'][$size])) { if (isset($this->comicpress_options['image_types'][$size]['dimensions'])) { list($width, $height) = explode('x', $this->comicpress_options['image_types'][$size]['dimensions']); $current_max = array(intval($width), intval($height)); } } return $current_max; } function normalize_image_size_options() { $protected_options = apply_filters('comicpress_protected_image_size_options', array('thumbnail', 'medium', 'large')); foreach (get_alloptions() as $option => $value) { if (strpos($option, '_size_w') !== false) { $size = str_replace('_size_w', '', $option); if (!in_array($size, $protected_options)) { foreach (array('_size_w', '_size_h', '_crop') as $suffix) { delete_option("${size}${suffix}"); } } } } if (isset($this->comicpress_options['image_types'])) { foreach ($this->comicpress_options['image_types'] as $type => $info) { if (isset($info['dimensions'])) { list($width, $height) = explode('x', $info['dimensions']); update_option("${type}_size_w", intval($width)); update_option("${type}_size_h", intval($height)); update_option("${type}_crop", 0); } } } } // @codeCoverageIgnoreStart /** * Initialize the class. */ function init() { $this->load(); if (current_user_can('edit_themes')) { if (!empty($this->comicpress_options['helpers'])) { add_action('wp_footer', array(&$this, 'announce_activated_helpers')); } } add_filter('intermediate_image_sizes', array(&$this, 'intermediate_image_sizes')); add_filter('editor_max_image_size', array(&$this, 'editor_max_image_size'), 10, 2); foreach (array('comic', 'rss', 'archive', 'mini') as $size) { list($w, $h) = explode("x", $this->comicpress_options["${size}_dimensions"]); update_option("${size}_size_w", $w); update_option("${size}_size_h", $h); update_option("${size}_crop", 0); } foreach (get_declared_classes() as $class) { if (preg_match('#^ComicPressBackend.+$#', $class) > 0) { $this->backends[] = $class; } } } function announce_activated_helpers() { echo "