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


PHP WP_Theme::sort_by_name方法代码示例

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


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

示例1: prepare_items

	/**
	 * @access public
	 */
	public function prepare_items() {
		$themes = wp_get_themes( array( 'allowed' => true ) );

		if ( ! empty( $_REQUEST['s'] ) )
			$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) );

		if ( ! empty( $_REQUEST['features'] ) )
			$this->features = $_REQUEST['features'];

		if ( $this->search_terms || $this->features ) {
			foreach ( $themes as $key => $theme ) {
				if ( ! $this->search_theme( $theme ) )
					unset( $themes[ $key ] );
			}
		}

		unset( $themes[ get_option( 'stylesheet' ) ] );
		WP_Theme::sort_by_name( $themes );

		$per_page = 36;
		$page = $this->get_pagenum();

		$start = ( $page - 1 ) * $per_page;

		$this->items = array_slice( $themes, $start, $per_page, true );

		$this->set_pagination_args( array(
			'total_items' => count( $themes ),
			'per_page' => $per_page,
			'infinite_scroll' => true,
		) );
	}
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:35,代码来源:class-wp-themes-list-table.php

示例2: prepare_items

 function prepare_items()
 {
     global $status, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order', 's'));
     $themes = array('all' => apply_filters('all_themes', wp_get_themes()), 'search' => array(), 'enabled' => array(), 'disabled' => array(), 'upgrade' => array(), 'broken' => $this->is_site_themes ? array() : wp_get_themes(array('errors' => true)));
     if ($this->is_site_themes) {
         $themes_per_page = $this->get_items_per_page('site_themes_network_per_page');
         $allowed_where = 'site';
     } else {
         $themes_per_page = $this->get_items_per_page('themes_network_per_page');
         $allowed_where = 'network';
     }
     $maybe_update = current_user_can('update_themes') && !$this->is_site_themes && ($current = get_site_transient('update_themes'));
     foreach ((array) $themes['all'] as $key => $theme) {
         if ($this->is_site_themes && $theme->is_allowed('network')) {
             unset($themes['all'][$key]);
             continue;
         }
         if ($maybe_update && isset($current->response[$key])) {
             $themes['all'][$key]->update = true;
             $themes['upgrade'][$key] = $themes['all'][$key];
         }
         $filter = $theme->is_allowed($allowed_where, $this->site_id) ? 'enabled' : 'disabled';
         $themes[$filter][$key] = $themes['all'][$key];
     }
     if ($s) {
         $status = 'search';
         $themes['search'] = array_filter(array_merge($themes['all'], $themes['broken']), array(&$this, '_search_callback'));
     }
     $totals = array();
     foreach ($themes as $type => $list) {
         $totals[$type] = count($list);
     }
     if (empty($themes[$status]) && !in_array($status, array('all', 'search'))) {
         $status = 'all';
     }
     $this->items = $themes[$status];
     WP_Theme::sort_by_name($this->items);
     $this->has_items = !empty($themes['all']);
     $total_this_page = $totals[$status];
     if ($orderby) {
         $orderby = ucfirst($orderby);
         $order = strtoupper($order);
         if ($orderby == 'Name') {
             if ('ASC' == $order) {
                 $this->items = array_reverse($this->items);
             }
         } else {
             uasort($this->items, array(&$this, '_order_callback'));
         }
     }
     $start = ($page - 1) * $themes_per_page;
     if ($total_this_page > $themes_per_page) {
         $this->items = array_slice($this->items, $start, $themes_per_page, true);
     }
     $this->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $themes_per_page));
 }
开发者ID:xuandungpy,项目名称:vuong,代码行数:57,代码来源:class-wp-ms-themes-list-table.php

示例3: wp_prepare_themes_for_js

/**
 * Prepare themes for JavaScript.
 *
 * @since 3.8.0
 *
 * @param array $themes Optional. Array of WP_Theme objects to prepare.
 *                      Defaults to all allowed themes.
 *
 * @return array An associative array of theme data, sorted by name.
 */
