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


PHP wp_get_sidebars_widgets函数代码示例

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


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

示例1: croft_widget_classes

/**
 * Additional Widgets Classes
 *
 * @param $params
 *
 * @return mixed
 */
function croft_widget_classes($params)
{
    /* Global a counter array */
    global $croft_widget_num;
    /* Get the id for the current sidebar we're processing */
    $this_id = $params[0]['id'];
    /* Get registered widgets */
    $arr_registered_widgets = wp_get_sidebars_widgets();
    /* If the counter array doesn't exist, create it */
    if (!$croft_widget_num) {
        $croft_widget_num = array();
    }
    /* if current sidebar has no widget, return. */
    if (!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) {
        return $params;
    }
    /* See if the counter array has an entry for this sidebar */
    if (isset($croft_widget_num[$this_id])) {
        $croft_widget_num[$this_id]++;
    } else {
        $croft_widget_num[$this_id] = 1;
    }
    /* Add a widget number class for additional styling options */
    $class = 'class="widget widget-' . $croft_widget_num[$this_id] . ' ';
    /* in first widget, add 'widget-first' class */
    if ($croft_widget_num[$this_id] == 1) {
        $class .= 'widget-first ';
    } elseif ($croft_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) {
        $class .= 'widget-last ';
    }
    /* str replace before_widget param with new class */
    $params[0]['before_widget'] = str_replace('class="widget ', $class, $params[0]['before_widget']);
    return $params;
}
开发者ID:brettsmason,项目名称:croft,代码行数:41,代码来源:utility.php

示例2: kadence_widget_first_last_classes

/**
 * Add additional classes onto widgets
 *
 * @link http://wordpress.org/support/topic/how-to-first-and-last-css-classes-for-sidebar-widgets
 */
function kadence_widget_first_last_classes($params)
{
    global $my_widget_num;
    $this_id = $params[0]['id'];
    $arr_registered_widgets = wp_get_sidebars_widgets();
    if (!$my_widget_num) {
        $my_widget_num = array();
    }
    if (!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) {
        return $params;
    }
    if (isset($my_widget_num[$this_id])) {
        $my_widget_num[$this_id]++;
    } else {
        $my_widget_num[$this_id] = 1;
    }
    $class = 'class="widget-' . $my_widget_num[$this_id] . ' ';
    if ($my_widget_num[$this_id] == 1) {
        $class .= 'widget-first ';
    } elseif ($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) {
        $class .= 'widget-last ';
    }
    $params[0]['before_widget'] = preg_replace('/class=\\"/', "{$class}", $params[0]['before_widget'], 1);
    return $params;
}
开发者ID:louiseolofsson,项目名称:wordpress_examensarbete,代码行数:30,代码来源:cleanup.php

示例3: mango_register_meta_boxes

/**
 * Register meta boxes
 * @return void
 */
