Ejemplo n.º 1
0
 /**
  * The function for the advanced admin section
  */
 public static function advanced_admin()
 {
     $settings = ShareaholicUtilities::get_settings();
     $api_key = ShareaholicUtilities::get_or_create_api_key();
     $action = str_replace('%7E', '~', $_SERVER['REQUEST_URI']);
     if (!ShareaholicUtilities::has_accepted_terms_of_service()) {
         ShareaholicUtilities::load_template('terms_of_service_modal', array('image_url' => SHAREAHOLIC_ASSET_DIR . 'img'));
     }
     if (isset($_POST['reset_settings']) && $_POST['reset_settings'] == 'Y' && check_admin_referer($action, 'nonce_field')) {
         ShareaholicUtilities::destroy_settings();
         echo "<div class='updated settings_updated'><p><strong>" . sprintf(__('Settings successfully reset. Refresh this page to complete the reset.', 'shareaholic')) . "</strong></p></div>";
     }
     if (isset($_POST['already_submitted']) && $_POST['already_submitted'] == 'Y' && check_admin_referer($action, 'nonce_field')) {
         echo "<div class='updated settings_updated'><p><strong>" . sprintf(__('Settings successfully saved', 'shareaholic')) . "</strong></p></div>";
         foreach (array('disable_tracking', 'disable_og_tags', 'disable_admin_bar_menu', 'disable_debug_info', 'disable_internal_share_counts_api') as $setting) {
             if (isset($settings[$setting]) && !isset($_POST['shareaholic'][$setting]) && $settings[$setting] == 'on') {
                 $_POST['shareaholic'][$setting] = 'off';
             } elseif (!isset($_POST['shareaholic'][$setting])) {
                 $_POST['shareaholic'][$setting] = array();
             }
         }
         if (isset($_POST['shareaholic']['api_key']) && $_POST['shareaholic']['api_key'] != $api_key) {
             ShareaholicUtilities::get_new_location_name_ids($_POST['shareaholic']['api_key']);
         }
         if (isset($_POST['shareaholic']['api_key'])) {
             ShareaholicUtilities::update_options(array('api_key' => $_POST['shareaholic']['api_key']));
         }
         if (isset($_POST['shareaholic']['disable_tracking'])) {
             ShareaholicUtilities::update_options(array('disable_tracking' => $_POST['shareaholic']['disable_tracking']));
         }
         if (isset($_POST['shareaholic']['disable_og_tags'])) {
             ShareaholicUtilities::update_options(array('disable_og_tags' => $_POST['shareaholic']['disable_og_tags']));
         }
         if (isset($_POST['shareaholic']['disable_admin_bar_menu'])) {
             ShareaholicUtilities::update_options(array('disable_admin_bar_menu' => $_POST['shareaholic']['disable_admin_bar_menu']));
         }
         if (isset($_POST['shareaholic']['disable_debug_info'])) {
             ShareaholicUtilities::update_options(array('disable_debug_info' => $_POST['shareaholic']['disable_debug_info']));
         }
         if (isset($_POST['shareaholic']['disable_internal_share_counts_api'])) {
             ShareaholicUtilities::update_options(array('disable_internal_share_counts_api' => $_POST['shareaholic']['disable_internal_share_counts_api']));
         }
         ShareaholicUtilities::log_event("UpdatedSettings");
         // clear cache after settings update
         ShareaholicUtilities::clear_cache();
     }
     ShareaholicUtilities::load_template('advanced_settings', array('settings' => ShareaholicUtilities::get_settings(), 'action' => $action));
 }