function wp_prepare_themes_for_js($themes = null)
{
    $current_theme = get_stylesheet();
    /**
     * Filter theme data before it is prepared for JavaScript.
     *
     * Passing a non-empty array will result in wp_prepare_themes_for_js() returning
     * early with that value instead.
     *
     * @since 4.2.0
     *
     * @param array      $prepared_themes An associative array of theme data. Default empty array.
     * @param null|array $themes          An array of WP_Theme objects to prepare, if any.
     * @param string     $current_theme   The current theme slug.
     */
    $prepared_themes = (array) apply_filters('pre_prepare_themes_for_js', array(), $themes, $current_theme);
    if (!empty($prepared_themes)) {
        return $prepared_themes;
    }
    // Make sure the current theme is listed first.
    $prepared_themes[$current_theme] = array();
    if (null === $themes) {
        $themes = wp_get_themes(array('allowed' => true));
        if (!isset($themes[$current_theme])) {
            $themes[$current_theme] = wp_get_theme();
        }
    }
    $updates = array();
    if (current_user_can('update_themes')) {
        $updates_transient = get_site_transient('update_themes');
        if (isset($updates_transient->response)) {
            $updates = $updates_transient->response;
        }
    }
    WP_Theme::sort_by_name($themes);
    $parents = array();
    /** @type WP_Theme $theme */
    foreach ($themes as $theme) {
        $slug = $theme->get_stylesheet();
        $encoded_slug = urlencode($slug);
        $parent = false;
        if ($theme->parent()) {
            $parent = $theme->parent()->display('Name');
            $parents[$slug] = $theme->parent()->get_stylesheet();
        }
        $prepared_themes[$slug] = array('id' => $slug, 'name' => $theme->display('Name'), 'screenshot' => array($theme->get_screenshot()), 'description' => $theme->display('Description'), 'author' => $theme->display('Author', false, true), 'authorAndUri' => $theme->display('Author'), 'version' => $theme->display('Version'), 'tags' => $theme->display('Tags'), 'parent' => $parent, 'active' => $slug === $current_theme, 'hasUpdate' => isset($updates[$slug]), 'update' => get_theme_update_available($theme), 'actions' => array('activate' => current_user_can('switch_themes') ? wp_nonce_url(admin_url('themes.php?action=activate&stylesheet=' . $encoded_slug), 'switch-theme_' . $slug) : null, 'customize' => current_user_can('edit_theme_options') && current_user_can('customize') ? wp_customize_url($slug) : null, 'preview' => add_query_arg(array('preview' => 1, 'template' => urlencode($theme->get_template()), 'stylesheet' => urlencode($slug), 'preview_iframe' => true, 'TB_iframe' => true), home_url('/')), 'delete' => current_user_can('delete_themes') ? wp_nonce_url(admin_url('themes.php?action=delete&stylesheet=' . $encoded_slug), 'delete-theme_' . $slug) : null));
    }
    // Remove 'delete' action if theme has an active child
    if (!empty($parents) && array_key_exists($current_theme, $parents)) {
        unset($prepared_themes[$parents[$current_theme]]['actions']['delete']);
    }
    /**
     * Filter the themes prepared for JavaScript, for themes.php.
     *
     * Could be useful for changing the order, which is by name by default.
     *
     * @since 3.8.0
     *
     * @param array $prepared_themes Array of themes.
     */
    $prepared_themes = apply_filters('wp_prepare_themes_for_js', $prepared_themes);
    $prepared_themes = array_values($prepared_themes);
    return array_filter($prepared_themes);
}
开发者ID:ycms,项目名称:wp-core,代码行数:74,代码来源:theme.php