function mango_register_meta_boxes($meta_boxes)
{
    /**
     * prefix of meta keys (optional)
     * Use underscore (_) at the beginning to make keys hidden
     * Alt.: You also can make prefix empty to disable it
     */
    // Better has an underscore as last sign
    $prefix = 'mango_';
    $mango_sidebar_nosidebar = array();
    $mango_sidebar = array();
    $mango_sidebar_nosidebar[''] = "No Sidebar";
    global $post;
    $post_id = isset($_GET['post']) && $_GET['post'] ? $_GET['post'] : '';
    $post_id = isset($_REQUEST['post']) && $_REQUEST['post'] ? $_REQUEST['post'] : '';
    //if(isset($_GET['post'])||isset($_POST['post_ID'])):
    //	$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    //endif;
    $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
    $categories = get_terms('portfolio-category', 'orderby=count&hide_empty=0');
    $mango_portfolio_categories['all'] = __('All Categories', 'mango');
    if ($categories && !is_wp_error($categories)) {
        foreach ($categories as $category) {
            $mango_portfolio_categories[$category->name] = $category->name;
        }
    }
    foreach ($mango_portfolio_categories as $key => $value) {
        if ($key == 'uncategorized') {
            continue;
        }
        $mango_portfolio_default[] = $key;
    }
    $wp_registered_sidebars = wp_get_sidebars_widgets();
    foreach ($wp_registered_sidebars as $sidebar => $sidebar_info) {
        if ($sidebar == 'wp_inactive_widgets') {
            continue;
        }
        $mango_sidebar[$sidebar] = ucwords(str_replace(array('_', '-'), ' ', $sidebar));
        $mango_sidebar_nosidebar[$sidebar] = ucwords(str_replace(array('_', '-'), ' ', $sidebar));
    }
    // Page
    require_once mango_functions . '/metaboxes/meta-page.php';
    // Portfolio
    require_once mango_functions . '/metaboxes/meta-portfolio.php';
    // Post
    require_once mango_functions . '/metaboxes/meta-post.php';
    // Client
    require_once mango_functions . '/metaboxes/meta-clients.php';
    // testimonials
    require_once mango_functions . '/metaboxes/meta-testimonial.php';
    // Faqs
    require_once mango_functions . '/metaboxes/meta-faqs.php';
    // Product
    require_once mango_functions . '/metaboxes/meta-product.php';
    //general
    require_once mango_functions . '/metaboxes/meta-general.php';
    //meta popup
    require_once mango_functions . '/metaboxes/meta-popup.php';
    return $meta_boxes;
}
开发者ID:nickkoskowski,项目名称:Work-Depot,代码行数:64,代码来源:metaboxes.php

示例4: export_settings_page

	/**
	 * HTML for export admin page
	 */
	public static function export_settings_page() {
		$sidebar_widgets = self::order_sidebar_widgets( wp_get_sidebars_widgets() );
		?>
		<div class="widget-data export-widget-settings">
			<div class="wrap">
				<h2>Widget Setting Export</h2>
				<div id="notifier" style="display: none;"></div>
				<form action="" method="post" id="widget-export-settings">
					<input type="hidden" id="action" name="action" value="export_widget_settings" />
					<?php wp_nonce_field('export_widget_settings', '_wpnonce'); ?>
					<p>
						<a class="button select-all">Select All Active Widgets</a>
						<a class="button unselect-all">Un-Select All Active Widgets</a>
					</p>
					<div class="title">
						<h3>Sidebars</h3>
						<div class="clear"></div>
					</div>
					<div class="sidebars">
						<?php
						foreach ( $sidebar_widgets as $sidebar_name => $widget_list ) :
							if ( empty( $widget_list ) )
								continue;

							$sidebar_info = self::get_sidebar_info( $sidebar_name );
							if( !empty($sidebar_info) ): ?>
								<div class="sidebar">
									<h4><?php echo $sidebar_info['name']; ?></h4>

									<div class="widgets">
										<?php
										foreach ( $widget_list as $widget ) :

											$widget_type = trim( substr( $widget, 0, strrpos( $widget, '-' ) ) );
											$widget_type_index = trim( substr( $widget, strrpos( $widget, '-' ) + 1 ) );
											$widget_options = get_option( 'widget_' . $widget_type );
											$widget_title = isset( $widget_options[$widget_type_index]['title'] ) ? $widget_options[$widget_type_index]['title'] : $widget_type_index;
											?>
											<div class="import-form-row">
												<input class="<?php echo ($sidebar_name == 'wp_inactive_widgets') ? 'inactive' : 'active'; ?> widget-checkbox" type="checkbox" name="<?php echo esc_attr( $widget ); ?>" id="<?php echo esc_attr( 'meta_' .  $widget ); ?>" />
												<label for="<?php echo esc_attr( 'meta_' . $widget ); ?>">
													<?php
														echo ucfirst( $widget_type );
														if( !empty( $widget_title ) )
															echo ' - ' . $widget_title;
													?>
												</label>
											</div>
										<?php endforeach; ?>
									</div> <!-- end widgets -->
								</div> <!-- end sidebar -->
							<?php endif;
						endforeach; ?>
					</div> <!-- end sidebars -->
					<input class="button-bottom button-primary" type="submit" value="Export Widget Settings"/>
				</form>
			</div> <!-- end wrap -->
		</div> <!-- end export-widget-settings -->
		<?php
	}
