• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_list_widget_controls_dynamic_sidebar函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: wp_list_widgets

/**
 * Display list of the available widgets, either all or matching search.
 *
 * The search parameter are search terms separated by spaces.
 *
 * @since unknown
 *
 * @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'.
 * @param string $_search Optional. Search for widgets. Should be unsanitized.
 */
function wp_list_widgets()
{
    global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
    $sort = $wp_registered_widgets;
    usort($sort, create_function('$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );'));
    $done = array();
    foreach ($sort as $widget) {
        if (in_array($widget['callback'], $done, true)) {
            // We already showed this multi-widget
            continue;
        }
        $sidebar = is_active_widget($widget['callback'], $widget['id'], false, false);
        $done[] = $widget['callback'];
        if (!isset($widget['params'][0])) {
            $widget['params'][0] = array();
        }
        $args = array('widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template');
        if (isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number'])) {
            $id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
            $args['_temp_id'] = "{$id_base}-__i__";
            $args['_multi_num'] = next_widget_id_number($id_base);
            $args['_add'] = 'multi';
        } else {
            $args['_add'] = 'single';
            if ($sidebar) {
                $args['_hide'] = '1';
            }
        }
        $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
        call_user_func_array('wp_widget_control', $args);
    }
}
开发者ID:alicam,项目名称:wordpress,代码行数:42,代码来源:widgets.php


示例2: render_content

 public function render_content()
 {
     global $wp_registered_widgets;
     require_once ABSPATH . '/wp-admin/includes/widgets.php';
     $widget = $wp_registered_widgets[$this->widget_id];
     if (!isset($widget['params'][0])) {
         $widget['params'][0] = array();
     }
     $args = array('widget_id' => $widget['id'], 'widget_name' => $widget['name']);
     $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
     $control = Widget_Customizer::get_widget_control($args);
     echo $control;
     // xss ok
 }
开发者ID:niceit,项目名称:rockets,代码行数:14,代码来源:class-widget-form-wp-customize-control.php


