Ejemplo n.º 1
0
             //Updates the chosen option
             $lingotek_option = 'lingotek_' . $setting;
             $source_options = get_blog_option($source_site, $lingotek_option);
             update_blog_option($destination, $lingotek_option, $source_options);
         }
     }
     //Creates a new project based on the name of the selected site
     if (isset($_POST['new_project'])) {
         $options = get_blog_option($destination, 'lingotek_defaults');
         $client = new Lingotek_API();
         $title = htmlspecialchars_decode(get_blog_details($destination)->blogname, ENT_QUOTES);
         if ($new_id = $client->create_project($title, $community_id = get_blog_option($destination, 'lingotek_community'))) {
             $options['project_id'] = $new_id;
             // Adds correct callback URL for new project
             $args = array('callback_url' => add_query_arg('lingotek', 1, get_blog_details($destination)->siteurl));
             $response = $client->patch($client->get_api_url() . '/project/' . $new_id, $args);
             update_blog_option($destination, 'lingotek_defaults', $options);
         }
     }
     if (isset($_POST['preferences'])) {
         switch_to_blog($source_site);
         $preferences = Lingotek_Model::get_prefs();
         update_blog_option($destination, 'lingotek_prefs', $preferences);
         restore_current_blog();
     }
     if (isset($_POST['utility_set_default_language'])) {
         switch_to_blog($destination);
         $GLOBALS['wp_lingotek']->utilities->run_utility('utility_set_default_language');
         restore_current_blog();
     }
 }