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


PHP the_widget函数代码示例

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


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

示例1: dt_print_widget_recent_photos

function dt_print_widget_recent_photos($atts)
{
    extract(shortcode_atts(array('ppp' => 6, 'title' => '', 'column' => 'half', 'orderby' => 'date', 'order' => 'DESC', 'only' => '', 'except' => ''), $atts));
    $title = strip_tags($title);
    $ppp = absint($ppp);
    $order = DT_latest_photo_Widget::dt_sanitize_enum($order, DT_latest_photo_Widget::$order_reference);
    $orderby = DT_latest_photo_Widget::dt_sanitize_enum($orderby, array_keys(DT_latest_photo_Widget::$orderby_reference));
    $args = array('before_widget' => '<div class="' . esc_attr($column) . '">', 'after_widget' => '</div>', 'before_title' => '<h2>', 'after_title' => '</h2>');
    $select = 'all';
    $cats = array();
    if ($except) {
        $select = 'except';
        $cats = array_map('trim', explode(',', $except));
    }
    if ($only) {
        $select = 'only';
        $cats = array_map('trim', explode(',', $only));
    }
    $params = array('title' => $title, 'show' => $ppp, 'order' => $order, 'orderby' => $orderby, 'select' => $select);
    if ($cats) {
        $params['cats'] = $cats;
    }
    ob_start();
    the_widget('DT_latest_photo_Widget', $params, $args);
    $output = ob_get_clean();
    return $output;
}
开发者ID:mnjit,项目名称:aa-global,代码行数:27,代码来源:functions.php

示例2: WidgetShortcode

 /**
  * Ausgabe eines Windgets
  *
  * Gibt per Shortcode ein Widget aus. Wenn das Widget parameter auswertet,
  * koennen diese uebergeben werden. Um z.B. das Kalender Widget mit "Hello, World!" als
  * Titel per Shortcode aufzurufen ist folgender Aufruf  noetig.
  * <code>
  * [widget name="Kalender" instance="title=Hello,World!"]
  * [widget classname="Calendar" instance="title=Hello,World!"]
  * </code>
  *
  * @param array $atts
  * @return string
  */
 public static function WidgetShortcode(array $atts)
 {
     global $wp_registered_widgets;
     $back = '';
     $widget_class = '';
     extract(shortcode_atts(array('name' => '', 'instance' => '', 'classname' => ''), $atts));
     $instance = html_entity_decode($instance);
     if ($name != '') {
         // Nun den Klassennamen des Widgets ermitteln, die Funktion the_widget erwartet den
         // Klassennamen des Widgets als Parameter.
         foreach ($wp_registered_widgets as $widget) {
             if ($widget['name'] == $name) {
                 $widget_class = get_class($widget['callback'][0]);
                 continue;
             }
         }
     } elseif ($classname != '') {
         foreach ($wp_registered_widgets as $widget) {
             if (get_class($widget['callback'][0]) == $classname) {
                 $widget_class = $classname;
                 continue;
             }
         }
     }
     if ($widget_class != '') {
         $back = "<div id='" . str_replace(" ", "_", $name) . "' class='widget_shortcode'>";
         ob_start();
         the_widget($widget_class, $instance);
         $back .= ob_get_contents();
         ob_end_clean();
         $back .= "</div>";
     }
     return $back;
 }
开发者ID:sydneyDAD,项目名称:cardguys.com,代码行数:48,代码来源:class-widget-or-sidebar-per-shortcode.php

示例3: postmatic_widget

 /**
  * Get Postmatic subscribe widget.
  *
  * @since 0.0.5
  *
  * @return string
  */
 public static function postmatic_widget()
 {
     $attributes = array('title' => __('Subscribe to Comments Via Email', 'epoch'), 'collect_name' => true, 'template_path' => null);
     ob_start();
     the_widget('Prompt_Subscribe_Widget', $attributes);
     return ob_get_clean();
 }
开发者ID:rpkoller,项目名称:epoch,代码行数:14,代码来源:layout.php

示例4: siteorigin_panels_legacy_widget_migration

/**
 * Go through all the old PB widgets and change them into far better visual editor widgets
 *
 * @param array $panels_data
 *
 * @return array
 */
