本文整理汇总了PHP中dynamic_sidebar函数的典型用法代码示例。如果您正苦于以下问题:PHP dynamic_sidebar函数的具体用法?PHP dynamic_sidebar怎么用?PHP dynamic_sidebar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dynamic_sidebar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sidebar_shortcode
function sidebar_shortcode($atts, $content = null)
{
global $wp_registered_sidebars, $wp_registered_widgets;
extract(shortcode_atts(array('alias' => false), $atts));
if ($alias) {
// find the sidebar ID by the alias
$sidebars = $this->get_sidebars();
foreach ($sidebars as $key => $value) {
if (isset($value['alias']) && $value['alias'] == $alias) {
$id = $key;
break;
}
}
if ($id) {
// turn on output buffering to capture output
ob_start();
// generate sidebar
dynamic_sidebar($id);
// get output content
$content = ob_get_clean();
// return the content
return $content;
}
}
}
示例2: example_widget
function example_widget($content)
{
if (is_home() && is_active_sidebar('example') && is_main_query()) {
dynamic_sidebar('example');
}
return $content;
}
示例3: genesis_footer_widget_areas
/**
* Echos the markup necessary to facilitate the footer widget areas.
*
* Checks for a numerical parameter given when adding theme support - if none is
* found, then the function returns early.
*
* The child theme must style the widget areas.
*
* @since 1.6.0
*
* @return null Returns early if number of widget areas could not be determined,
* or nothing is added to the first widget area
*/
function genesis_footer_widget_areas()
{
$footer_widgets = get_theme_support('genesis-footer-widgets');
if (!$footer_widgets || !isset($footer_widgets[0]) || !is_numeric($footer_widgets[0])) {
return;
}
$footer_widgets = (int) $footer_widgets[0];
/**
* Check to see if first widget area has widgets. If not,
* do nothing. No need to check all footer widget areas.
*/
if (!is_active_sidebar('footer-1')) {
return;
}
$output = '';
$counter = 1;
while ($counter <= $footer_widgets) {
/** Darn you, WordPress! Gotta output buffer. */
ob_start();
dynamic_sidebar('footer-' . $counter);
$widgets = ob_get_clean();
$output .= sprintf('<div class="footer-widgets-%d widget-area">%s</div>', $counter, $widgets);
$counter++;
}
echo apply_filters('genesis_footer_widget_areas', sprintf('<div id="footer-widgets" class="footer-widgets">%2$s%1$s%3$s</div>', $output, genesis_structural_wrap('footer-widgets', 'open', 0), genesis_structural_wrap('footer-widgets', 'close', 0)));
}
示例4: get_sidebar
/**
* called by the action get_sidebar. this is what places this into the theme
*/
public static function get_sidebar($index = 'default-sidebar')
{
wp_reset_query();
global $wp_query;
$post = $wp_query->get_queried_object();
if (is_post_type_archive('product')) {
$post = get_post(woocommerce_get_page_id('shop'));
}
if (isset($post->ID)) {
$selected_sidebar = get_post_meta($post->ID, '_selected_sidebar', true);
} else {
$selected_sidebar = "";
}
if ($selected_sidebar != '' && $selected_sidebar != "0") {
echo "\n\n<!-- begin generated sidebar [{$selected_sidebar}] -->\n";
//echo "<!-- selected: $selected_sidebar -->";
dynamic_sidebar('ht_' . $selected_sidebar);
echo "\n<!-- end generated sidebar -->\n\n";
} else {
//dynamic_sidebar($index);
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar($index)) {
//echo '<div id="search" class="widget widget_search">';
//get_search_form();
//echo '</div>';
}
}
}
示例5: woocommerce_us_after_content
function woocommerce_us_after_content()
{
?>
</div>
</div>
<div class="l-sidebar at_left">
<div class="l-sidebar-h i-widgets">
<?php
if (defined('SIDEBAR_POS') and SIDEBAR_POS == 'left') {
dynamic_sidebar('shop_sidebar');
}
?>
</div>
</div>
<div class="l-sidebar at_right">
<div class="l-sidebar-h i-widgets">
<?php
if (defined('SIDEBAR_POS') and SIDEBAR_POS == 'right') {
dynamic_sidebar('shop_sidebar');
}
?>
</div>
</div>
</div>
</div>
<?php
}
示例6: do_widget_area
function do_widget_area($atts)
{
global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
extract(shortcode_atts(array('widget_area' => 'widgets_for_shortcodes', 'class' => 'amr-widget-area', 'widget_area_class' => '', 'widget_classes' => ''), $atts));
if (empty($wp_registered_sidebars[$widget_area])) {
echo '<br/>Widget area "' . $widget_area . '" not found. Registered widget areas (sidebars) are: <br/>';
foreach ($wp_registered_sidebars as $area => $sidebar) {
echo $area . '<br />';
}
}
if (isset($_REQUEST['do_widget_debug']) and current_user_can('administrator')) {
var_dump($wp_registered_sidebars);
}
/**/
if ($widget_area_class == 'none') {
$class = '';
} else {
if (!empty($widget_area_class)) {
//2014 08
$class .= 'class="' . $class . ' ' . $widget_area_class . '"';
} else {
$class = 'class="' . $class . '"';
}
}
if (!empty($widget_classes) and $widget_classes == 'none') {
add_filter('dynamic_sidebar_params', 'amr_remove_widget_class');
}
ob_start();
/* catch the echo output, so we can control where it appears in the text */
dynamic_sidebar($widget_area);
$output = ob_get_clean();
remove_filter('dynamic_sidebar_params', 'amr_remove_widget_class');
$output = PHP_EOL . '<div id="' . $widget_area . '" ' . $class . '>' . $output . '</div>' . PHP_EOL;
return $output;
}
示例7: genesis_footer_widget_areas
/**
* Echo the markup necessary to facilitate the footer widget areas.
*
* Check for a numerical parameter given when adding theme support - if none is found, then the function returns early.
*
* The child theme must style the widget areas.
*
* Applies the `genesis_footer_widget_areas` filter.
*
* @since 1.6.0
*
* @uses genesis_structural_wrap() Optionally adds wrap with footer-widgets context.
*
* @return null Return early if number of widget areas could not be determined, or nothing is added to the first widget area.
*/
function genesis_footer_widget_areas()
{
$footer_widgets = get_theme_support('genesis-footer-widgets');
if (!$footer_widgets || !isset($footer_widgets[0]) || !is_numeric($footer_widgets[0])) {
return;
}
$footer_widgets = (int) $footer_widgets[0];
//* Check to see if first widget area has widgets. If not, do nothing. No need to check all footer widget areas.
if (!is_active_sidebar('footer-1')) {
return;
}
$inside = '';
$output = '';
$counter = 1;
while ($counter <= $footer_widgets) {
//* Darn you, WordPress! Gotta output buffer.
ob_start();
dynamic_sidebar('footer-' . $counter);
$widgets = ob_get_clean();
if ($widgets) {
$inside .= sprintf('<div class="footer-widgets-%d widget-area">%s</div>', $counter, $widgets);
}
$counter++;
}
if ($inside) {
$output .= genesis_markup(array('html5' => '<div %s>' . genesis_sidebar_title('Footer'), 'xhtml' => '<div id="footer-widgets" class="footer-widgets">', 'context' => 'footer-widgets', 'echo' => false));
$output .= genesis_structural_wrap('footer-widgets', 'open', 0);
$output .= $inside;
$output .= genesis_structural_wrap('footer-widgets', 'close', 0);
$output .= '</div>';
}
echo apply_filters('genesis_footer_widget_areas', $output, $footer_widgets);
}
示例8: pw_second_sidebar
function pw_second_sidebar()
{
echo pw_function_handle(__FUNCTION__);
if (!dynamic_sidebar("second-sidebar")) {
echo '<div class="warning clear fl"><p>' . __("Add widgets to the Second Sidebar ", "presswork") . '<a href="' . admin_url('widgets.php') . '">' . __("here", "presswork") . '</a>.</p></div>';
}
}
示例9: reactor_do_footer_widgets
/**
* Footer widgets
* in footer.php
*
* @since 1.0.0
*/
function reactor_do_footer_widgets()
{
?>
<div class="row">
<div class="large-2 medium-6 small-12 columns">
<div class="inner-footer quick-links">
<?php
dynamic_sidebar('footer-left');
?>
</div><!-- .inner-footer -->
</div><!-- .columns -->
<div class="large-2 medium-6 small-12 columns">
<div class="inner-footer footer-location">
<?php
dynamic_sidebar('footer-middle');
?>
</div><!-- .inner-footer -->
</div><!-- .columns -->
<div class="large-8 medium-12 columns">
<div class="inner-footer">
<?php
dynamic_sidebar('footer-facebook');
?>
</div><!-- .inner-footer -->
</div><!-- .columns -->
</div><!-- .row -->
<?php
}
示例10: wp_list_widget_controls
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param string $sidebar
*/
function wp_list_widget_controls($sidebar)
{
add_filter('dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar');
echo "\t<div id='{$sidebar}' class='widgets-sortables'>\n";
dynamic_sidebar($sidebar);
echo "\t</div>\n";
}
示例11: jumbotron_content
function jumbotron_content()
{
global $ss_settings, $ss_framework;
$hero = false;
$site_style = $ss_settings['site_style'];
$visibility = $ss_settings['jumbotron_visibility'];
$nocontainer = $ss_settings['jumbotron_nocontainer'];
if (($visibility == 1 && is_front_page() || $visibility != 1) && is_active_sidebar('jumbotron')) {
$hero = true;
}
if ($hero) {
echo $ss_framework->clearfix();
echo '<div class="before-main-wrapper">';
if ($site_style == 'boxed' && $nocontainer != 1) {
echo '<div class="' . Shoestrap_Layout::container_class() . '">';
}
echo '<div class="jumbotron">';
if ($nocontainer != 1 && $site_style == 'wide' || $site_style == 'boxed') {
echo '<div class="' . Shoestrap_Layout::container_class() . '">';
}
dynamic_sidebar('Jumbotron');
if ($nocontainer != 1 && $site_style == 'wide' || $site_style == 'boxed') {
echo '</div>';
}
echo '</div>';
if ($site_style == 'boxed' && $nocontainer != 1) {
echo '</div>';
}
echo '</div>';
}
}
示例12: evision_corporate_sidebar
/**
* Sidebar
*
* @since eVision Corporate 1.0.0
*
* @param null
* @return null
*
*/
function evision_corporate_sidebar()
{
global $evision_corporate_customizer_all_values;
if (isset($evision_corporate_customizer_all_values['evision-corporate-layout-page'])) {
$evision_corporate_layout_page = $evision_corporate_customizer_all_values['evision-corporate-layout-page'];
if ('sidebar-no' == $evision_corporate_layout_page) {
$evision_corporate_sidebar_active = 0;
} else {
$evision_corporate_sidebar_active = 1;
}
} else {
$evision_corporate_sidebar_active = 1;
}
if (!is_active_sidebar('sidebar-1') || 0 == $evision_corporate_sidebar_active) {
return;
}
?>
<div id="secondary" class="widget-area" role="complementary">
<?php
dynamic_sidebar('sidebar-1');
?>
</div><!-- #secondary -->
<?php
}
示例13: sharp_dynamic_sidebar
function sharp_dynamic_sidebar($widgetname)
{
dynamic_sidebar($widgetname);
if (get_option('sharp_widget') == 1 and current_user_can('manage_options')) {
echo '<span class="widgetmapname">' . $widgetname . '</span>';
}
}
示例14: widget
function widget($args, $instance)
{
global $it_storage_cache_layout_settings, $builder_current_sidebar;
global $wp_registered_sidebars;
if (in_array($instance['sidebar'], $builder_current_sidebar)) {
return;
}
list($module_guid, $num) = explode('-', $instance['sidebar']);
$layout = null;
foreach ((array) $it_storage_cache_layout_settings['layouts'] as $layout_id => $layout_data) {
foreach ((array) $layout_data['modules'] as $module) {
if ($module['guid'] === $module_guid) {
$layout = $layout_id;
break 2;
}
}
}
if (!is_null($layout)) {
global $builder_current_sidebar;
do_action('builder_sidebar_register_layout_sidebars', $layout);
if (!is_array($builder_current_sidebar)) {
$builder_current_sidebar = array();
}
$builder_current_sidebar[] = $instance['sidebar'];
dynamic_sidebar($instance['sidebar']);
array_pop($builder_current_sidebar);
}
}
示例15: get_dynamic_sidebar
function get_dynamic_sidebar($index = 1)
{
ob_start();
dynamic_sidebar($index);
$sidebar_contents = ob_get_clean();
return $sidebar_contents;
}