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


PHP retrieve_widgets函数代码示例

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


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

示例1: _wp_sidebars_changed

/**
 * Handle sidebars config after theme change
 *
 * @access private
 * @since 3.3
 */
function _wp_sidebars_changed()
{
    global $sidebars_widgets;
    if (!is_array($sidebars_widgets)) {
        $sidebars_widgets = wp_get_sidebars_widgets();
    }
    retrieve_widgets(true);
}
开发者ID:CarterNelms,项目名称:www.engineeredcomfort.net,代码行数:14,代码来源:widgets.php

示例2: upgrade_330

/**
 * Execute changes made in WordPress 3.3.
 *
 * @since 3.3.0
 */
function upgrade_330()
{
    global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets;
    if ($wp_current_db_version < 19061 && is_main_site() && !defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) {
        $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')");
    }
    if ($wp_current_db_version >= 11548) {
        return;
    }
    $sidebars_widgets = get_option('sidebars_widgets', array());
    $_sidebars_widgets = array();
    if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets)) {
        $sidebars_widgets['array_version'] = 3;
    } elseif (!isset($sidebars_widgets['array_version'])) {
        $sidebars_widgets['array_version'] = 1;
    }
    switch ($sidebars_widgets['array_version']) {
        case 1:
            foreach ((array) $sidebars_widgets as $index => $sidebar) {
                if (is_array($sidebar)) {
                    foreach ((array) $sidebar as $i => $name) {
                        $id = strtolower($name);
                        if (isset($wp_registered_widgets[$id])) {
                            $_sidebars_widgets[$index][$i] = $id;
                            continue;
                        }
                        $id = sanitize_title($name);
                        if (isset($wp_registered_widgets[$id])) {
                            $_sidebars_widgets[$index][$i] = $id;
                            continue;
                        }
                        $found = false;
                        foreach ($wp_registered_widgets as $widget_id => $widget) {
                            if (strtolower($widget['name']) == strtolower($name)) {
                                $_sidebars_widgets[$index][$i] = $widget['id'];
                                $found = true;
                                break;
                            } elseif (sanitize_title($widget['name']) == sanitize_title($name)) {
                                $_sidebars_widgets[$index][$i] = $widget['id'];
                                $found = true;
                                break;
                            }
                        }
                        if ($found) {
                            continue;
                        }
                        unset($_sidebars_widgets[$index][$i]);
                    }
                }
            }
            $_sidebars_widgets['array_version'] = 2;
            $sidebars_widgets = $_sidebars_widgets;
            unset($_sidebars_widgets);
        case 2:
            $sidebars_widgets = retrieve_widgets();
            $sidebars_widgets['array_version'] = 3;
            update_option('sidebars_widgets', $sidebars_widgets);
    }
}
开发者ID:Telemedellin,项目名称:feriadelasfloresmedellin,代码行数:64,代码来源:upgrade.php

示例3: foreach

