當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_Theme::network_disable_theme方法代碼示例

本文整理匯總了PHP中WP_Theme::network_disable_theme方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Theme::network_disable_theme方法的具體用法?PHP WP_Theme::network_disable_theme怎麽用?PHP WP_Theme::network_disable_theme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_Theme的用法示例。


在下文中一共展示了WP_Theme::network_disable_theme方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete_theme

/**
 * Remove a theme
 *
 * @since 2.8.0
 *
 * @global WP_Filesystem_Base $wp_filesystem Subclass
 *
 * @param string $stylesheet Stylesheet of the theme to delete
 * @param string $redirect Redirect to page when complete.
 * @return void|bool|WP_Error When void, echoes content.
 */
function delete_theme($stylesheet, $redirect = '')
{
    global $wp_filesystem;
    if (empty($stylesheet)) {
        return false;
    }
    if (empty($redirect)) {
        $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode($stylesheet), 'delete-theme_' . $stylesheet);
    }
    ob_start();
    $credentials = request_filesystem_credentials($redirect);
    $data = ob_get_clean();
    if (false === $credentials) {
        if (!empty($data)) {
            include_once ABSPATH . 'wp-admin/admin-header.php';
            echo $data;
            include ABSPATH . 'wp-admin/admin-footer.php';
            exit;
        }
        return;
    }
    if (!WP_Filesystem($credentials)) {
        ob_start();
        request_filesystem_credentials($redirect, '', true);
        // Failed to connect, Error and request again.
        $data = ob_get_clean();
        if (!empty($data)) {
            include_once ABSPATH . 'wp-admin/admin-header.php';
            echo $data;
            include ABSPATH . 'wp-admin/admin-footer.php';
            exit;
        }
        return;
    }
    if (!is_object($wp_filesystem)) {
        return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
    }
    if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
        return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
    }
    // Get the base plugin folder.
    $themes_dir = $wp_filesystem->wp_themes_dir();
    if (empty($themes_dir)) {
        return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.'));
    }
    $themes_dir = trailingslashit($themes_dir);
    $theme_dir = trailingslashit($themes_dir . $stylesheet);
    $deleted = $wp_filesystem->delete($theme_dir, true);
    if (!$deleted) {
        return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $stylesheet));
    }
    $theme_translations = wp_get_installed_translations('themes');
    // Remove language files, silently.
    if (!empty($theme_translations[$stylesheet])) {
        $translations = $theme_translations[$stylesheet];
        foreach ($translations as $translation => $data) {
            $wp_filesystem->delete(WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po');
            $wp_filesystem->delete(WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo');
        }
    }
    // Remove the theme from allowed themes on the network.
    if (is_multisite()) {
        WP_Theme::network_disable_theme($stylesheet);
    }
    // Force refresh of theme update information.
    delete_site_transient('update_themes');
    return true;
}
開發者ID:johnpbloch,項目名稱:wordpress,代碼行數:79,代碼來源:theme.php

示例2: test_network_disable_multiple_themes

 /**
  * Disable multiple themes on a network.
  *
  * @ticket 30594
  */
 function test_network_disable_multiple_themes()
 {
     if (!is_multisite()) {
         $this->markTestSkipped('This test requires multisite');
     }
     $current_allowed_themes = get_site_option('allowedthemes');
     $allowed_themes = array('existing-4' => true, 'existing-5' => true, 'existing-6' => true);
     update_site_option('allowedthemes', $allowed_themes);
     $disable_themes = array('existing-4', 'existing-5');
     WP_Theme::network_disable_theme($disable_themes);
     $new_allowed_themes = get_site_option('allowedthemes');
     update_site_option('allowedthemes', $current_allowed_themes);
     // reset previous value.
     unset($allowed_themes['existing-4']);
     unset($allowed_themes['existing-5']);
     $this->assertEqualSetsWithIndex($allowed_themes, $new_allowed_themes);
 }
開發者ID:atimmer,項目名稱:wordpress-develop-mirror,代碼行數:22,代碼來源:WPTheme.php

示例3: isset

     $themes = isset($_POST['checked']) ? (array) $_POST['checked'] : array();
     if (empty($themes)) {
         wp_safe_redirect(add_query_arg('error', 'none', $referer));
         exit;
     }
     WP_Theme::network_enable_theme((array) $themes);
     wp_safe_redirect(add_query_arg('enabled', count($themes), $referer));
     exit;
 case 'disable-selected':
     check_admin_referer('bulk-themes');
     $themes = isset($_POST['checked']) ? (array) $_POST['checked'] : array();
     if (empty($themes)) {
         wp_safe_redirect(add_query_arg('error', 'none', $referer));
         exit;
     }
     WP_Theme::network_disable_theme((array) $themes);
     wp_safe_redirect(add_query_arg('disabled', count($themes), $referer));
     exit;
 case 'update-selected':
     check_admin_referer('bulk-themes');
     if (isset($_GET['themes'])) {
         $themes = explode(',', $_GET['themes']);
     } elseif (isset($_POST['checked'])) {
         $themes = (array) $_POST['checked'];
     } else {
         $themes = array();
     }
     $title = __('Update Themes');
     $parent_file = 'themes.php';
     require_once ABSPATH . 'wp-admin/admin-header.php';
     echo '<div class="wrap">';
開發者ID:CompositeUK,項目名稱:clone.WordPress-Core,代碼行數:31,代碼來源:themes.php


注:本文中的WP_Theme::network_disable_theme方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。