示例#1
0
 /**
  * This function is called from the Wordpress Settings menu
  */
 function settings()
 {
     // Get our options and see if we're handling a form submission.
     $action = OX_Tools::sanitize_post_var('advman-action');
     if ($action == 'save') {
         global $advman_engine;
         $settings = array('openx-market', 'openx-market-cpm', 'openx-sync', 'enable-php', 'stats', 'purge-stats-days');
         foreach ($settings as $setting) {
             $value = isset($_POST["advman-{$setting}"]) ? OX_Tools::sanitize($_POST["advman-{$setting}"]) : false;
             $advman_engine->setSetting($setting, $value);
         }
     }
     $template = Advman_Tools::get_template('Settings');
     $template->display();
 }
示例#2
0
 /**
  * This function is called from the Wordpress Settings menu
  */
 static function settings()
 {
     global $advman_engine;
     // Get our options and see if we're handling a form submission.
     $action = OX_Tools::sanitize_post_var('advman-action');
     if ($action == 'save') {
         global $advman_engine;
         // We need to know if we are changing the adjs settings
         $adjs_pre = $advman_engine->getSetting('enable-adjs');
         $settings = array('enable-php', 'stats', 'purge-stats-days', 'enable-adjs');
         foreach ($settings as $setting) {
             $value = isset($_POST["advman-{$setting}"]) ? OX_Tools::sanitize($_POST["advman-{$setting}"]) : false;
             $advman_engine->setSetting($setting, $value);
         }
         $adjs_post = $advman_engine->getSetting('enable-adjs');
         // If a user is turning on adjs
         // This generates a client ID given the admin email address and the domain.  Note:  user has given consent in settings if we have made it this far.
         if (!$adjs_pre && $adjs_post) {
             $url = 'http://adjs.io/beta_signups';
             $params = array('headers' => array("Accept" => 'application/json'), 'body' => array('beta_signup' => array("email" => get_option('admin_email'), "url" => get_option('siteurl'))));
             //                print_r($params);
             //                exit;
             $response = wp_remote_post($url, $params);
             if (is_array($response) && $response['body']) {
                 $clientId = json_decode($response['body'])->client_id;
                 $advman_engine->setSetting('adjs-clientid', $clientId);
             } else {
                 // Fail silently!
                 //                    print_r($response);
                 //                    exit;
             }
         }
         // If a user is turning off adjs
         // This generates a client ID given the admin email address and the domain.  Note:  user has given consent in settings if we have made it this far.
         if ($adjs_pre && !$adjs_post) {
             $clientId = $advman_engine->getSetting('adjs-clientid');
             if ($clientId) {
                 $url = "http://adjs.io/beta_signups/{$clientId}";
                 $params = array('method' => 'DELETE', 'headers' => array("Accept" => 'application/json'));
                 $response = wp_remote_request($url, $params);
                 if ($response['response'] && $response['response']['code'] == 204) {
                     $advman_engine->setSetting('adjs-clientid', '');
                 }
             }
         }
     }
     $template = Advman_Tools::get_template('Settings');
     $template->display();
 }