当前位置: 首页>>代码示例>>PHP>>正文


PHP delete_theme函数代码示例

本文整理汇总了PHP中delete_theme函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_theme函数的具体用法?PHP delete_theme怎么用?PHP delete_theme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delete_theme函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 protected function delete()
 {
     foreach ($this->themes as $theme) {
         // Don't delete an active child theme
         if (is_child_theme() && $theme == get_stylesheet()) {
             $error = $this->log[$theme]['error'] = 'You cannot delete a theme while it is active on the main site.';
             continue;
         }
         if ($theme == get_template()) {
             $error = $this->log[$theme]['error'] = 'You cannot delete a theme while it is active on the main site.';
             continue;
         }
         /**
          * Filters whether to use an alternative process for deleting a WordPress.com theme.
          * The alternative process can be executed during the filter.
          *
          * The filter can also return an instance of WP_Error; in which case the endpoint response will
          * contain this error.
          *
          * @module json-api
          *
          * @since 4.4.2
          *
          * @param bool   $use_alternative_delete_method Whether to use the alternative method of deleting
          *                                              a WPCom theme.
          * @param string $theme_slug                    Theme name (slug). If it is a WPCom theme,
          *                                              it should be suffixed with `-wpcom`.
          */
         $result = apply_filters('jetpack_wpcom_theme_delete', false, $theme);
         if (!$result) {
             $result = delete_theme($theme);
         }
         if (is_wp_error($result)) {
             $error = $this->log[$theme]['error'] = $result->get_error_messages;
         } else {
             $this->log[$theme][] = 'Theme deleted';
         }
     }
     if (!$this->bulk && isset($error)) {
         return new WP_Error('delete_theme_error', $error, 400);
     }
     return true;
 }
开发者ID:automattic,项目名称:jetpack,代码行数:43,代码来源:class.jetpack-json-api-themes-delete-endpoint.php

示例2: delete

 protected function delete()
 {
     foreach ($this->themes as $theme) {
         // Don't delete an active child theme
         if (is_child_theme() && $theme == get_stylesheet()) {
             $error = $this->log[$theme]['error'] = 'You cannot delete a theme while it is active on the main site.';
             continue;
         }
         if ($theme == get_template()) {
             $error = $this->log[$theme]['error'] = 'You cannot delete a theme while it is active on the main site.';
             continue;
         }
         $result = delete_theme($theme);
         if (is_wp_error($result)) {
             $error = $this->log[$theme]['error'] = $result->get_error_messages;
         } else {
             $this->log[$theme][] = 'Theme deleted';
         }
     }
     if (!$this->bulk && isset($error)) {
         return new WP_Error('delete_theme_error', $error, 400);
     }
     return true;
 }
开发者ID:shazadmaved,项目名称:vizblog,代码行数:24,代码来源:class.jetpack-json-api-themes-delete-endpoint.php

