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


PHP Templates::printt方法代码示例

本文整理汇总了PHP中Templates::printt方法的典型用法代码示例。如果您正苦于以下问题:PHP Templates::printt方法的具体用法?PHP Templates::printt怎么用?PHP Templates::printt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Templates的用法示例。


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

示例1: widget

 function widget($args, $instance)
 {
     /**
      * @var $title string
      * @var $menu_id int
      * @var $display_type string
      * @var $hide_offline boolean
      * @var $hide_offline_images boolean
      * @var $sorting_strategy string
      */
     extract(self::$defaults);
     extract(wp_parse_args($instance, self::$defaults), EXTR_IF_EXISTS);
     // Get menu items for configured menu
     $menu_items = !empty($menu_id) ? wp_get_nav_menu_items($menu_id) : false;
     // No menu selected
     if (!$menu_items) {
         return;
     }
     echo $args['before_widget'];
     $title = apply_filters('widget_title', $title);
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $core = new LSB_API_Core();
     // Get only those with links
     $links = array();
     foreach ($menu_items as $m) {
         if (empty($m->url) || empty($m->title)) {
             continue;
         }
         $stream_summaries = $core->validate_urls(array($m->url));
         /** @var $stream_summary LSB_Stream_Summary */
         $stream_summary = isset($stream_summaries[0]) ? $stream_summaries[0] : NULL;
         if (empty($stream_summary)) {
             continue;
         }
         $links[$stream_summary->get_id()] = $m;
     }
     $store = new LSB_Stream_Storage(new LSB_API_Sync());
     $streams = $store->get_streams();
     $stream_sorter = new LSB_Stream_Sorter($links);
     if ($sorting_strategy == 'by_status') {
         usort($streams, array($stream_sorter, 'sort_by_status'));
     } else {
         if ($sorting_strategy == 'by_watching_now') {
             usort($streams, array($stream_sorter, 'sort_by_watching_now'));
         } else {
             usort($streams, array($stream_sorter, 'sort_by_menu_order'));
         }
     }
     // Display format templates
     $templates = new Templates();
     $lsb_status_widget_format = $templates->status_widget();
     $lsb_status_widget_item_format = $templates->status_widget_item();
     $lsb_status_widget_item_with_image_format = $templates->status_widget_item_with_image();
     $lsb_status_widget_no_content_format = $templates->status_widget_no_content();
     $container = '';
     $items = '';
     foreach ($streams as $stream) {
         /** @var $stream LSB_Stream */
         $stream_id = $stream->summary->get_id();
         $menu_item = isset($links[$stream_id]) ? $links[$stream_id] : NULL;
         if (empty($menu_item)) {
             continue;
         }
         $is_on = $stream->watching_now != -1;
         if (!$is_on && $hide_offline) {
             continue;
         }
         $var_image_src = '';
         if ($is_on || !$hide_offline_images) {
             if ($display_type == 'screen_cap' && !empty($stream->screen_cap_url)) {
                 $var_image_src = $stream->screen_cap_url;
             } else {
                 if ($display_type == 'image' && !empty($stream->image_url)) {
                     $var_image_src = $stream->image_url;
                 }
             }
         }
         $show_image = !empty($var_image_src);
         $var_status_class = $is_on ? 'lsb-on' : 'lsb-off';
         $var_url = $menu_item->url;
         $var_title = apply_filters('lsb_stream_status_widget_text', $menu_item->title);
         $var_status_indicator = $is_on ? $stream->watching_now : 'Offline';
         $item = '';
         if ($show_image == true) {
             $item = $templates->printt($lsb_status_widget_item_with_image_format, array('%%status_class%%' => $var_status_class, '%%url%%' => $var_url, '%%title%%' => $var_title, '%%status_indicator%%' => $var_status_indicator, '%%image_src%%' => $var_image_src));
         } else {
             $item = $templates->printt($lsb_status_widget_item_format, array('%%status_class%%' => $var_status_class, '%%url%%' => $var_url, '%%title%%' => $var_title, '%%status_indicator%%' => $var_status_indicator));
         }
         $items .= $item;
     }
     if (!empty($items)) {
         $container = $templates->printt($lsb_status_widget_format, array('%%items%%' => $items));
     } else {
         $container = $templates->printt($lsb_status_widget_no_content_format, array('%%message%%' => __('No streams available')));
     }
     echo $container;
     echo $args['after_widget'];
 }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:100,代码来源:stream-status-widget.php


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