foreach ($sidebars_widgets as $sidebar_id => $widgets) {
    if ('wp_inactive_widgets' == $sidebar_id) {
        continue;
    }
    if (!isset($wp_registered_sidebars[$sidebar_id])) {
        if (!empty($widgets)) {
            // register the inactive_widgets area as sidebar
            register_sidebar(array('name' => __('Inactive Sidebar (not used)'), 'id' => $sidebar_id, 'class' => 'inactive-sidebar orphan-sidebar', 'description' => __('This sidebar is no longer available and does not show anywhere on your site. Remove each of the widgets below to fully remove this inactive sidebar.'), 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''));
        } else {
            unset($sidebars_widgets[$sidebar_id]);
        }
    }
}
// register the inactive_widgets area as sidebar
register_sidebar(array('name' => __('Inactive Widgets'), 'id' => 'wp_inactive_widgets', 'class' => 'inactive-sidebar', 'description' => __('Drag widgets here to remove them from the sidebar but keep their settings.'), 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''));
retrieve_widgets();
// We're saving a widget without js
if (isset($_POST['savewidget']) || isset($_POST['removewidget'])) {
    $widget_id = $_POST['widget-id'];
    check_admin_referer("save-delete-widget-{$widget_id}");
    $number = isset($_POST['multi_number']) ? (int) $_POST['multi_number'] : '';
    if ($number) {
        foreach ($_POST as $key => $val) {
            if (is_array($val) && preg_match('/__i__|%i%/', key($val))) {
                $_POST[$key] = array($number => array_shift($val));
                break;
            }
        }
    }
    $sidebar_id = $_POST['sidebar'];
    $position = isset($_POST[$sidebar_id . '_position']) ? (int) $_POST[$sidebar_id . '_position'] - 1 : 0;
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:31,代码来源:widgets.php

示例4: override_sidebars_widgets_for_theme_switch

 /**
  * Override sidebars_widgets for theme switch.
  *
  * When switching a theme via the Customizer, supply any previously-configured
  * sidebars_widgets from the target theme as the initial sidebars_widgets
  * setting. Also store the old theme's existing settings so that they can
  * be passed along for storing in the sidebars_widgets theme_mod when the
  * theme gets switched.
  *
  * @since 3.9.0
  * @access public
  *
  * @global array $sidebars_widgets
  * @global array $_wp_sidebars_widgets
  */
 public function override_sidebars_widgets_for_theme_switch()
 {
     global $sidebars_widgets;
     if ($this->manager->doing_ajax() || $this->manager->is_theme_active()) {
         return;
     }
     $this->old_sidebars_widgets = wp_get_sidebars_widgets();
     add_filter('customize_value_old_sidebars_widgets_data', array($this, 'filter_customize_value_old_sidebars_widgets_data'));
     // retrieve_widgets() looks at the global $sidebars_widgets
     $sidebars_widgets = $this->old_sidebars_widgets;
     $sidebars_widgets = retrieve_widgets('customize');
     add_filter('option_sidebars_widgets', array($this, 'filter_option_sidebars_widgets_for_theme_switch'), 1);
     // reset global cache var used by wp_get_sidebars_widgets()
     unset($GLOBALS['_wp_sidebars_widgets']);
 }
开发者ID:nxty2011,项目名称:WordPress,代码行数:30,代码来源:class-wp-customize-widgets.php

示例5: copy_theme_mods

 function copy_theme_mods($from, $to)
 {
     // we can copy settings from parent to child even if neither is currently active
     // so we need cases for active parent, active child or neither
     // get active theme
     $active_theme = get_stylesheet();
     $this->debug('from: ' . $from . ' to: ' . $to . ' active: ' . $active_theme, __FUNCTION__);
     // create temp array from parent settings
     $child_mods = get_option('theme_mods_' . $from);
     if ($active_theme == $from) {
         $this->debug('from is active, using active widgets', __FUNCTION__);
         // if parent theme is active, get widgets from active sidebars_widgets array
         $child_widgets = retrieve_widgets();
     } else {
         $this->debug('from not active, using theme mods widgets', __FUNCTION__);
         // otherwise get widgets from parent theme mods
         $child_widgets = empty($child_mods['sidebars_widgets']['data']) ? array('wp_inactive_widgets' => array()) : $child_mods['sidebars_widgets']['data'];
     }
     if ($active_theme == $to) {
         $this->debug('to active, setting active widgets', __FUNCTION__);
         // if child theme is active, remove widgets from temp array
         unset($child_mods['sidebars_widgets']);
         // copy widgets to active sidebars_widgets array
         wp_set_sidebars_widgets($child_widgets);
     } else {
         $this->debug('child not active, saving widgets in theme mods', __FUNCTION__);
         // otherwise copy widgets to temp array with time stamp
         $child_mods['sidebars_widgets']['data'] = $child_widgets;
         $child_mods['sidebars_widgets']['time'] = time();
     }
     $this->debug('saving child theme mods:' . LF . print_r($child_mods, TRUE), __FUNCTION__);
     // copy temp array to child mods
     update_option('theme_mods_' . $to, $child_mods);
 }
开发者ID:sourabh-mehra,项目名称:ASVYS-Charity-Foundation,代码行数:34,代码来源:class-ctc-admin.php

示例6: bizzthemes_layout

function bizzthemes_layout()
{
    global $wpdb, $wp_version, $wp_registered_widget_updates, $wp_registered_sidebars, $wp_registered_widgets, $bizz_package, $sidebars_widgets;
    // Permissions Check
    if (!current_user_can('edit_theme_options')) {
        wp_die(__('Cheatin&#8217; uh?', 'bizzthemes'));
    }
    // WordPress Administration Widgets API
    load_template(ABSPATH . 'wp-admin/includes/widgets.php');
    // These are the widgets grouped by sidebar
    /*
    $sidebars_widgets = wp_get_sidebars_widgets();
    if ( empty( $sidebars_widgets ) )
    	$sidebars_widgets = wp_get_widget_defaults();
    */
    // Show inactive widgets
    $user = get_current_user_id();
    $screenopt = get_user_meta($user, 'templates_screen_options', true);
    // Mobile
    if (wp_is_mobile()) {
        wp_enqueue_script('jquery-touch-punch');
    }
    // Do sidebar action
    do_action('sidebar_admin_setup');
    // options header
    bizzthemes_options_header($options_title = __('Template Builder', 'bizzthemes'), $toggle = false);
    if (isset($messages)) {
        foreach ($messages as $message) {
            echo $message . "\n";
        }
    }
    // register the inactive_widgets area as sidebar
    register_sidebar(array('name' => __('Inactive Widgets', 'bizzthemes'), 'id' => 'wp_inactive_widgets', 'class' => 'inactive-sidebar', 'description' => __('Drag widgets here to remove them from the sidebar but keep their settings.', 'bizzthemes'), 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', 'grid' => ''));
    if (function_exists('retrieve_widgets')) {
        retrieve_widgets();
    }
    do_action('widgets_admin_page');
    ?>

	<div class="manage-templates manage-menus<?php 
    if (!isset($_REQUEST['tab'])) {
        echo ' disabled';
    }
    ?>
">
		<div class="label-templates"><?php 
    _e('Select a template to edit:', 'bizzthemes');
    ?>
</div>
		<div class="select-templates">
			<a href="#" class="dropdown-toggle menu-select">
				<span dir="ltr"><?php 
    echo bizz_tabs_active();
    ?>
</span>
				<span class="templates-toggle"></span>
			</a>
			<div class="dropdown-menu menu-tabs">
				<?php 
    bizz_tabs_list();
    ?>

			</div>
		</div>
		<a href="#" class="bizzhelp templates-help" onclick="return template_help_toggle();">?</a>
	</div>
	<div id="widget-frame" class="clearfix">
	<div class="widget-liquid-left<?php 
    if (!isset($_REQUEST['tab'])) {
        echo ' liquid-left-disabled';
    }
    ?>
">
	<div id="widgets-left">
		<div id="available-widgets" class="widgets-holder-wrap">
			<div class="sidebar-name">
			   <div class="sidebar-name-arrow"><br /></div>
			   <h3><?php 
    _e('Available Widgets', 'bizzthemes');
    ?>
 <span id="removing-widget"><?php 
    _e('Deactivate', 'bizzthemes');
    ?>
 <span></span></span></h3>
			</div>
			<div class="widget-holder">
				<p class="description">
					<?php 
    _e('Drag widgets from here to a template on the right to activate them. Drag widgets back here to deactivate them and delete their settings.', 'bizzthemes');
    ?>

				</p>
				<div id="widget-list">
					<?php 
    wp_list_widgets();
    ?>

				</div>
				<br class='clear' />
			</div>
//.........这里部分代码省略.........
开发者ID:loevendahl,项目名称:flexbil,代码行数:101,代码来源:frame_layout.php

示例7: get_theme_mods

 function get_theme_mods($theme)
 {
     // get active theme
     $active_theme = get_stylesheet();
     // create temp array from parent settings
     $mods = get_option('theme_mods_' . $theme);
     if ($active_theme == $theme) {
         $this->debug('from is active, using active widgets', __FUNCTION__, __CLASS__);
         // if parent theme is active, get widgets from active sidebars_widgets array
         $mods['sidebars_widgets']['data'] = retrieve_widgets();
     } else {
         $this->debug('from not active, using theme mods widgets', __FUNCTION__, __CLASS__);
         // otherwise get widgets from parent theme mods
         $mods['sidebars_widgets']['data'] = empty($mods['sidebars_widgets']['data']) ? array('wp_inactive_widgets' => array()) : $mods['sidebars_widgets']['data'];
     }
     return $mods;
 }
开发者ID:pacificano,项目名称:pacificano,代码行数:17,代码来源:class-ctc-admin.php


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