示例3: edit_themes

 public function edit_themes($args)
 {
     extract($args);
     $return = array();
     foreach ($items as $item) {
         switch ($items_edit_action) {
             case 'activate':
                 switch_theme($item['path'], $item['stylesheet']);
                 break;
             case 'delete':
                 $result = delete_theme($item['path']);
                 break;
             default:
                 break;
         }
         if (is_wp_error($result)) {
             $result = array('error' => $result->get_error_message());
         } elseif ($result === false) {
             $result = array('error' => "Failed to perform action.");
         } else {
             $result = "OK";
         }
         $return[$item['name']] = $result;
     }
     return $return;
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:26,代码来源:Installer.php

示例4: wp_ajax_delete_theme

/**
 * Ajax handler for deleting a theme.
 *
 * @since 4.6.0
 *
 * @see delete_theme()
 */
function wp_ajax_delete_theme()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug'])) {
        wp_send_json_error(array('slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __('No theme specified.')));
    }
    $stylesheet = sanitize_key(wp_unslash($_POST['slug']));
    $status = array('delete' => 'theme', 'slug' => $stylesheet);
    if (!current_user_can('delete_themes')) {
        $status['errorMessage'] = __('Sorry, you are not allowed to delete themes on this site.');
        wp_send_json_error($status);
    }
    if (!wp_get_theme($stylesheet)->exists()) {
        $status['errorMessage'] = __('The requested theme does not exist.');
        wp_send_json_error($status);
    }
    // Check filesystem credentials. `delete_theme()` will bail otherwise.
    $url = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode($stylesheet), 'delete-theme_' . $stylesheet);
    ob_start();
    $credentials = request_filesystem_credentials($url);
    ob_end_clean();
    if (false === $credentials || !WP_Filesystem($credentials)) {
        global $wp_filesystem;
        $status['errorCode'] = 'unable_to_connect_to_filesystem';
        $status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
        // Pass through the error from WP_Filesystem if one was raised.
        if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
            $status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
        }
        wp_send_json_error($status);
    }
    include_once ABSPATH . 'wp-admin/includes/theme.php';
    $result = delete_theme($stylesheet);
    if (is_wp_error($result)) {
        $status['errorMessage'] = $result->get_error_message();
        wp_send_json_error($status);
    } elseif (false === $result) {
        $status['errorMessage'] = __('Theme could not be deleted.');
        wp_send_json_error($status);
    }
    wp_send_json_success($status);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:49,代码来源:ajax-actions.php

示例5: delete_default_content

 function delete_default_content()
 {
     delete_theme('twentysixteen');
     delete_theme('twentyfifteen');
     delete_theme('twentyfourteen');
     delete_theme('twentythirteen');
     delete_theme('twentytwelve');
     delete_theme('twentyeleven');
     delete_theme('twentyten');
     delete_plugins(array('hello.php', 'akismet/akismet.php'));
 }
开发者ID:pravdomil,项目名称:WP-Quick-Install,代码行数:11,代码来源:wp-quick-install.php

