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


PHP Theme_Upgrader::theme_info方法代码示例

本文整理汇总了PHP中Theme_Upgrader::theme_info方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme_Upgrader::theme_info方法的具体用法?PHP Theme_Upgrader::theme_info怎么用?PHP Theme_Upgrader::theme_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Theme_Upgrader的用法示例。


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

示例1: hooks_theme_install_or_update

 /**
  * @param Theme_Upgrader $upgrader
  * @param array $extra
  */
 public function hooks_theme_install_or_update($upgrader, $extra)
 {
     if (!isset($extra['type']) || 'theme' !== $extra['type']) {
         return;
     }
     if ('install' === $extra['action']) {
         $slug = $upgrader->theme_info();
         if (!$slug) {
             return;
         }
         wp_clean_themes_cache();
         $theme = wp_get_theme($slug);
         $name = $theme->name;
         $version = $theme->version;
         aal_insert_log(array('action' => 'installed', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
     }
     if ('update' === $extra['action']) {
         if (isset($extra['bulk']) && true == $extra['bulk']) {
             $slugs = $extra['themes'];
         } else {
             $slugs = array($upgrader->skin->theme);
         }
         foreach ($slugs as $slug) {
             $theme = wp_get_theme($slug);
             $stylesheet = $theme['Stylesheet Dir'] . '/style.css';
             $theme_data = get_file_data($stylesheet, array('Version' => 'Version'));
             $name = $theme['Name'];
             $version = $theme_data['Version'];
             aal_insert_log(array('action' => 'updated', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
         }
     }
 }
开发者ID:leogopal,项目名称:wordpress-aryo-activity-log,代码行数:36,代码来源:class-aal-hook-theme.php

示例2: theme_install_or_update

 /**
  * Theme install of update
  *
  * @since 0.1.0
  *
  * @param Theme_Upgrader $upgrader
  * @param array $extra
  */
 public function theme_install_or_update($upgrader, $extra)
 {
     // Bail if not a theme
     if (!isset($extra['type']) || 'theme' !== $extra['type']) {
         return;
     }
     // Install
     if ('install' === $extra['action']) {
         // Bail if no theme found
         $slug = $upgrader->theme_info();
         if (empty($slug)) {
             return;
         }
         wp_clean_themes_cache();
         $theme = wp_get_theme($slug);
         $name = $theme->name;
         $version = $theme->version;
         // Insert activity
         wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $version, 'object_name' => $name, 'action' => 'install'));
         // Update
     } elseif ('update' === $extra['action']) {
         // Get theme slugs
         if (isset($extra['bulk']) && true == $extra['bulk']) {
             $slugs = $extra['themes'];
         } else {
             $slugs = array($upgrader->skin->theme);
         }
         // Activity for each theme
         foreach ($slugs as $slug) {
             $theme = wp_get_theme($slug);
             $stylesheet = $theme['Stylesheet Dir'] . '/style.css';
             $theme_data = get_file_data($stylesheet, array('Version' => 'Version'));
             $name = $theme['Name'];
             $version = $theme_data['Version'];
             // Insert activity
             wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $version, 'object_name' => $name, 'action' => 'update'));
         }
     }
 }
开发者ID:wir,项目名称:wp-user-activity,代码行数:47,代码来源:class-action-themes.php

示例3: install_themes

 private function install_themes($themes)
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/plugin.php';
     require_once ABSPATH . 'wp-admin/includes/theme.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/upgrader-skin.php';
     $upgrader = new Theme_Upgrader(new Ithemes_Sync_Upgrader_Skin());
     $results = array();
     foreach ((array) $themes as $theme) {
         Ithemes_Sync_Functions::set_time_limit(300);
         if (preg_match('{^(http|https|ftp)://}i', $theme)) {
             $result = $upgrader->install($theme);
         } else {
             $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false)));
             if (is_wp_error($api)) {
                 $result = $api;
             } else {
                 $result = $upgrader->install($api->download_link);
             }
         }
         if (is_wp_error($result)) {
             $results[$theme]['error'] = array('error_code' => $result->get_error_code(), 'error_details' => $result->get_error_message());
         } else {
             $results[$theme]['result'] = $result;
             $theme_info = $upgrader->theme_info();
             $results[$theme]['name'] = $theme_info->get('Name');
             $results[$theme]['version'] = $theme_info->get('Version');
             if (is_object($theme_info) && is_callable(array($theme_info, 'get_stylesheet'))) {
                 $results[$theme]['slug'] = basename($theme_info->get_stylesheet());
             } else {
                 if (isset($upgrader->result) && !empty($upgrader->result['destination_name'])) {
                     $results[$theme]['slug'] = $upgrader->result['destination_name'];
                 }
             }
             if (true === $result) {
                 $results[$theme]['success'] = true;
             }
         }
     }
     Ithemes_Sync_Functions::refresh_theme_updates();
     return $results;
 }
开发者ID:AndyA,项目名称:River,代码行数:43,代码来源:manage-themes.php


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