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

PHP wp_get_widget_defaults函数代码示例

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

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



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

示例1: k2_default_widgets

/**
 * Assigns a default set of widgets
 */
function k2_default_widgets()
{
    $sidebars_widgets = wp_get_widget_defaults();
    if (isset($sidebars_widgets['sidebar-1']) and isset($sidebars_widgets['sidebar-2'])) {
        $sidebars_widgets['sidebar-1'] = $sidebars_widgets['sidebar-2'] = array();
        k2_add_widget($sidebars_widgets['sidebar-1'], 'search');
        k2_add_widget($sidebars_widgets['sidebar-1'], 'k2-about');
        k2_add_widget($sidebars_widgets['sidebar-1'], 'recent-posts');
        k2_add_widget($sidebars_widgets['sidebar-1'], 'recent-comments');
        k2_add_widget($sidebars_widgets['sidebar-2'], 'archives');
        k2_add_widget($sidebars_widgets['sidebar-2'], 'tag_cloud');
        k2_add_widget($sidebars_widgets['sidebar-2'], 'links');
        wp_set_sidebars_widgets($sidebars_widgets);
    }
}
开发者ID:JeffLuckett,项目名称:quickref,代码行数:18,代码来源:widgets.php


示例2: __

$title = __('Widgets');
$parent_file = 'themes.php';
get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => '<p>' . __('Widgets are independent sections of content that can be placed into any widgetized area provided by your theme (commonly called sidebars). To populate your sidebars/widget areas with individual widgets, drag and drop the title bars into the desired area. By default, only the first widget area is expanded. To populate additional widget areas, click on their title bars to expand them.') . '</p>
	<p>' . __('The Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '</p>'));
get_current_screen()->add_help_tab(array('id' => 'removing-reusing', 'title' => __('Removing and Reusing'), 'content' => '<p>' . __('If you want to remove the widget but save its setting for possible future use, just drag it into the Inactive Widgets area. You can add them back anytime from there. This is especially helpful when you switch to a theme with fewer or different widget areas.') . '</p>
	<p>' . __('Widgets may be used multiple times. You can give each widget a title, to display on your site, but it&#8217;s not required.') . '</p>
	<p>' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.') . '</p>'));
get_current_screen()->add_help_tab(array('id' => 'missing-widgets', 'title' => __('Missing Widgets'), 'content' => '<p>' . __('Many themes show some sidebar widgets by default until you edit your sidebars, but they are not automatically displayed in your sidebar management tool. After you make your first widget change, you can re-add the default widgets by adding them from the Available Widgets area.') . '</p>' . '<p>' . __('When changing themes, there is often some variation in the number and setup of widget areas/sidebars and sometimes these conflicts make the transition a bit less smooth. If you changed themes and seem to be missing widgets, scroll down on this screen to the Inactive Widgets area, where all of your widgets and their settings will have been saved.') . '</p>'));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Widgets_Screen" target="_blank">Documentation on Widgets</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
if (!current_theme_supports('widgets')) {
    wp_die(__('The theme you are currently using isn&#8217;t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.'));
}
// These are the widgets grouped by sidebar
$sidebars_widgets = wp_get_sidebars_widgets();
if (empty($sidebars_widgets)) {
    $sidebars_widgets = wp_get_widget_defaults();
}
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
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:31,代码来源:widgets.php


示例3: display_layout_detail

        function display_layout_detail($layout_id, $post_ID)
        {
            $i = 1;
            $update = array('layout_id' => $layout_id, 'post_ID' => $post_ID, 'zones' => array());
            require_once ABSPATH . 'wp-admin/includes/widgets.php';
            global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
            $this->register_zones_as_sidebars();
            $sidebars_widgets = wp_get_sidebars_widgets();
            if (empty($sidebars_widgets)) {
                $sidebars_widgets = wp_get_widget_defaults();
            }
            ?>
				
				<h4><?php 
            _e("Select a zone and drag a widget", BAOL_PL_TEXTDOMAIN);
            ?>
</h4>
				<div id="widget-list" class="float-break clear">
				<?php 
            wp_list_widgets();
            ?>
				</div>
						
				<div class="details clear">
				<ul><?php 
            foreach ($this->registered_layouts[$layout_id]['zones'] as $i => $zone) {
                register_sidebar(array('name' => $zone, 'id' => 'zone-' . $i . '-page-' . $post_ID, 'before_widget' => '<div id="%1$s" class="widget zone %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'));
                $update['zones'][] = 'zone-' . $i . '-page-' . $post_ID;
                ?>
				
					<li><a href="#zone-<?php 
                echo $i;
                ?>
-panel"><span><?php 
                echo $zone;
                ?>
</span></a></li><?php 
            }
            $this->current_layout = $this->set_current_layout($post_ID, $update);
            ?>
				
				</ul><?php 
            foreach ($this->registered_layouts[$layout_id]['zones'] as $i => $zone) {
                ?>
			
					<div id="zone-<?php 
                echo $i;
                ?>
-panel">
						<div class="widgets-zone-sortables zone-name">
						<?php 
                wp_list_widget_controls('zone-' . $i . '-page-' . $post_ID);
                ?>
						</div>
					</div><?php 
            }
            ?>
				
				</div>
				
				<div style="display:none !important">
				
				<?php 
            foreach ($wp_registered_sidebars as $sidebar => $registered_sidebar) {
                if (in_array($sidebar, $update['zones'])) {
                    continue;
                }
                wp_list_widget_controls($sidebar);
            }
            ?>
				
				</div><?php 
        }
开发者ID:azeemgolive,项目名称:thefunkidsgame,代码行数:73,代码来源:page-layout.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_guess_url函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_video_extensions函数代码示例发布时间: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