Example #1
0
 public function save_option($input)
 {
     // TODO: Implement save_option() method.
     if (!isset(self::$instance)) {
         self::$instance = true;
         if (!empty($input['account']['marker']) && \app\includes\TPPlugin::$options['account']['marker'] != $input['account']['marker']) {
             $request = 'http://metrics.aviasales.ru/?goal=tp_wp_plugin_activation&data={"merker":' . $input['account']['marker'] . ',"domain":"' . preg_replace("(^https?://)", "", get_option('home')) . '"}';
             $string = htmlspecialchars($request);
             $response = wp_remote_get($string, array('headers' => array('Accept-Encoding' => 'gzip, deflate')));
         }
         if (isset($input['wizard'])) {
             \app\includes\TPPlugin::$options['account']['marker'] = $input['account']['marker'];
             \app\includes\TPPlugin::$options['account']['token'] = $input['account']['token'];
             \app\includes\TPPlugin::$options['local']['localization'] = $input['local']['localization'];
             \app\includes\TPPlugin::$options['local']['currency'] = $input['local']['currency'];
             self::$result = \app\includes\TPPlugin::$options;
         } else {
             self::$result = array_merge(\app\includes\TPPlugin::$options, $input);
         }
         \app\includes\TPPlugin::deleteCacheAll();
     }
     return self::$result;
 }
Example #2
0
 public function importSettings()
 {
     if (is_array($_POST['value'])) {
         $settings = array_replace_recursive(\app\includes\TPPlugin::$options, $_POST['value']);
         update_option(TPOPlUGIN_OPTION_NAME, $settings);
         //error_log(print_r($settings,true));
         //error_log(print_r(\app\includes\TPPlugin::$options, true));
         \app\includes\TPPlugin::deleteCacheAll();
     }
     //error_log(print_r($_POST, true));
     /*$base64 = $_POST['value'];
     
             if ( strpos($base64, 'text/plain') ) {
                 $file = str_replace('data:text/plain;base64,', '', $base64);
                 $file = str_replace(' ', '+', $file);
                 $data = base64_decode($file);
     
                 $options = json_decode($data,true);
                 error_log(print_r($options,true));
                 if(is_array($options)){
                     update_option( TPOPlUGIN_OPTION_NAME, $options);
                 }
             }*/
 }