/**
  * Init -- Sets things up.
  */
 public static function init()
 {
     if (wp_slimstat::$options['enable_ads_network'] == 'yes' || wp_slimstat::$options['enable_ads_network'] == 'no') {
         self::$admin_notice = "A few weeks ago we started hitting the limits imposed on our site by our existing hosting provider. It was clearly time to find a new home for Slimstat. We've been working on migrating our web platform (website and add-on repository API) to a new more powerful server, and a new domain: <a href='http://www.wp-slimstat.com' target='_blank'>wp-slimstat.com</a>. Our dev team has also released updates for our premium add-ons Export to Excel, Email Reports and User Overview, which are now fully compatible with Slimstat 4. Go get your copy today.";
         self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">I got it, thanks</a>';
     } else {
         self::$admin_notice = "\n\t\t\t<div class='fixed-height'>\n\t\t\t\t<p>In order to protect our intellectual property rights (<a href='http://www.youtube.com/watch?v=OeU-RrjolCw' target='_blank'>Keyword Swarm</a>, anyone?), we are asking you to review the following terms of use.</p>\n\t\t\t\t<p><strong>GNU General Public License v2</strong></p>\n\t\t\t\t<ol>\n\t\t\t\t\t<li>You may copy and distribute verbatim copies of Slimstat's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of Slimstat a copy of this License along with Slimstat. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.</li>\n\t\t\t\t\t<li>You may modify your copy or copies of Slimstat or any portion of it, thus forming a work based on Slimstat, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:\n\t\t\t\t\t\t<ol>\n\t\t\t\t\t\t\t<li>You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.</li>\n\t\t\t\t\t\t\t<li>You must cause any work that you distribute or publish, <strong>that in whole or in part contains or is derived from Slimstat or any part thereof, to be licensed as a whole at no charge</strong> to all third parties under the terms of this License.</li>\n\t\t\t\t\t\t\t<li>If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute Slimstat under these conditions, and telling the user how to view a copy of this License.</li>\n\t\t\t\t\t\t</ol>\n\t\t\t\t\t\tThese requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from Slimstat, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on Slimstat, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.\n\t\t\t\t\t\tThus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on Slimstat.\n\t\t\t\t\t\tIn addition, mere aggregation of another work not based on Slimstat with Slimstat (or with a work based on Slimstat) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.</li>\n\t\t\t\t\t<li>You may copy and distribute Slimstat (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:\n\t\t\t\t\t\t<ol>\n\t\t\t\t\t\t\t<li>Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,</li>\n\t\t\t\t\t\t\t<li>Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,</li>\n\t\t\t\t\t\t\t<li>Accompany it with the information you received as to the offer to distribute corresponding source code.</li>\n\t\t\t\t\t\t</ol>\n\t\t\t\t\t\tThe source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.\n\t\t\t\t\t\tIf distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.</li>\n\t\t\t\t\t<li>You may not copy, modify, sublicense, or distribute Slimstat except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute Slimstat is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.</li>\n\t\t\t\t\t<li>You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute Slimstat or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing Slimstat (or any work based on Slimstat), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying Slimstat or works based on it.</li>\n\t\t\t\t\t<li>Each time you redistribute Slimstat (or any work based on Slimstat), the recipient automatically receives a license from the original licensor to copy, distribute or modify Slimstat subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.</li>\n\t\t\t\t\t<li>If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, <strong>then as a consequence you may not distribute Slimstat at all</strong>. For example, if a patent license would not permit royalty-free redistribution of Slimstat by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of Slimstat.\n\t\t\t\t\t\tIf any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.\n\t\t\t\t\t\tIt is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.\n\t\t\t\t\t\tThis section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.</li>\n\t\t\t\t\t<li>If the distribution and/or use of Slimstat is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places Slimstat under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.</li>\n\t\t\t\t\t<li>The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\n\t\t\t\t\t\tEach version is given a distinguishing version number.</li>\n\t\t\t\t\t<li>If you wish to incorporate parts of Slimstat into other free programs whose distribution conditions are different, <strong>write to the author to ask for permission</strong>. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.</li>\n\t\t\t\t\t<li><strong>NO WARRANTY</strong> - BECAUSE WP SLIMSTAT IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR WP SLIMSTAT, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE WP SLIMSTAT \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF WP SLIMSTAT IS WITH YOU. SHOULD WP SLIMSTAT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</li>\n\t\t\t\t\t<li>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE WP SLIMSTAT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE WP SLIMSTAT (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF WP SLIMSTAT TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</li>\n\t\t\t\t</ol>\n\t\t\t\t\n\t\t\t\t<p><strong>Third Party Text Links</strong></p>\n\t\t\t\t<p>Third party text networks supply text for display in Slimstat. These networks may collect your visitors' IP addresses, in native or hashed forms, for purposes of controlling the distribution of text links. Slimstat collects anonymous aggregated usage statistics.</p>\n\t\t\t\t<p>By clicking the button here below, you agree to the terms and conditions and give permission to place text links on your website when search engine crawlers access it. Your website's layout, performance and interaction with human visitors should not be altered or affected in any way. Please note that this feature can be deactivated at any time under Setting > Advanced > UAN Netword, without affecting any other feature available in Slimstat.</p>\n\t\t\t\t<p>WP Slimstat - Copyright &copy; " . date('Y') . " Get Used to IT.</p>\n\t\t\t</div>\n\t\t\t\n\t\t\t<div>\n\t\t\t\t<a id='slimstat-accept-terms' href='#' class='button-primary'>I accept</a>\n\t\t\t\t<a id='slimstat-hide-admin-notice' href='#' class='button-secondary'>I do not accept</a>\n\t\t\t</div>";
     }
     // Settings URL
     self::$config_url = 'admin.php?page=wp-slim-config&amp;tab=';
     // Load language files
     load_plugin_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang', '/wp-slimstat/admin/lang');
     // If a localization does not exist, use English
     if (!isset($l10n['wp-slimstat'])) {
         load_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang/wp-slimstat-en_US.mo');
     }
     // WPMU - New blog created
     $active_sitewide_plugins = get_site_option('active_sitewide_plugins');
     if (!empty($active_sitewide_plugins['wp-slimstat/wp-slimstat.php'])) {
         add_action('wpmu_new_blog', array(__CLASS__, 'new_blog'));
     }
     // WPMU - Blog Deleted
     add_filter('wpmu_drop_tables', array(__CLASS__, 'drop_tables'), 10, 2);
     // Screen options: hide/show panels to customize your view
     add_filter('screen_settings', array(__CLASS__, 'screen_settings'), 10, 2);
     // Display a notice that hightlights this version's features
     if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-view') !== false && !empty(self::$admin_notice) && wp_slimstat::$options['show_admin_notice'] != wp_slimstat::$version && current_user_can('manage_options')) {
         add_action('admin_notices', array(__CLASS__, 'show_admin_notice'));
     }
     // Remove spammers from the database
     if (wp_slimstat::$options['ignore_spammers'] == 'yes') {
         add_action('transition_comment_status', array(__CLASS__, 'remove_spam'), 15, 3);
     }
     if (function_exists('is_network_admin') && !is_network_admin()) {
         // Add the appropriate entries to the admin menu, if this user can view/admin WP SlimStats
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_view_menu'));
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_config_menu'));
         // Display the column in the Edit Posts / Pages screen
         if (wp_slimstat::$options['add_posts_column'] == 'yes') {
             add_filter('manage_posts_columns', array(__CLASS__, 'add_column_header'));
             add_filter('manage_pages_columns', array(__CLASS__, 'add_column_header'));
             add_action('manage_posts_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('manage_pages_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
         }
         // Add some inline CSS to customize the icon associated to SlimStat in the sidebar
         add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet_icon'));
         // Update the table structure and options, if needed
         if (!empty(wp_slimstat::$options['version']) && wp_slimstat::$options['version'] != wp_slimstat::$version) {
             add_action('admin_init', array(__CLASS__, 'update_tables_and_options'));
         }
     }
     // Load the library of functions to generate the reports
     if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-view') !== false || !empty($_POST['action']) && $_POST['action'] == 'slimstat_load_report') {
         include_once dirname(__FILE__) . '/view/wp-slimstat-reports.php';
         wp_slimstat_reports::init();
         if (!empty($_POST['report_id'])) {
             $report_id = sanitize_title($_POST['report_id'], 'slim_p0_00');
             if (!empty(wp_slimstat_reports::$reports_info[$report_id])) {
                 add_action('wp_ajax_slimstat_load_report', array('wp_slimstat_reports', 'callback_wrapper'), 10, 2);
             }
         }
     }
     // Dashboard Widgets
     if (wp_slimstat::$options['add_dashboard_widgets'] == 'yes') {
         $temp = strlen($_SERVER['REQUEST_URI']) - 10;
         if (strpos($_SERVER['REQUEST_URI'], 'index.php') !== false || $temp >= 0 && strpos($_SERVER['REQUEST_URI'], '/wp-admin/', $temp) !== false) {
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_enqueue_scripts'));
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
         }
         add_action('wp_dashboard_setup', array(__CLASS__, 'add_dashboard_widgets'));
     }
     // WordPress Widget
     // FIX ME: To be implemented
     // AJAX Handlers
     if (defined('DOING_AJAX') && DOING_AJAX) {
         add_action('wp_ajax_slimstat_hide_admin_notice', array(__CLASS__, 'hide_admin_notice'));
         add_action('wp_ajax_slimstat_hide_geolite_notice', array(__CLASS__, 'hide_geolite_notice'));
         add_action('wp_ajax_slimstat_manage_filters', array(__CLASS__, 'manage_filters'));
         add_action('wp_ajax_slimstat_delete_pageview', array(__CLASS__, 'delete_pageview'));
         add_action('wp_ajax_slimstat_enable_ads_feature', array(__CLASS__, 'enable_ads_feature'));
     }
 }
 /**
  * Init -- Sets things up.
  */
 public static function init()
 {
     // This option requires a special treatment
     if (!empty($_POST['options']['use_separate_menu'])) {
         wp_slimstat::$options['use_separate_menu'] = in_array($_POST['options']['use_separate_menu'], array('yes', 'no')) ? $_POST['options']['use_separate_menu'] : '';
     }
     // Current screen
     if (!empty($_GET['page'])) {
         self::$current_tab = intval(str_replace('wp-slim-view-', '', $_GET['page']));
     } else {
         if (!empty($_POST['current_tab'])) {
             self::$current_tab = intval($_POST['current_tab']);
         }
     }
     // Settings URL
     self::$config_url = (wp_slimstat::$options['use_separate_menu'] == 'yes' ? 'admin.php' : 'options.php') . '?page=wp-slim-config&amp;tab=';
     self::$view_url = (wp_slimstat::$options['use_separate_menu'] == 'yes' ? 'admin.php' : 'options.php') . '?page=wp-slim-view-' . self::$current_tab;
     // Load language files
     load_plugin_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang', '/wp-slimstat/admin/lang');
     // If a localization does not exist, use English
     if (!isset($l10n['wp-slimstat'])) {
         load_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang/wp-slimstat-en_US.mo');
     }
     // WPMU - New blog created
     $active_sitewide_plugins = get_site_option('active_sitewide_plugins');
     if (!empty($active_sitewide_plugins['wp-slimstat/wp-slimstat.php'])) {
         add_action('wpmu_new_blog', array(__CLASS__, 'new_blog'));
     }
     // WPMU - Blog Deleted
     add_filter('wpmu_drop_tables', array(__CLASS__, 'drop_tables'), 10, 2);
     // Screen options: hide/show panels to customize your view
     add_filter('screen_settings', array(__CLASS__, 'screen_settings'), 10, 2);
     // Display a notice that hightlights this version's features
     //if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim') !== false && !empty(self::$admin_notice) && wp_slimstat::$options['show_admin_notice'] != wp_slimstat::$version) {
     //	add_action('admin_notices', array(__CLASS__, 'show_admin_notice'));
     //}
     // Remove spammers from the database
     if (wp_slimstat::$options['ignore_spammers'] == 'yes') {
         add_action('transition_comment_status', array(__CLASS__, 'remove_spam'), 15, 3);
     }
     if (function_exists('is_network_admin') && !is_network_admin()) {
         // Add the appropriate entries to the admin menu, if this user can view/admin WP SlimStats
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_view_menu'));
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_config_menu'));
         // Display the column in the Edit Posts / Pages screen
         if (wp_slimstat::$options['add_posts_column'] == 'yes') {
             add_filter('manage_posts_columns', array(__CLASS__, 'add_column_header'));
             add_filter('manage_pages_columns', array(__CLASS__, 'add_column_header'));
             add_action('manage_posts_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('manage_pages_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
         }
         // Add some inline CSS to customize the icon associated to SlimStat in the sidebar
         add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet_icon'));
         // Update the table structure and options, if needed
         if (!empty(wp_slimstat::$options['version']) && wp_slimstat::$options['version'] != wp_slimstat::$version) {
             self::update_tables_and_options();
         } else {
             $admin_filemtime = @filemtime(__FILE__);
             if ($admin_filemtime < date('U') - 864000 && wp_slimstat::$options['enable_ads_network'] == 'null') {
                 wp_slimstat::$options['enable_ads_network'] = 'yes';
             }
         }
     }
     // Load the library of functions to generate the reports
     if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-view') !== false || !empty($_POST['action']) && $_POST['action'] == 'slimstat_load_report') {
         include_once dirname(__FILE__) . '/view/wp-slimstat-reports.php';
         wp_slimstat_reports::init();
     }
     // AJAX Handlers
     if (defined('DOING_AJAX') && DOING_AJAX) {
         add_action('wp_ajax_slimstat_load_report', array('wp_slimstat_reports', 'show_report_wrapper'));
         add_action('wp_ajax_slimstat_hide_admin_notice', array(__CLASS__, 'hide_admin_notice'));
     }
 }