示例4: prepare_items

 public function prepare_items()
 {
     global $totals, $status;
     $order = 'DESC';
     $page = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
     $orderby = 'Name';
     $themes = array('all' => apply_filters('all_themes', wp_get_themes()), 'update_enabled' => array(), 'update_disabled' => array(), 'automatic' => array());
     $maybe_update = current_user_can('update_themes') && !$this->is_site_themes && ($current = get_site_transient('update_themes'));
     $theme_options = MPSUM_Updates_Manager::get_options('themes');
     $theme_automatic_options = MPSUM_Updates_Manager::get_options('themes_automatic');
     foreach ((array) $themes['all'] as $theme => $theme_data) {
         if (false !== ($key = array_search($theme, $theme_options))) {
             $themes['update_disabled'][$theme] = $theme_data;
         } else {
             $themes['update_enabled'][$theme] = $theme_data;
             if (in_array($theme, $theme_automatic_options)) {
                 $themes['automatic'][$theme] = $theme_data;
             }
         }
     }
     $totals = array();
     foreach ($themes as $type => $list) {
         $totals[$type] = count($list);
     }
     //Disable the automatic updates view
     $core_options = MPSUM_Updates_Manager::get_options('core');
     if (isset($core_options['automatic_theme_updates']) && 'individual' !== $core_options['automatic_theme_updates']) {
         unset($totals['automatic']);
         $themes['automatic'] = array();
     }
     if (empty($themes[$status])) {
         $status = 'all';
     }
     $this->items = $themes[$status];
     WP_Theme::sort_by_name($this->items);
     $this->has_items = !empty($themes['all']);
     $total_this_page = $totals[$status];
     if ($orderby) {
         $orderby = ucfirst($orderby);
         $order = strtoupper($order);
         if ($orderby == 'Name') {
             if ('ASC' == $order) {
                 $this->items = array_reverse($this->items);
             }
         } else {
             uasort($this->items, array($this, '_order_callback'));
         }
     }
     $total_this_page = count($themes['all']);
     $themes_per_page = 999;
     $start = ($page - 1) * $themes_per_page;
     if ($total_this_page > $themes_per_page) {
         $this->items = array_slice($this->items, $start, $themes_per_page, true);
     }
     $this->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $themes_per_page));
 }
开发者ID:taherbth,项目名称:bestbuy-bestsell,代码行数:56,代码来源:MPSUM_Themes_List_Table.php

示例5: wp_prepare_themes_for_js

/**
 * Prepare themes for JavaScript.
 *
 * @since 3.8.0
 *
 * @param array $themes Optional. Array of WP_Theme objects to prepare.
 *                      Defaults to all allowed themes.
 *
 * @return array An associative array of theme data, sorted by name.
 */
function wp_prepare_themes_for_js($themes = null)
{
    $current_theme = get_stylesheet();
    // Make sure the current theme is listed first.
    $prepared_themes = array($current_theme => array());
    if (null === $themes) {
        $themes = wp_get_themes(array('allowed' => true));
        if (!isset($themes[$current_theme])) {
            $themes[$current_theme] = wp_get_theme();
        }
    }
    $updates = array();
    if (current_user_can('update_themes')) {
        $updates_transient = get_site_transient('update_themes');
        if (isset($updates_transient->response)) {
            $updates = $updates_transient->response;
        }
    }
    WP_Theme::sort_by_name($themes);
    foreach ($themes as $theme) {
        $parent = false;
        if ($theme->parent()) {
            $parent = $theme->parent()->display('Name');
        }
        $slug = $theme->get_stylesheet();
        $encoded_slug = urlencode($slug);
        $prepared_themes[$slug] = array('id' => $slug, 'name' => $theme->display('Name'), 'screenshot' => array($theme->get_screenshot()), 'description' => $theme->display('Description'), 'author' => $theme->display('Author', false, true), 'authorAndUri' => $theme->display('Author'), 'version' => $theme->display('Version'), 'tags' => $theme->display('Tags'), 'parent' => $parent, 'active' => $slug === $current_theme, 'hasUpdate' => isset($updates[$slug]), 'update' => get_theme_update_available($theme), 'actions' => array('activate' => current_user_can('switch_themes') ? wp_nonce_url(admin_url('themes.php?action=activate&stylesheet=' . $encoded_slug), 'switch-theme_' . $slug) : null, 'customize' => current_user_can('edit_theme_options') && current_user_can('customize') ? wp_customize_url($slug) : null, 'preview' => add_query_arg(array('preview' => 1, 'template' => urlencode($theme->get_template()), 'stylesheet' => urlencode($slug), 'preview_iframe' => true, 'TB_iframe' => true), home_url('/')), 'delete' => current_user_can('delete_themes') ? wp_nonce_url(admin_url('themes.php?action=delete&stylesheet=' . $encoded_slug), 'delete-theme_' . $slug) : null));
    }
    /**
     * Filter the themes prepared for JavaScript, for themes.php.
     *
     * Could be useful for changing the order, which is by name by default.
     *
     * @since 3.8.0
     *
     * @param array $prepared_themes Array of themes.
     */
    $prepared_themes = apply_filters('wp_prepare_themes_for_js', $prepared_themes);
    return array_values($prepared_themes);
}
开发者ID:justatechnology,项目名称:Security,代码行数:50,代码来源:theme.php


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