示例6: delete

 /**
  * Delete a theme.
  *
  * Removes the theme from the filesystem.
  *
  * ## OPTIONS
  *
  * <theme>...
  * : One or more themes to delete.
  *
  * ## EXAMPLES
  *
  *     $ wp theme delete twentytwelve
  *     Deleted 'twentytwelve' theme.
  *     Success: Deleted 1 of 1 themes.
  *
  * @alias uninstall
  */
 public function delete($args)
 {
     $successes = $errors = 0;
     foreach ($this->fetcher->get_many($args) as $theme) {
         $theme_slug = $theme->get_stylesheet();
         if ($this->is_active_theme($theme)) {
             WP_CLI::warning("Can't delete the currently active theme: {$theme_slug}");
             $errors++;
             continue;
         }
         $r = delete_theme($theme_slug);
         if (is_wp_error($r)) {
             WP_CLI::warning($r);
             $errors++;
         } else {
             WP_CLI::log("Deleted '{$theme_slug}' theme.");
             $successes++;
         }
     }
     if (!$this->chained_command) {
         Utils\report_batch_operation_results('theme', 'delete', count($args), $successes, $errors);
     }
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:41,代码来源:theme.php

示例7: wp_die

            wp_die(__('Cheatin&#8217; uh?'), 403);
        }
        switch_theme($theme->get_stylesheet());
        wp_redirect(admin_url('themes.php?activated=true'));
        exit;
    } elseif ('delete' == $_GET['action']) {
        check_admin_referer('delete-theme_' . $_GET['stylesheet']);
        $theme = wp_get_theme($_GET['stylesheet']);
        if (!current_user_can('delete_themes') || !$theme->exists()) {
            wp_die(__('Cheatin&#8217; uh?'), 403);
        }
        $active = wp_get_theme();
        if ($active->get('Template') == $_GET['stylesheet']) {
            wp_redirect(admin_url('themes.php?delete-active-child=true'));
        } else {
            delete_theme($_GET['stylesheet']);
            wp_redirect(admin_url('themes.php?deleted=true'));
        }
        exit;
    }
}
$title = __('Manage Themes');
$parent_file = 'themes.php';
// Help tab: Overview
if (current_user_can('switch_themes')) {
    $help_overview = '<p>' . __('This screen is used for managing your installed themes. Aside from the default theme(s) included with your WordPress installation, themes are designed and developed by third parties.') . '</p>' . '<p>' . __('From this screen you can:') . '</p>' . '<ul><li>' . __('Hover or tap to see Activate and Live Preview buttons') . '</li>' . '<li>' . __('Click on the theme to see the theme name, version, author, description, tags, and the Delete link') . '</li>' . '<li>' . __('Click Customize for the current theme or Live Preview for any other theme to see a live preview') . '</li></ul>' . '<p>' . __('The current theme is displayed highlighted as the first theme.') . '</p>' . '<p>' . __('The search for installed themes will search for terms in their name, description, author, or tag.') . ' <span id="live-search-desc">' . __('The search results will be updated as you type.') . '</span></p>';
    get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => $help_overview));
}
// switch_themes
// Help tab: Adding Themes
if (current_user_can('install_themes')) {
开发者ID:ycms,项目名称:framework,代码行数:31,代码来源:themes.php

示例8: delete

 /**
  * Delete a theme.
  *
  * ## OPTIONS
  *
  * <theme>...
  * : One or more themes to delete.
  *
  * ## EXAMPLES
  *
  *     wp theme delete twentyeleven
  */
 function delete($args)
 {
     foreach ($this->fetcher->get_many($args) as $theme) {
         $theme_slug = $theme->get_stylesheet();
         if ($this->is_active_theme($theme)) {
             WP_CLI::warning("Can't delete the currently active theme: {$theme_slug}");
             continue;
         }
         $r = delete_theme($theme_slug);
         if (is_wp_error($r)) {
             WP_CLI::warning($r);
         } else {
             WP_CLI::success("Deleted '{$theme_slug}' theme.");
         }
     }
 }
开发者ID:ptahdunbar,项目名称:wp-cli,代码行数:28,代码来源:theme.php

示例9: delete

 function delete($args)
 {
     $this->_escape($args);
     $username = $args[0];
     $password = $args[1];
     $template = $args[2];
     if ($password != get_option('wpr_cron')) {
         if (!($user = $this->login($username, $password))) {
             return $this->error;
         }
         if (!current_user_can('update_themes')) {
             return new IXR_Error(401, 'Sorry, you are not allowed to delete themes from the remote blog.');
         }
     }
     ob_start();
     $result = delete_theme($template);
     ob_end_clean();
     if (is_wp_error($result)) {
         return new IXR_Error(401, 'Theme could not be deleted. ' . $result->get_error_message());
     }
     return TRUE;
 }
开发者ID:satishux,项目名称:fitnesshack,代码行数:22,代码来源:display-cl.php

示例10: delete

 /**
  * Delete a theme.
  *
  * @synopsis <theme>
  */
 function delete($args)
 {
     list($file, $name) = $this->parse_name($args);
     $r = delete_theme($name);
     if (is_wp_error($r)) {
         WP_CLI::error($r);
     }
 }
开发者ID:navitronic,项目名称:wp-cli-1,代码行数:13,代码来源:theme.php

示例11: switch

  switch ($data['action']) {
    case 'getAllThemesList':
      get_all_themes_list();
      break;
    case 'getAllThemes':
      get_all_themes();
      break;
    case 'getThemeInfo':
      get_theme_info();
      break;
    case 'saveThemeInfo':
      save_theme_info();
      break;
    case 'deleteTheme':
      delete_theme();
      break;
    case 'getAllCategoriesList':
      get_all_categories_list();
      break;
    case 'getCategoryInfo':
      get_category_info();
      break;
    case 'saveCategoryInfo':
      save_category_info();
      break;
    case 'deleteCategory':
      delete_category();
      break;
    case 'getAllLayersList':
      get_all_layers_list();
开发者ID:rahool,项目名称:maplocator,代码行数:30,代码来源:ml_json_data.php

示例12: wp_delete_theme

 /**
  * Supprime les themes default de Wordpress
  *
  */
 public function wp_delete_theme()
 {
     require_once 'wp-load.php';
     require_once 'wp-admin/includes/upgrade.php';
     delete_theme('twentyfourteen');
     delete_theme('twentythirteen');
     delete_theme('twentytwelve');
     delete_theme('twentyeleven');
     delete_theme('twentyten');
     // We delete the _MACOSX folder (bug with a Mac)
     delete_theme('__MACOSX');
 }
开发者ID:Aigleblanc,项目名称:wp-migration-url,代码行数:16,代码来源:migration.php

示例13: handleInstall


//.........这里部分代码省略.........
                             $args = array('post_title' => trim($post['title']), 'post_name' => $post['slug'], 'post_content' => trim($post['content']), 'post_status' => $post['status'], 'post_type' => $post['type'], 'post_parent' => $parent, 'post_author' => 1, 'post_date' => date('Y-m-d H:i:s'), 'post_date_gmt' => gmdate('Y-m-d H:i:s'), 'comment_status' => 'closed', 'ping_status' => 'closed');
                             wp_insert_post($args);
                         }
                     }
                 }
             }
             break;
         case "install_theme":
             /** Load WordPress Bootstrap */
             require_once $directory . 'wp-load.php';
             /** Load WordPress Administration Upgrade API */
             require_once $directory . 'wp-admin/includes/upgrade.php';
             /*--------------------------*/
             /*	We install the new theme
             			/*--------------------------*/
             // We verify if theme.zip exists
             if (file_exists(app_path() . '/Http/Controllers/Software/wordpress/theme.zip')) {
                 $zip = new \ZipArchive();
                 // We verify we can use it
                 if ($zip->open(app_path() . '/Http/Controllers/Software/wordpress/theme.zip') === true) {
                     // We retrieve the name of the folder
                     $stat = $zip->statIndex(0);
                     $theme_name = str_replace('/', '', $stat['name']);
                     // We unzip the archive in the themes folder
                     $zip->extractTo($directory . 'wp-content/themes/');
                     $zip->close();
                     // Let's activate the theme
                     // Note : The theme is automatically activated if the user asked to remove the default theme
                     if (isset($postInfo['activate_theme']) && $postInfo['activate_theme'] == 1 || $postInfo['delete_default_themes'] == 1) {
                         switch_theme($theme_name, $theme_name);
                     }
                     // Let's remove the Tweenty family
                     if (isset($postInfo['delete_default_themes']) && $postInfo['delete_default_themes'] == 1) {
                         delete_theme('twentyfourteen');
                         delete_theme('twentythirteen');
                         delete_theme('twentytwelve');
                         delete_theme('twentyeleven');
                         delete_theme('twentyten');
                     }
                     // We delete the _MACOSX folder (bug with a Mac)
                     delete_theme('__MACOSX');
                 }
             }
             break;
         case "install_plugins":
             /*--------------------------*/
             /*	Let's retrieve the plugin folder
             			/*--------------------------*/
             if (isset($postInfo['plugins']) && !empty($postInfo['plugins'])) {
                 $plugins = explode(";", $postInfo['plugins']);
                 $plugins = array_map('trim', $plugins);
                 $plugins_dir = $directory . 'wp-content/plugins/';
                 foreach ($plugins as $plugin) {
                     // We retrieve the plugin XML file to get the link to downlad it
                     $plugin_repo = file_get_contents("http://api.wordpress.org/plugins/info/1.0/{$plugin}.json");
                     if ($plugin_repo && ($plugin = json_decode($plugin_repo))) {
                         $plugin_path = $this->WPQI_CACHE_PLUGINS_PATH . $plugin->slug . '-' . $plugin->version . '.zip';
                         if (!file_exists($plugin_path)) {
                             // We download the lastest version
                             if ($download_link = file_get_contents($plugin->download_link)) {
                                 file_put_contents($plugin_path, $download_link);
                             }
                         }
                         // We unzip it
                         $zip = new \ZipArchive();
                         if ($zip->open($plugin_path) === true) {
开发者ID:UCCNetworkingSociety,项目名称:NetsocAdmin,代码行数:67,代码来源:Wordpress.php

示例14: switch_theme

             $zip->close();
             // Let's activate the theme
             // Note : The theme is automatically activated if the user asked to remove the default theme
             if ($_POST['activate_theme'] == 1 || $_POST['delete_default_themes'] == 1) {
                 switch_theme($theme_name, $theme_name);
             }
             // Let's remove the Tweenty family
             if ($_POST['delete_default_themes'] == 1) {
                 delete_theme('twentyfourteen');
                 delete_theme('twentythirteen');
                 delete_theme('twentytwelve');
                 delete_theme('twentyeleven');
                 delete_theme('twentyten');
             }
             // We delete the _MACOSX folder (bug with a Mac)
             delete_theme('__MACOSX');
         }
     }
     break;
 case "install_plugins":
     /*--------------------------*/
     /*	Let's retrieve the plugin folder
     			/*--------------------------*/
     if (!empty($_POST['plugins'])) {
         $plugins = explode(";", $_POST['plugins']);
         $plugins = array_map('trim', $plugins);
         $plugins_dir = $directory . 'wp-content/plugins/';
         foreach ($plugins as $plugin) {
             // We retrieve the plugin XML file to get the link to downlad it
             $plugin_repo = file_get_contents("http://api.wordpress.org/plugins/info/1.0/{$plugin}.json");
             if ($plugin_repo && ($plugin = json_decode($plugin_repo))) {
开发者ID:OusainouTouray,项目名称:install-wp,代码行数:31,代码来源:index.php

示例15: install_theme

function install_theme()
{
    $directory = DIRECTORY;
    /** Load WordPress Bootstrap */
    require_once $directory . 'wp-load.php';
    /** Load WordPress Administration Upgrade API */
    require_once $directory . 'wp-admin/includes/upgrade.php';
    /*--------------------------*/
    /*	We install the new theme
    	/*--------------------------*/
    // We verify if theme.zip exists
    if (file_exists('theme.zip')) {
        $zip = new ZipArchive();
        // We verify we can use it
        if ($zip->open('theme.zip') === true) {
            // We retrieve the name of the folder
            $stat = $zip->statIndex(0);
            $theme_name = str_replace('/', '', $stat['name']);
            // We unzip the archive in the themes folder
            $zip->extractTo($directory . 'wp-content/themes/');
            $zip->close();
            // Let's activate the theme
            // Note : The theme is automatically activated if the user asked to remove the default theme
            if (ACTIVATEDTHEME == 1 || DELETEDEFAULTTHEMES == 1) {
                switch_theme($theme_name, $theme_name);
            }
            // Let's remove the Tweenty family
            if (DELETEDEFAULTTHEMES == 1) {
                delete_theme('twentysixteen');
                delete_theme('twentyfithteen');
                delete_theme('twentyfourteen');
                delete_theme('twentythirteen');
                delete_theme('twentytwelve');
                delete_theme('twentyeleven');
                delete_theme('twentyten');
            }
            // We delete the _MACOSX folder (bug with a Mac)
            delete_theme('__MACOSX');
        }
    }
    return true;
}
开发者ID:GenerationLabs,项目名称:WP-Quick-Install,代码行数:42,代码来源:functions.php


注:本文中的delete_theme函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。