示例#1
0
 private function set_objects()
 {
     foreach ($this->p->cf['plugin']['ngfb']['lib']['website'] as $id => $name) {
         $classname = NgfbConfig::load_lib(false, 'website/' . $id, 'ngfbsharing' . $id);
         if ($classname !== false && class_exists($classname)) {
             $this->website[$id] = new $classname($this->p);
         }
     }
 }
 public function set_objects($activate = false)
 {
     /*
      * basic plugin setup (settings, check, debug, notices, utils)
      */
     $this->set_options();
     // filter and define the $this->options and $this->site_options properties
     $this->check = new NgfbCheck($this);
     $this->is_avail = $this->check->get_avail();
     // uses $this->options in checks
     // configure the debug class
     $html_debug = !empty($this->options['plugin_debug']) || defined('NGFB_HTML_DEBUG') && NGFB_HTML_DEBUG ? true : false;
     $wp_debug = defined('NGFB_WP_DEBUG') && NGFB_WP_DEBUG ? true : false;
     if (($html_debug || $wp_debug) && ($classname = NgfbConfig::load_lib(false, 'com/debug', 'SucomDebug')) !== false) {
         $this->debug = new $classname($this, array('html' => $html_debug, 'wp' => $wp_debug));
     } else {
         $this->debug = new NgfbNoDebug();
     }
     // fallback to dummy debug class
     if ($this->debug->enabled && $activate === true) {
         $this->debug->log('method called for plugin activation');
     }
     $this->notice = new SucomNotice($this);
     $this->util = new NgfbUtil($this);
     $this->opt = new NgfbOptions($this);
     $this->cache = new SucomCache($this);
     // object and file caching
     $this->style = new SucomStyle($this);
     // admin styles
     $this->script = new SucomScript($this);
     // admin jquery tooltips
     $this->webpage = new SucomWebpage($this);
     // title, desc, etc., plus shortcodes
     $this->media = new NgfbMedia($this);
     // images, videos, etc.
     $this->head = new NgfbHead($this);
     // open graph and twitter card meta tags
     $this->og = new NgfbOpengraph($this);
     // prepare open graph array
     $this->schema = new NgfbSchema($this);
     if (is_admin()) {
         $this->msgs = new NgfbMessages($this);
         // admin tooltip messages
         $this->admin = new NgfbAdmin($this);
         // admin menus and page loader
     }
     if ($this->is_avail['ssb']) {
         $this->sharing = new NgfbSharing($this);
     }
     // wp_head and wp_footer js and buttons
     $this->loader = new NgfbLoader($this, $activate);
     do_action('ngfb_init_objects', $activate);
     /*
      * check and create the default options array
      * execute after all objects have been defines, so hooks into 'ngfb_get_defaults' are available
      */
     if (is_multisite() && (!is_array($this->site_options) || empty($this->site_options))) {
         $this->site_options = $this->opt->get_site_defaults();
     }
     /*
      * end here when called for plugin activation (the init_plugin() hook handles the rest)
      */
     if ($activate == true || !empty($_GET['action']) && $_GET['action'] == 'activate-plugin' && !empty($_GET['plugin']) && $_GET['plugin'] == NGFB_PLUGINBASE) {
         if ($this->debug->enabled) {
             $this->debug->log('exiting early: init_plugin() hook will follow');
         }
         return;
     }
     /*
      * check and upgrade options if necessary
      */
     $this->options = $this->opt->check_options(NGFB_OPTIONS_NAME, $this->options);
     if (is_multisite()) {
         $this->site_options = $this->opt->check_options(NGFB_SITE_OPTIONS_NAME, $this->site_options, true);
     }
     /*
      * configure class properties based on plugin settings
      */
     $this->cache->default_object_expire = $this->options['plugin_object_cache_exp'];
     $this->cache->default_file_expire = $this->check->aop() ? $this->debug->is_enabled('wp') ? NGFB_DEBUG_FILE_EXP : $this->options['plugin_file_cache_exp'] : 0;
     $this->is_avail['cache']['file'] = $this->cache->default_file_expire > 0 ? true : false;
     // disable the transient cache if html debug mode is on
     if ($this->debug->is_enabled('html') === true) {
         $this->is_avail['cache']['transient'] = defined('NGFB_TRANSIENT_CACHE_DISABLE') && !NGFB_TRANSIENT_CACHE_DISABLE ? true : false;
         $cache_status = 'transient cache use ' . ($this->is_avail['cache']['transient'] ? 'could not be' : 'is') . ' disabled';
         if ($this->debug->enabled) {
             $this->debug->log('html debug mode is active: ' . $cache_status);
         }
         $this->notice->inf('HTML debug mode is active – ' . $cache_status . ' and informational messages are being added as hidden HTML comments.');
     }
     if (!empty($this->options['plugin_ngfb_tid'])) {
         $this->util->add_plugin_filters($this, array('installed_version' => 1, 'ua_plugin' => 1));
     }
 }