示例3: to_json

 /**
  * Gather control params for exporting to JavaScript.
  *
  * @global array $wp_registered_widgets
  */
 public function to_json()
 {
     global $wp_registered_widgets;
     parent::to_json();
     $exported_properties = array('widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide');
     foreach ($exported_properties as $key) {
         $this->json[$key] = $this->{$key};
     }
     // Get the widget_control and widget_content.
     require_once ABSPATH . '/wp-admin/includes/widgets.php';
     $widget = $wp_registered_widgets[$this->widget_id];
     if (!isset($widget['params'][0])) {
         $widget['params'][0] = array();
     }
     $args = array('widget_id' => $widget['id'], 'widget_name' => $widget['name']);
     $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
     $widget_control_parts = $this->manager->widgets->get_widget_control_parts($args);
     $this->json['widget_control'] = $widget_control_parts['control'];
     $this->json['widget_content'] = $widget_control_parts['content'];
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:25,代码来源:class-wp-widget-form-customize-control.php


示例4: wp_list_widgets

/**
 * Display list of widgets, either all or matching search.
 *
 * The search parameter are search terms separated by spaces.
 *
 * @since unknown
 *
 * @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'.
 * @param string $_search Optional. Search for widgets. Should be unsanitized.
 */
function wp_list_widgets($show = 'all', $_search = false)
{
    global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
    if ($_search) {
        // sanitize
        $search = preg_replace('/[^\\w\\s]/', '', $_search);
        // array of terms
        $search_terms = preg_split('/[\\s]/', $search, -1, PREG_SPLIT_NO_EMPTY);
    } else {
        $search_terms = array();
    }
    if (!in_array($show, array('all', 'unused', 'used'))) {
        $show = 'all';
    }
    ?>

	<ul id='widget-list'>
		<?php 
    $no_widgets_shown = true;
    $already_shown = array();
    foreach ($wp_registered_widgets as $name => $widget) {
        if ('all' == $show && in_array($widget['callback'], $already_shown)) {
            // We already showed this multi-widget
            continue;
        }
        if ($search_terms) {
            $hit = false;
            // Simple case-insensitive search.  Boolean OR.
            $search_text = preg_replace('/[^\\w]/', '', $widget['name']);
            if (isset($widget['description'])) {
                $search_text .= preg_replace('/[^\\w]/', '', $widget['description']);
            }
            foreach ($search_terms as $search_term) {
                if (stristr($search_text, $search_term)) {
                    $hit = true;
                    break;
                }
            }
            if (!$hit) {
                continue;
            }
        }
        $sidebar = is_active_widget($widget['callback'], $widget['id']);
        if ('unused' == $show && $sidebar || 'used' == $show && !$sidebar) {
            continue;
        }
        if (!isset($widget['params'][0])) {
            $widget['params'][0] = array();
        }
        ob_start();
        $args = wp_list_widget_controls_dynamic_sidebar(array(0 => array('widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show), 1 => $widget['params'][0]));
        $sidebar_args = call_user_func_array('wp_widget_control', $args);
        $widget_control_template = ob_get_contents();
        ob_end_clean();
        $widget_id = $widget['id'];
        // save this for later in case we mess with $widget['id']
        $is_multi = false !== strpos($widget_control_template, '%i%');
        if (!$sidebar || $is_multi) {
            $add_query = array('sidebar' => $sidebar, 'key' => false, 'edit' => false);
            if ('all' == $show && $is_multi) {
                // it's a multi-widget.  We only need to show it in the list once.
                $already_shown[] = $widget['callback'];
                $num = (int) array_pop($ids = explode('-', $widget['id']));
                $id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
                // so that we always add a new one when clicking "add"
                while (isset($wp_registered_widgets["{$id_base}-{$num}"])) {
                    $num++;
                }
                $widget['id'] = "{$id_base}-{$num}";
                $add_query['base'] = $id_base;
                $add_query['key'] = $num;
                $add_query['sidebar'] = $GLOBALS['sidebar'];
            }
            $add_query['add'] = $widget['id'];
            $action = 'add';
            $add_url = clean_url(wp_nonce_url(add_query_arg($add_query), "add-widget_{$widget['id']}"));
        } else {
            $action = 'edit';
            $edit_url = clean_url(add_query_arg(array('sidebar' => $sidebar, 'edit' => $widget['id'], 'key' => array_search($widget['id'], $sidebars_widgets[$sidebar]))));
            $widget_control_template = '<textarea rows="1" cols="1">' . htmlspecialchars($widget_control_template) . '</textarea>';
        }
        $widget_control_template = $sidebar_args['before_widget'] . $widget_control_template . $sidebar_args['after_widget'];
        $no_widgets_shown = false;
        if ('all' != $show && $sidebar_args['_widget_title']) {
            $widget_title = $sidebar_args['_widget_title'];
        } else {
            $widget_title = $widget['name'];
        }
        ?>

//.........这里部分代码省略.........
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:101,代码来源:widgets.php


示例5: get_available_widgets

 /**
  * Build up an index of all available widgets for use in Backbone models.
  *
  * @since 3.9.0
  * @access public
  *
  * @global array $wp_registered_widgets
  * @global array $wp_registered_widget_controls
  * @staticvar array $available_widgets
  *
  * @see wp_list_widgets()
  *
  * @return array List of available widgets.
  */
 public function get_available_widgets()
 {
     static $available_widgets = array();
     if (!empty($available_widgets)) {
         return $available_widgets;
     }
     global $wp_registered_widgets, $wp_registered_widget_controls;
     require_once ABSPATH . '/wp-admin/includes/widgets.php';
     // for next_widget_id_number()
     $sort = $wp_registered_widgets;
     usort($sort, array($this, '_sort_name_callback'));
     $done = array();
     foreach ($sort as $widget) {
         if (in_array($widget['callback'], $done, true)) {
             // We already showed this multi-widget
             continue;
         }
         $sidebar = is_active_widget($widget['callback'], $widget['id'], false, false);
         $done[] = $widget['callback'];
         if (!isset($widget['params'][0])) {
             $widget['params'][0] = array();
         }
         $available_widget = $widget;
         unset($available_widget['callback']);
         // not serializable to JSON
         $args = array('widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template');
         $is_disabled = false;
         $is_multi_widget = isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']);
         if ($is_multi_widget) {
             $id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
             $args['_temp_id'] = "{$id_base}-__i__";
             $args['_multi_num'] = next_widget_id_number($id_base);
             $args['_add'] = 'multi';
         } else {
             $args['_add'] = 'single';
             if ($sidebar && 'wp_inactive_widgets' !== $sidebar) {
                 $is_disabled = true;
             }
             $id_base = $widget['id'];
         }
         $list_widget_controls_args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
         $control_tpl = $this->get_widget_control($list_widget_controls_args);
         // The properties here are mapped to the Backbone Widget model.
         $available_widget = array_merge($available_widget, array('temp_id' => isset($args['_temp_id']) ? $args['_temp_id'] : null, 'is_multi' => $is_multi_widget, 'control_tpl' => $control_tpl, 'multi_number' => $args['_add'] === 'multi' ? $args['_multi_num'] : false, 'is_disabled' => $is_disabled, 'id_base' => $id_base, 'transport' => 'refresh', 'width' => $wp_registered_widget_controls[$widget['id']]['width'], 'height' => $wp_registered_widget_controls[$widget['id']]['height'], 'is_wide' => $this->is_wide_widget($widget['id'])));
         $available_widgets[] = $available_widget;
     }
     return $available_widgets;
 }
开发者ID:nxty2011,项目名称:WordPress,代码行数:62,代码来源:class-wp-customize-widgets.php


示例6: get_test_widget_control_args

 /**
  * Get the widget control args for tests.
  *
  * @return array
  */
 function get_test_widget_control_args()
 {
     global $wp_registered_widgets;
     require_once ABSPATH . '/wp-admin/includes/widgets.php';
     $widget_id = 'search-2';
     $widget = $wp_registered_widgets[$widget_id];
     $args = array('widget_id' => $widget['id'], 'widget_name' => $widget['name']);
     $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
     return $args;
 }
开发者ID:joemcgill,项目名称:develop.wordpress,代码行数:15,代码来源:widgets.php


示例7: test_wp_widget_control

 /**
  * @see wp_widget_control()
  */
 function test_wp_widget_control()
 {
     global $wp_registered_widgets;
     wp_widgets_init();
     require_once ABSPATH . '/wp-admin/includes/widgets.php';
     $widget_id = 'search-2';
     $widget = $wp_registered_widgets[$widget_id];
     $params = array('widget_id' => $widget['id'], 'widget_name' => $widget['name']);
     $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $params, 1 => $widget['params'][0]));
     ob_start();
     call_user_func_array('wp_widget_control', $args);
     $control = ob_get_clean();
     $this->assertNotEmpty($control);
     $this->assertContains('<div class="widget-top">', $control);
     $this->assertContains('<div class="widget-title-action">', $control);
     $this->assertContains('<div class="widget-title">', $control);
     $this->assertContains('<form method="post">', $control);
     $this->assertContains('<div class="widget-content">', $control);
     $this->assertContains('<input class="widefat"', $control);
     $this->assertContains('<input type="hidden" name="id_base" class="id_base" value="search"', $control);
     $this->assertContains('<div class="widget-control-actions">', $control);
     $this->assertContains('<div class="alignleft">', $control);
     $this->assertContains('widget-control-remove', $control);
     $this->assertContains('widget-control-close', $control);
     $this->assertContains('<div class="alignright">', $control);
     $this->assertContains('<input type="submit" name="savewidget"', $control);
     $param_overrides = array('before_form' => '<!-- before_form -->', 'after_form' => '<!-- after_form -->', 'before_widget_content' => '<!-- before_widget_content -->', 'after_widget_content' => '<!-- after_widget_content -->');
     $params = array_merge($params, $param_overrides);
     $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $params, 1 => $widget['params'][0]));
     ob_start();
     call_user_func_array('wp_widget_control', $args);
     $control = ob_get_clean();
     $this->assertNotEmpty($control);
     $this->assertNotContains('<form method="post">', $control);
     $this->assertNotContains('<div class="widget-content">', $control);
     foreach ($param_overrides as $contained) {
         $this->assertContains($contained, $control);
     }
 }
开发者ID:rclilly,项目名称:wordpress-develop,代码行数:42,代码来源:widgets.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_list_widgets函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_list_widget_controls函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap