function wptouch_repair_active_theme_from_cloud(&$error_condition) { global $wptouch_pro; $result = true; $error_condition = false; $settings = wptouch_get_settings(); $wptouch_pro->setup_bncapi(); // We need to download the theme and then repair it $themes = $wptouch_pro->get_available_themes(true); if (isset($themes[$settings->current_theme_friendly_name])) { require_once WPTOUCH_DIR . '/core/addon-theme-installer.php'; $theme_to_install = $themes[$settings->current_theme_friendly_name]; $directory = wptouch_get_multsite_aware_install_path('themes'); $addon_installer = new WPtouchAddonThemeInstaller(); $result = $addon_installer->install_anywhere($theme_to_install->base, $theme_to_install->download_url, $directory); if ($result) { $wptouch_pro->repair_active_theme($directory, $settings->current_theme_friendly_name); } } return $result; }
function wptouch_pro_install_addon($addon_to_install) { require_once WPTOUCH_DIR . '/core/addon-theme-installer.php'; $destination_directory = wptouch_get_multsite_aware_install_path('extensions'); $addon_installer = new WPtouchAddonThemeInstaller(); $addon_installer->install_anywhere($addon_to_install->base, $addon_to_install->download_url, $destination_directory); $result = array(); if (file_exists($destination_directory . '/' . $addon_to_install->base)) { return str_replace(WP_CONTENT_DIR, '', $destination_directory) . '/' . $addon_to_install->base; } else { if ($addon_installer->had_error()) { return $addon_installer; } } }
function setup_languages() { $current_locale = get_locale(); // Check for language override $settings = wptouch_get_settings(); if (is_network_admin()) { $locale_setting = 'force_network_locale'; } else { $locale_setting = 'force_locale'; } $destination_directory = wptouch_get_multsite_aware_install_path('lang'); // Auto download code for language files if ($current_locale != 'en_US' || $settings->{$locale_setting} != 'auto' && $settings->{$locale_setting} != 'en_US') { if ($settings->{$locale_setting} != 'auto') { $current_locale = $settings->{$locale_setting}; } $this->setup_bncapi(); $bnc_api = $this->get_bnc_api(); $list = false; if (false === ($list = get_site_transient('_wptouch_language_info'))) { $list = $bnc_api->translations_get_list(); set_site_transient('_wptouch_language_info', $list, 3600 * 24); } $language_file = 'wptouch-pro-' . $current_locale . '.mo'; if (isset($list[$language_file])) { $should_install = false; if (!file_exists($destination_directory . '/' . $language_file)) { $should_install = true; } else { $language_file_size = filesize($destination_directory . '/' . $language_file); if ($language_file_size != $list[$language_file]['size']) { $should_install = true; } } if ($should_install) { require_once WPTOUCH_DIR . '/core/addon-theme-installer.php'; $installer = new WPtouchAddonThemeInstaller(); $language_to_install = $list[$language_file]; $installer->install_anywhere($language_file, $language_to_install['file'], $destination_directory); } } } if (!empty($current_locale)) { $current_locale = apply_filters('wptouch_language', $current_locale); $use_lang_file = false; $custom_lang_file = $destination_directory . '/wptouch-pro-' . $current_locale . '.mo'; if (file_exists($custom_lang_file) && is_readable($custom_lang_file)) { $use_lang_file = $custom_lang_file; $rel_path = str_replace(WP_CONTENT_DIR, '..', $destination_directory); $use_lang_rel_path = $rel_path; } else { $lang_file = WPTOUCH_DIR . '/lang/wptouch-pro-' . $current_locale . '.mo'; if (file_exists($lang_file) && is_readable($lang_file)) { $use_lang_file = $lang_file; if (defined('WPTOUCH_IS_FREE')) { $use_lang_rel_path = 'wptouch/lang'; } else { $use_lang_rel_path = 'wptouch-pro/lang'; } } } add_filter('plugin_locale', array(&$this, 'get_wordpress_locale'), 10, 2); $this->locale = $current_locale; if ($use_lang_file) { $can_load = true; if (is_admin() && !$settings->translate_admin) { $can_load = false; } if ($can_load) { load_plugin_textdomain('wptouch-pro', false, $use_lang_rel_path); WPTOUCH_DEBUG(WPTOUCH_INFO, 'Loading language file ' . $use_lang_file); } } do_action('wptouch_language_loaded', $this->locale); } }