开发者ID:kautzar,项目名称:drpp4,代码行数:63,代码来源:class-widget-data.php

示例5: count_widgets

 /**
  * @param $sidebar_id string
  * @return int
  */
 public function count_widgets($sidebar_id)
 {
     if (!isset($sidebar_id)) {
         return 0;
     }
     return count(wp_get_sidebars_widgets($sidebar_id));
 }
开发者ID:r-moiseev,项目名称:jets,代码行数:11,代码来源:Sidebar_Helper.php

示例6: calibrefx_do_footer_widgets

/**
 * Display the footer widget if the footer widget are active.
 */
function calibrefx_do_footer_widgets()
{
    global $wp_registered_sidebars;
    $footer_widgets = get_theme_support('calibrefx-footer-widgets');
    $all_widgets = wp_get_sidebars_widgets();
    //Check if footer widget theme support is activated or is there any widget inside
    if (!$footer_widgets or !isset($all_widgets['footer-widget'])) {
        return;
    }
    $count_footer_widgets = count($all_widgets['footer-widget']);
    if (0 == $count_footer_widgets) {
        return;
    }
    if (current_theme_supports('calibrefx-responsive-style')) {
        $span = 'col-lg-' . strval(floor(12 / $count_footer_widgets)) . ' col-md-' . strval(floor(12 / $count_footer_widgets)) . ' col-sm-12 col-xs-12';
    } else {
        $span = 'col-xs-' . strval(floor(12 / $count_footer_widgets));
    }
    $sidebar = $wp_registered_sidebars['footer-widget'];
    $footer_widget_column = apply_filters('calibrefx_footer_widget_column_span', $span);
    $sidebar['before_widget'] = '<div id="%1$s" class="widget ' . $footer_widget_column . ' %2$s">';
    $sidebar['after_widget'] = '</div>';
    unregister_sidebar('footer-widget');
    register_sidebar($sidebar);
    if (is_active_sidebar('footer-widget')) {
        echo '<div id="footer-widget">';
        calibrefx_put_wrapper('footer-widget', 'open');
        $footer_widget_wrapper_class = apply_filters('footer_widget_wrapper_class', calibrefx_row_class());
        echo '<div class="footer-widget-wrapper"><div class="' . $footer_widget_wrapper_class . '">';
        dynamic_sidebar('footer-widget');
        echo '</div></div><!--end .footer-widget-wrapper -->';
        calibrefx_put_wrapper('footer-widget', 'close');
        echo '</div><!--end #footer-widget-->';
    }
}
开发者ID:alispx,项目名称:calibrefx,代码行数:38,代码来源:footer-hook.php

示例7: setUp

	function setUp() {
		parent::setUp();
		require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );

		add_theme_support( 'customize-selective-refresh-widgets' );
		$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
		wp_set_current_user( $user_id );
		$GLOBALS['wp_customize'] = new WP_Customize_Manager();
		$this->manager = $GLOBALS['wp_customize'];

		unset( $GLOBALS['_wp_sidebars_widgets'] ); // clear out cache set by wp_get_sidebars_widgets()
		$sidebars_widgets = wp_get_sidebars_widgets();
		$this->assertEqualSets( array( 'wp_inactive_widgets', 'sidebar-1' ), array_keys( wp_get_sidebars_widgets() ) );
		$this->assertContains( 'search-2', $sidebars_widgets['sidebar-1'] );
		$this->assertContains( 'categories-2', $sidebars_widgets['sidebar-1'] );
		$this->assertArrayHasKey( 2, get_option( 'widget_search' ) );
		$widget_categories = get_option( 'widget_categories' );
		$this->assertArrayHasKey( 2, $widget_categories );
		$this->assertEquals( '', $widget_categories[2]['title'] );

		// @todo We should not be including a theme anyway
		remove_action( 'after_setup_theme', 'twentyfifteen_setup' );
		remove_action( 'after_setup_theme', 'twentysixteen_setup' );
		remove_action( 'customize_register', 'twentysixteen_customize_register', 11 );

		$this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];

		// Reset protected static var on class.
		WP_Customize_Setting::reset_aggregated_multidimensionals();
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:30,代码来源:widgets.php

