本文整理汇总了PHP中Language_Pack_Upgrader::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Language_Pack_Upgrader::init方法的具体用法?PHP Language_Pack_Upgrader::init怎么用?PHP Language_Pack_Upgrader::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language_Pack_Upgrader
的用法示例。
在下文中一共展示了Language_Pack_Upgrader::init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_can_install_language_pack
/**
* Check if WordPress has access to the filesystem without asking for
* credentials.
*
* @since 4.0.0
*
* @return bool Returns true on success, false on failure.
*/
function wp_can_install_language_pack()
{
if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
return false;
}
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Language_Pack_Upgrader($skin);
$upgrader->init();
$check = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_LANG_DIR));
if (!$check || is_wp_error($check)) {
return false;
}
return true;
}
示例2: foreach
function update_translations()
{
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// Clear the cache.
wp_update_themes();
$available_themes_updates = get_site_transient('update_themes');
if (!isset($available_themes_updates->translations) || empty($available_themes_updates->translations)) {
return new WP_Error('nothing_to_translate');
}
foreach ($available_themes_updates->translations as $translation) {
$theme = $translation['slug'];
if (!in_array($translation['slug'], $this->themes)) {
$this->log[$theme][] = __('No update needed', 'jetpack');
continue;
}
/**
* Pre-upgrade action
*
* @since 4.4
*
* @param object $theme WP_Theme object
* @param array $themes Array of theme objects
*/
do_action('jetpack_pre_theme_upgrade_translations', $theme, $this->themes);
// Objects created inside the for loop to clean the messages for each theme
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Language_Pack_Upgrader($skin);
$upgrader->init();
$result = $upgrader->upgrade((object) $translation);
$this->log[$theme] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && !$result) {
return new WP_Error('update_fail', __('There was an error updating your theme', 'jetpack'), 400);
}
return true;
}
示例3: wp_can_install_language_pack
/**
* Check if WordPress has access to the filesystem without asking for
* credentials.
*
* @since 4.0.0
*
* @return bool Returns true on success, false on failure.
*/
function wp_can_install_language_pack()
{
if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
return false;
}
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Language_Pack_Upgrader($skin);
$upgrader->init();
$check = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_LANG_DIR));
if (!$check || is_wp_error($check)) {
return false;
}
return true;
}
示例4: foreach
function update_translations()
{
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
// Clear the cache.
wp_clean_plugins_cache();
ob_start();
wp_update_plugins();
// Check for Plugin updates
ob_end_clean();
$available_updates = get_site_transient('update_plugins');
if (!isset($available_updates->translations) || empty($available_updates->translations)) {
return new WP_Error('nothing_to_translate');
}
$update_attempted = false;
$result = false;
foreach ($this->plugins as $plugin) {
$this->slug = Jetpack_Autoupdate::get_plugin_slug($plugin);
$translation = array_filter($available_updates->translations, array($this, 'get_translation'));
if (empty($translation)) {
$this->log[$plugin][] = __('No update needed', 'jetpack');
continue;
}
/**
* Pre-upgrade action
*
* @since 4.4
*
* @param array $plugin Plugin data
* @param array $plugin Array of plugin objects
* @param bool $updated_attempted false for the first update, true subsequently
*/
do_action('jetpack_pre_plugin_upgrade_translations', $plugin, $this->plugins, $update_attempted);
$update_attempted = true;
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Language_Pack_Upgrader($skin);
$upgrader->init();
$result = $upgrader->upgrade((object) $translation[0]);
$this->log[$plugin] = $upgrader->skin->get_upgrade_messages();
}
if (!$this->bulk && !$result) {
return new WP_Error('update_fail', __('There was an error updating your plugin', 'jetpack'), 400);
}
return true;
}