Exemplo n.º 1
0
 /**
  * Register hooks and istantiate the administrative classes.
  * 
  * @uses Webcomic::$dir
  * @uses Webcomic::$config
  * @uses Webcomic::__construct()
  * @uses WebcomicAdmin::activate()
  * @uses WebcomicAdmin::deactivate()
  * @uses WebcomicAdmin::admin_init()
  * @uses WebcomicAdmin::admin_head()
  * @uses WebcomicAdmin::admin_notices()
  * @uses WebcomicAdmin::admin_enqueue_scripts()
  * @uses WebcomicAdmin::plugin_row_meta()
  * @uses WebcomicAdmin::plugin_action_links()
  * @uses WebcomicPosts
  * @uses WebcomicPages
  * @uses WebcomicUsers
  * @uses WebcomicMedia
  * @uses WebcomicConfig
  * @uses WebcomicCommerce
  * @uses WebcomicTaxonomy
  * @uses WebcomicTranscripts
  * @uses WebcomicLegacy
  */
 public function __construct()
 {
     parent::__construct();
     register_activation_hook(self::$dir . "webcomic.php", array($this, "activate"));
     register_deactivation_hook(self::$dir . "webcomic.php", array($this, "deactivate"));
     if (!self::$config or version_compare(self::$config["version"], self::$version, "<")) {
         add_action("admin_init", array($this, "activate"));
     }
     if (self::$config and version_compare(self::$config["version"], "4x", ">=")) {
         add_action("admin_init", array($this, "admin_init"));
         add_action("admin_head", array($this, "admin_head"));
         add_action("admin_notices", array($this, "admin_notices"));
         add_action("admin_enqueue_scripts", array($this, "admin_enqueue_scripts"));
         add_filter("plugin_row_meta", array($this, "plugin_row_meta"), 10, 3);
         add_filter("plugin_action_links", array($this, "plugin_action_links"), 10, 4);
         require_once self::$dir . "-/php/posts.php";
         new WebcomicPosts();
         require_once self::$dir . "-/php/pages.php";
         new WebcomicPages();
         require_once self::$dir . "-/php/media.php";
         new WebcomicMedia();
         require_once self::$dir . "-/php/config.php";
         new WebcomicConfig();
         require_once self::$dir . "-/php/commerce.php";
         new WebcomicCommerce();
         require_once self::$dir . "-/php/taxonomy.php";
         new WebcomicTaxonomy();
         require_once self::$dir . "-/php/transcripts.php";
         new WebcomicTranscripts();
         if (!empty(self::$config["legacy"])) {
             require_once self::$dir . "-/php/legacy.php";
             new WebcomicLegacy();
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Check to see if the current page is webcomic-related.
  * 
  * We have to do this as early as possible to ensure that the
  * correct template can be set if the collection is using a custom
  * theme. Unfortunately, this means checking even before any
  * conditional tags are available.
  * 
  * @uses Webcomic::$config
  * @uses Webcomic::$integrate
  * @uses Webcomic::$collection
  * @hook setup_theme
  */
 public function setup_theme()
 {
     global $wp_rewrite;
     $match = $permalinks = array();
     if ($wp_rewrite->using_permalinks()) {
         $tokens = array('%year%' => '(?P<year>\\d{4})', '%monthnum%' => '(?P<monthnum>0[1-9]|1[012])', '%day%' => '(?P<day>0[1-9]|[12][0-9]|3[01])', '%hour%' => '(?P<hour>0[0-9]|1[0-9]|2[0-3])', '%minute%' => '(?P<minute>0[1-9]|[1-5][0-9])', '%second%' => '(?P<second>0[1-9]|[1-5][0-9])', '%post_id%' => '(?P<post_id>\\d+)', '%author%' => '(?P<author>[\\w-]+)');
         foreach (self::$config['collections'] as $k => $v) {
             $tokens["%{$k}_storyline%"] = "(?P<{$k}_storyline>([\\w-]+/?)+)";
             $permalinks["{$k}_archive"] = $v['slugs']['archive'];
             $permalinks["{$k}_webcomic"] = str_replace(array_keys($tokens), $tokens, $v['slugs']['webcomic']);
             $permalinks["{$k}_storyline"] = $v['slugs']['storyline'];
             $permalinks["{$k}_character"] = $v['slugs']['character'];
         }
     }
     if ((preg_match('/webcomic\\d+(_(storyline|character))?/', implode(' ', array_keys($_GET)), $match) or isset($_GET['post_type']) and isset(self::$config['collections'][$_GET['post_type']]) and $match[0] = $_GET['post_type'] or $wp_rewrite->using_permalinks() and preg_match('{/(' . implode('|', $permalinks) . ')/}', $_SERVER['REQUEST_URI'], $match) or $id = url_to_postid($_SERVER['REQUEST_URI']) and $match[0] = get_post_meta($id, 'webcomic_collection', true) and isset(self::$config['collections'][$match[0]])) and $match) {
         if (2 < count($match) and $permalinks) {
             foreach ($permalinks as $k => $v) {
                 if (false !== strpos($k, '_webcomic') and preg_match('{' . $v . '}', $match[1])) {
                     self::$collection = str_replace('_webcomic', '', $k);
                     break;
                 }
             }
         } else {
             $match[0] = preg_replace('/_(storyline|character)$/', '', $match[0]);
             self::$collection = empty(self::$config['collections'][$match[0]]) ? preg_replace('/_(archive|webcomic|storyline|character)$/', '', array_search($match[1], $permalinks)) : $match[0];
         }
     }
     $active_theme = new WP_Theme(get_stylesheet_directory(), '');
     self::$integrate = !$active_theme->get('Webcomic');
 }