示例8: category_posts_should_enqueue

function category_posts_should_enqueue($id_base, $class)
{
    global $wp_registered_widgets;
    $ret = false;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16)) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    $widget_base = _get_widget_id_base($widget);
                    if ($widget_base == $id_base) {
                        $widgetclass = new $class();
                        $allsettings = $widgetclass->get_settings();
                        $settings = $allsettings[str_replace($widget_base . '-', '', $widget)];
                        if (!isset($settings['disable_css'])) {
                            // checks if css disable is not set
                            $ret = true;
                        }
                    }
                }
            }
        }
    }
    return $ret;
}
开发者ID:misfist,项目名称:missdrepants-network,代码行数:28,代码来源:cat-posts.php

示例9: vanilla_widget_template_markup

function vanilla_widget_template_markup($block = null)
{
    global $wp_registered_sidebars, $wp_registered_widgets;
    $tpl_source = "";
    $block = sanitize_title($block);
    foreach ((array) $wp_registered_sidebars as $key => $value) {
        if (sanitize_title($value['name']) == $block) {
            $block = $key;
            break;
        }
    }
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (empty($wp_registered_sidebars[$block]) || !array_key_exists($block, $sidebars_widgets) || !is_array($sidebars_widgets[$block]) || empty($sidebars_widgets[$block])) {
        return "";
    }
    $sidebar = $wp_registered_sidebars[$block];
    foreach ((array) $sidebars_widgets[$block] as $id) {
        $params = array_merge(array(array_merge($sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']))), (array) $wp_registered_widgets[$id]['params']);
        $params = apply_filters('dynamic_sidebar_params', $params);
        $callback = $wp_registered_widgets[$id]['callback'];
        $widget_name = str_replace("widget_", "", strtolower($callback));
        $active_template = vanilla_get_template('widgets/' . str_replace("_", "-", $widget_name) . ".html");
        if (!$active_template) {
            return "";
        }
        //echo $widget_name . " " . $widget_filename;
        if (is_callable($callback)) {
            call_user_func_array($callback, $params);
            $tpl_source .= '<span metal:use-macro="' . $active_template . '/loader" />' . "\n" . '<span tal:condition="php:VANILLA_DEBUG" class="widget-debug">WIDGET: ' . $widget_name . '</span>' . "\n" . '<span metal:define-slot="' . $widget_name . '" />' . "\n";
        }
    }
    return $tpl_source;
}
开发者ID:alicam,项目名称:vanilla-theme,代码行数:33,代码来源:widgets.php

示例10: theme_FirstLastClasses

function theme_FirstLastClasses($params)
{
    global $my_widget_num;
    $this_id = $params[0]['id'];
    $arr_registered_widgets = wp_get_sidebars_widgets();
    if (!$my_widget_num) {
        $my_widget_num = array();
    }
    if (!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) {
        return $params;
    }
    if (isset($my_widget_num[$this_id])) {
        $my_widget_num[$this_id]++;
    } else {
        $my_widget_num[$this_id] = 1;
    }
    $class = 'class="widget-' . $my_widget_num[$this_id] . ' ';
    if ($my_widget_num[$this_id] == 1) {
        $class .= 'widget-first ';
    } elseif ($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) {
        $class .= 'widget-last ';
    }
    $params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']);
    return $params;
}
开发者ID:nickthesing,项目名称:WordPress-Theme-Framework,代码行数:25,代码来源:filter.php

示例11: iterator

function iterator($id_base, $class, $callback)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16)) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    $widget_base = _get_widget_id_base($widget);
                    if ($widget_base == $id_base) {
                        $widgetclass = new $class();
                        $allsettings = $widgetclass->get_settings();
                        $settings = isset($allsettings[str_replace($widget_base . '-', '', $widget)]) ? $allsettings[str_replace($widget_base . '-', '', $widget)] : false;
                        if (!$callback($settings)) {
                            return;
                        }
                    }
                }
            }
        }
    }
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:25,代码来源:cat-posts.php