function siteorigin_panels_legacy_widget_migration($panels_data)
{
    if (!empty($panels_data['widgets']) && is_array($panels_data['widgets'])) {
        foreach ($panels_data['widgets'] as &$widget) {
            switch ($widget['panels_info']['class']) {
                case 'SiteOrigin_Panels_Widgets_Gallery':
                    $shortcode = '[gallery ';
                    if (!empty($widget['ids'])) {
                        $shortcode .= 'ids="' . esc_attr($widget['ids']) . '" ';
                    }
                    $shortcode = trim($shortcode) . ']';
                    $widget = array('title' => '', 'filter' => '1', 'type' => 'visual', 'text' => $shortcode, 'panels_info' => $widget['panels_info']);
                    $widget['panels_info']['class'] = 'SiteOrigin_Widget_Editor_Widget';
                    break;
                case 'SiteOrigin_Panels_Widgets_Image':
                    if (class_exists('SiteOrigin_Panels_Widgets_Image')) {
                        ob_start();
                        the_widget('SiteOrigin_Panels_Widgets_Image', $widget, array('before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''));
                        $widget = array('title' => '', 'filter' => '1', 'type' => 'visual', 'text' => ob_get_clean(), 'panels_info' => $widget['panels_info']);
                        $widget['panels_info']['class'] = 'SiteOrigin_Widget_Editor_Widget';
                    }
                    break;
            }
        }
    }
    return $panels_data;
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:34,代码来源:migration.php

示例5: displayWidget

 public static function displayWidget($instance = [], array $params = [])
 {
     if (is_string($instance)) {
         $instance = json_decode($instance, true);
     }
     if (!isset($instance['type']) || $instance['type'] !== 'widget' || !isset($instance['widget']) || !isset($instance['options'])) {
         return null;
     }
     $options = $instance['options'];
     $widgetClass = static::getWidgetClass($instance['widget']);
     if (!$widgetClass) {
         return '';
     }
     $id = static::displayWidgetId(true);
     $args = static::getWidgetChrome($widgetClass, $params['chrome']);
     ob_start();
     \the_widget($widgetClass, $options['widget'], $args);
     $html = ob_get_clean();
     if (trim($html)) {
         /** @var Theme $theme */
         $theme = static::gantry()['theme'];
         $theme->wordpress(true);
     }
     return $html;
 }
开发者ID:nmsde,项目名称:gantry5,代码行数:25,代码来源:Widgets.php

示例6: storefront_header_cart

    function storefront_header_cart()
    {
        if (is_woocommerce_activated()) {
            if (is_cart()) {
                $class = 'current-menu-item';
            } else {
                $class = '';
            }
            ?>
            <ul class="site-header-cart menu">
                <li class="<?php 
            echo esc_attr($class);
            ?>
">
                    <?php 
            storefront_cart_link();
            ?>
                </li>
                <li>
                    <?php 
            the_widget('WC_Widget_Cart', 'title=');
            ?>
                </li>
            </ul>
            <?php 
        }
    }
开发者ID:alexgomes09,项目名称:topshop,代码行数:27,代码来源:template-tags.php

示例7: storefront_header_cart

    function storefront_header_cart()
    {
        if (is_woocommerce_activated()) {
            if (is_cart()) {
                $class = 'current-menu-item';
            } else {
                $class = '';
            }
            ?>
		<ul class="site-header-cart menu">
			<li class="<?php 
            echo esc_attr($class);
            ?>
">
				<?php 
            storefront_cart_link();
            ?>
			</li>
			<li>
				<?php 
            the_widget('WC_Widget_Cart', 'title=');
            ?>
			</li>
		</ul>
		<div class="social-icons">
			<a href="http://instagram.com/homeboyadvance" class="icon-instagram" target="_blank"></a>
			<a href="http://facebook.com/homeboyadvance" class="icon-facebook" target="_blank"></a>
			<a href="http://twitter.com/homeboyadvance" class="icon-twitter" target="_blank"></a>
		</div>
		<?php 
        }
    }
开发者ID:kn0wbody,项目名称:homeboyadvance_storefront,代码行数:32,代码来源:template-tags.php

示例8: sandwich_jetpack_subscriptions_widget_shortcode

function sandwich_jetpack_subscriptions_widget_shortcode($attr, $content)
{
    if (!class_exists('Jetpack_Subscriptions_Widget')) {
        return '';
    }
    $attr = wp_parse_args($attr, array('title' => __('Display WordPress Posts', 'jetpack'), 'subscribe_text' => __('Enter your email address to subscribe to this blog and receive notifications of new posts by email.', 'jetpack'), 'subscribe_logged_in' => __('Click to subscribe to this blog and receive notifications of new posts by email.', 'jetpack'), 'subscribe_placeholder' => __('Email Address', 'jetpack'), 'subscribe_button' => __('Subscribe', 'jetpack'), 'show_subscribers_total' => false, 'hide_title' => false));
    $attr['show_subscribers_total'] = $attr['show_subscribers_total'] === 'true' || $attr['show_subscribers_total'] === true ? true : false;
    $hideTitleClass = '';
    if ($attr['hide_title']) {
        $hideTitleClass = 'hide_title';
    }
    ob_start();
    ?>
	<div class="sandwich <?php 
    echo $hideTitleClass;
    ?>
">
		<?php 
    the_widget('Jetpack_Subscriptions_Widget', $attr);
    ?>
	</div>
	
	<?php 
    return ob_get_clean();
}
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:25,代码来源:widget-jetpack-subscriptions.php

示例9: _hw_awc_feature_widget_content_shortcode

/**
 * @shortcode hw_widget_content shortcode to display any widget content
 * @param $prop
 * @param $content
 */
function _hw_awc_feature_widget_content_shortcode($prop, $content)
{
    $args = array('widget' => '', 'sidebar' => '', 'params_config' => '', 'skin' => 'skin_default');
    $d = shortcode_atts($args, $prop);
    extract($d);
    //valid
    if (empty($widget)) {
        return;
    }
    global $wp_registered_sidebars;
    global $wp_registered_widgets;
    //default sidebar params
    $sidebar_params = array('before_title' => '', 'after_title' => '', 'before_widget' => '', 'after_widget' => '');
    if (!empty($sidebar) && !empty($skin) && isset($wp_registered_sidebars[$sidebar])) {
        $sidebar_params = HW_AWC::apply_sidebar_skin($sidebar, $skin, array('widget_id' => 'hw-shortcode-widget', 'classname' => strtolower($widget) . ' hw-awc-override'));
    }
    //get widget instance by saved widget config
    if (!empty($params_config) && is_numeric($params_config)) {
        $config = AWC_WidgetFeature_saveconfig::get_widget_setting($params_config);
        if ($config) {
            $widget_params = AWC_WidgetFeature_saveconfig::decode_config($config->setting);
        }
    }
    if (isset($widget) && class_exists($widget, false) && !empty($widget_params)) {
        //display widget content
        the_widget($widget, $widget_params, $sidebar_params);
    }
}
开发者ID:hoangsoft90,项目名称:hw-hoangweb-plugin,代码行数:33,代码来源:shortcode.php

示例10: ufandshands_widget_shortcode

function ufandshands_widget_shortcode($atts)
{
    global $wp_widget_factory;
    extract(shortcode_atts(array('widget_name' => FALSE, 'title' => '', 'numberofposts' => '3', 'showexcerpt' => 1, 'showthumbnails' => 1, 'showdate' => 1, 'showrssicon' => 1, 'specific_category_id' => ''), $atts));
    $widget_name = wp_specialchars($widget_name);
    if (!is_a($wp_widget_factory->widgets[$widget_name], 'WP_Widget')) {
        $wp_class = 'WP_Widget_' . ucwords(strtolower($class));
        if (!is_a($wp_widget_factory->widgets[$wp_class], 'WP_Widget')) {
            return '<p>' . sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct"), '<strong>' . $class . '</strong>') . '</p>';
        } else {
            $class = $wp_class;
        }
    }
    $instance = '&title=' . $title;
    $instance .= '&numberofposts=' . $numberofposts;
    $instance .= '&showexcerpt=' . $showexcerpt;
    $instance .= '&showthumbnails=' . $showthumbnails;
    $instance .= '&showdate=' . $showdate;
    $instance .= '&showrssicon=' . $showrssicon;
    $instance .= '&specific_category_id=' . $specific_category_id;
    // $instance .= '&='.$;
    ob_start();
    the_widget($widget_name, $instance, array('widget_id' => 'arbitrary-instance-' . $id, 'before_widget' => '<div class="widget_body">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>'));
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
开发者ID:sezj,项目名称:ufl-template-responsive,代码行数:27,代码来源:shortcodes.php

示例11: do_widget

/**
 * Displays a widget
 *
 * @param mixed args
 * @since 0.2
 * @return string widget output
 */
function do_widget($args)
{
    global $_wp_sidebars_widgets, $wp_registered_widgets, $wp_registered_sidebars;
    extract(shortcode_atts(array('id' => '', 'title' => true, 'before_widget' => '', 'before_title' => '', 'after_title' => '', 'after_widget' => ''), $args));
    if (empty($id) || !isset($wp_registered_widgets[$id])) {
        return;
    }
    // get the widget instance options
    preg_match('/(\\d+)/', $id, $number);
    $options = get_option($wp_registered_widgets[$id]['callback'][0]->option_name);
    $instance = $options[$number[0]];
    $class = get_class($wp_registered_widgets[$id]['callback'][0]);
    // maybe the widget is removed or deregistered
    if (!$instance || !$class) {
        return;
    }
    // set this title to something arbitrary so we can remove it later on
    if ($title == false) {
        $args['before_title'] = '<div class="wsh-title">';
        $args['after_title'] = '</div>';
    }
    ob_start();
    the_widget($class, $instance, $args);
    $content = ob_get_clean();
    if ($title == false) {
        $content = preg_replace('/<div class="wsh-title">(.*?)<\\/div>/', '', $content);
    }
    if ($echo !== true) {
        return $content;
    }
    echo $content;
}
开发者ID:roycocup,项目名称:enclothed,代码行数:39,代码来源:init.php

示例12: my_shortcode_widget

/** widget
  * Objective:
  *		1.Used to add widgets in content area.
**/
function my_shortcode_widget($attrs)
{
    global $wp_widget_factory;
    extract(shortcode_atts(array('widget_name' => FALSE, 'widget_class_name' => FALSE), $attrs));
    foreach ($attrs as $key => $value) {
        switch ($key) {
            case 'exclude_replies':
            case 'time':
            case 'display_avatar':
                $instance[$key] = $value == "yes" ? $value : NULL;
                break;
            default:
                $instance[$key] = $value;
                break;
        }
    }
    $instance = array_filter($instance);
    $widget_name = esc_html($widget_name);
    if (!is_a($wp_widget_factory->widgets[$widget_name], 'WP_Widget')) {
        $wp_class = 'WP_Widget_' . ucwords(strtolower($class));
        if (!is_a($wp_widget_factory->widgets[$wp_class], 'WP_Widget')) {
            return '<p>' . sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct", 'dt_delicate'), '<strong>' . $class . '</strong>') . '</p>';
        } else {
            $class = $wp_class;
        }
    }
    ob_start();
    the_widget($widget_name, $instance, array('before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => ''));
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:36,代码来源:widgets.php

示例13: most_shared_posts_shortcode_widget_placer

function most_shared_posts_shortcode_widget_placer($atts)
{
    extract(shortcode_atts(array('title' => 'Most Shared Posts', 'num_posts' => '5', 'max_month_age' => '24'), $atts));
    $widget_instance = array('title' => $title, 'recency_limit_unit' => 'months', 'recency_limit_number' => $max_month_age, 'number_of_posts_to_list' => $num_posts);
    $args = array();
    the_widget('Most_Shared_Posts', $widget_instance, $args);
}
开发者ID:ahsaeldin,项目名称:projects,代码行数:7,代码来源:msp-front.php

示例14: sandwich_tag_cloud_widget_shortcode

function sandwich_tag_cloud_widget_shortcode($attr, $content)
{
    $default = '';
    foreach (get_taxonomies() as $taxonomy) {
        $tax = get_taxonomy($taxonomy);
        if (!$tax->show_tagcloud || empty($tax->labels->name)) {
            continue;
        }
        $default = esc_attr($taxonomy);
        break;
    }
    $attr = wp_parse_args($attr, array('title' => __('Tag Cloud', 'pbsandwich'), 'taxonomy' => $default, 'hide_title' => false));
    $hideTitleClass = '';
    if ($attr['hide_title']) {
        $hideTitleClass = 'hide_title';
    }
    ob_start();
    ?>
	<div class="sandwich <?php 
    echo $hideTitleClass;
    ?>
">
		<?php 
    the_widget('WP_Widget_Tag_Cloud', $attr);
    ?>
	</div>
	
	<?php 
    return ob_get_clean();
}
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:30,代码来源:widget-tag-cloud.php

示例15: sandwich_jetpack_gravatar_profile_widget_shortcode

function sandwich_jetpack_gravatar_profile_widget_shortcode($attr, $content)
{
    if (!class_exists('Jetpack_Gravatar_Profile_Widget')) {
        return '';
    }
    $attr = wp_parse_args($attr, array('title' => __('Gravatar Profile', 'jetpack'), 'email_user' => '-1', 'email' => 5, 'show_personal_links' => false, 'show_account_links' => false, 'hide_title' => false));
    // In the Jetpack widget, if email_user is -1, the email inputted is used. If the email_user is a user_id, then the email of that user
    // is used. We do that directly from here
    if ($attr['email_user'] != -1) {
        $attr['email'] = $attr['email_user'];
    }
    $attr['show_personal_links'] = $attr['show_personal_links'] === 'true' || $attr['show_personal_links'] === true ? true : false;
    $attr['show_account_links'] = $attr['show_account_links'] === 'true' || $attr['show_account_links'] === true ? true : false;
    $hideTitleClass = '';
    if ($attr['hide_title']) {
        $hideTitleClass = 'hide_title';
    }
    ob_start();
    ?>
	<div class="sandwich <?php 
    echo $hideTitleClass;
    ?>
">
		<?php 
    the_widget('Jetpack_Gravatar_Profile_Widget', $attr);
    ?>
	</div>
	
	<?php 
    return ob_get_clean();
}
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:31,代码来源:widget-jetpack-gravatar-profile.php


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