Ejemplo n.º 1
0
 /**
  * Main init method executed as wordpress action 'init'.
  */
 function init()
 {
     $this->init_uninstall();
     define('STARRATING_ENCODING', $this->o["encoding"]);
     if (isset($_GET["page"])) {
         if (substr($_GET["page"], 0, 14) == "gd-star-rating") {
             $this->admin_plugin = true;
             $this->admin_plugin_page = substr($_GET["page"], 15);
         }
     }
     $this->init_operations();
     if (!is_admin()) {
         $this->is_bot = GDSRHelper::detect_bot($_SERVER['HTTP_USER_AGENT']);
         $this->is_ban = GDSRHelper::detect_ban();
         $this->render_wait_article();
         if ($this->o["comments_active"] == 1) {
             $this->render_wait_comment();
         }
         if ($this->o["multis_active"] == 1) {
             $this->render_wait_multis();
         }
     } else {
         $this->cache_cleanup();
     }
     if ($this->admin_plugin_page == "settings-page") {
         $gdsr_options = $this->o;
         include $this->plugin_path . "code/gd-star-settings.php";
         $this->o = $gdsr_options;
     }
     wp_enqueue_script('jquery');
     if ($this->admin_plugin) {
         if ($this->wp_version >= 26) {
             add_thickbox();
         } else {
             wp_enqueue_script("thickbox");
         }
         $this->safe_mode = gdFunctionsGDSR::php_in_safe_mode();
         if (!$this->safe_mode) {
             $this->extra_folders = GDSRHelper::create_folders($this->wp_version);
         }
     }
     $this->l = get_locale();
     if (!empty($this->l)) {
         $moFile = dirname(__FILE__) . "/languages/gd-star-rating-" . $this->l . ".mo";
         if (@file_exists($moFile) && is_readable($moFile)) {
             load_textdomain('gd-star-rating', $moFile);
         }
     }
     $this->is_cached = $this->o["cache_active"];
     $this->is_ie6 = is_msie6();
     $this->custom_actions('init');
     if (is_admin() && $this->o["mur_review_set"] == 0) {
         $set = GDSRDBMulti::get_multis(0, 1);
         if (count($set) > 0) {
             $this->o["mur_review_set"] = $set[0]->multi_id;
             update_option('gd-star-rating', $this->o);
         }
     }
     if (!is_admin() && !is_feed()) {
         $this->rendering_sets = GDSRDBMulti::get_multisets_for_auto_insert();
         if (!is_array($this->rendering_sets)) {
             $this->rendering_sets = array();
         }
     } else {
         $this->rendering_sets = array();
     }
 }