示例12: widget

 function widget($args)
 {
     global $wp_registered_widgets;
     extract($args);
     echo $before_widget;
     $widget_ids = wp_get_sidebars_widgets();
     if (!empty($widget_ids['tabs-widget-area'])) {
         echo '<div class="tabs-section">';
         $output = '<ul class="tabs-list">';
         $i = 0;
         foreach ($widget_ids['tabs-widget-area'] as $widget) {
             $widget_object = $wp_registered_widgets[$widget]['callback'][0];
             $widget_id = $wp_registered_widgets[$widget]['params'][0]['number'];
             $widget_data = get_option($widget_object->option_name);
             foreach ($widget_data as $id => $widget) {
                 if ($id == $widget_id) {
                     $i++;
                     if ($i == 1) {
                         $output .= '<li class="tabs-current">' . __($widget['title'], 'unspoken') . '</li>';
                     } else {
                         $output .= '<li>' . __($widget['title'], 'unspoken') . '</li>';
                     }
                 }
             }
         }
         echo $output .= '</ul>';
         if (!dynamic_sidebar('tabs-widget-area')) {
         }
         echo '</div>';
     }
     echo $after_widget;
 }
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:32,代码来源:tabs.php

示例13: __comicpress_widgets_init

function __comicpress_widgets_init()
{
    $available_widgets = array();
    if (($dh = opendir(dirname(__FILE__) . '/widgets')) !== false) {
        while (($file = readdir($dh)) !== false) {
            if (strpos($file, '.inc') !== false) {
                $class_name = "ComicPress" . preg_replace('#\\..*$#', '', $file);
                require_once dirname(__FILE__) . '/widgets/' . $file;
                register_widget($class_name);
                $widget = new $class_name(true);
                if (method_exists($widget, 'init')) {
                    $widget->init();
                }
                $available_widgets[strtolower($class_name)] = $widget;
            }
        }
        closedir($dh);
    }
    foreach (wp_get_sidebars_widgets() as $type => $widgets) {
        if ($type != 'wp_inactive_widgets') {
            foreach ($widgets as $widget_id) {
                foreach ($available_widgets as $key => $widget) {
                    if (method_exists($widget, 'is_active')) {
                        if (strpos(strtolower($widget_id), $key) === 0) {
                            $widget->is_active();
                        }
                    }
                }
            }
        }
    }
}
开发者ID:johnbintz,项目名称:comicpress-2.8,代码行数:32,代码来源:functions.php

示例14: update_widgets

 /**
  * Update subscribe widget instances to follow widget instances
  *
  * @since 1.1.9
  */
 public static function update_widgets()
 {
     $sidebars = wp_get_sidebars_widgets();
     if (!is_array($sidebars)) {
         return;
     }
     $found_widgets = false;
     foreach ($sidebars as $sidebar => $widgets) {
         foreach ($widgets as $position => $widget_id) {
             if (strlen($widget_id) > 18 && substr_compare($widget_id, 'facebook-subscribe', 0, 18) === 0) {
                 $sidebars[$sidebar][$position] = 'facebook-follow' . substr($widget_id, strrpos($widget_id, '-'));
                 $found_widgets = true;
             }
         }
     }
     if ($found_widgets) {
         $existing_instances = get_option('widget_facebook-subscribe');
         if (is_array($existing_instances)) {
             update_option('widget_facebook-follow', $existing_instances);
         }
         if ($existing_instances !== false) {
             delete_option('widget_facebook-subscribe');
         }
         unset($existing_instances);
         wp_set_sidebars_widgets($sidebars);
     }
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:32,代码来源:migrate-options-118.php

示例15: count_sidebar_widgets

function count_sidebar_widgets($sidebar_id, $echo = true)
{
    $the_sidebars = wp_get_sidebars_widgets();
    if (!isset($the_sidebars[$sidebar_id])) {
        return 0;
    }
    return count($the_sidebars[$sidebar_id]);
}
开发者ID:besimhu,项目名称:legacy,代码行数:8,代码来源:functions.php


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