• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Twenty_Fourteen_Ephemera_Widget::widget() – Output the HTML for this widget.

You appear to be a bot. Output may be restricted

Description

Output the HTML for this widget.

Usage

Twenty_Fourteen_Ephemera_Widget::widget( $args, $instance );

Parameters

$args
( array ) required – An array of standard parameters for widgets in this theme.
$instance
( array ) required – An array of settings for this widget instance.

Returns

void

Source

File name: twentyfourteen/inc/widgets.php
Lines:

1 to 100 of 185
  public function widget( $args, $instance ) {
    $format = isset( $instance['format'] ) ? $instance['format'] : '';

    if ( ! $format || ! in_array( $format, $this->formats, true ) ) {
      $format = 'aside';
    }

    switch ( $format ) {
      case 'image':
        $format_string      = __( 'Images', 'twentyfourteen' );
        $format_string_more = __( 'More images', 'twentyfourteen' );
        break;
      case 'video':
        $format_string      = __( 'Videos', 'twentyfourteen' );
        $format_string_more = __( 'More videos', 'twentyfourteen' );
        break;
      case 'audio':
        $format_string      = __( 'Audio', 'twentyfourteen' );
        $format_string_more = __( 'More audio', 'twentyfourteen' );
        break;
      case 'quote':
        $format_string      = __( 'Quotes', 'twentyfourteen' );
        $format_string_more = __( 'More quotes', 'twentyfourteen' );
        break;
      case 'link':
        $format_string      = __( 'Links', 'twentyfourteen' );
        $format_string_more = __( 'More links', 'twentyfourteen' );
        break;
      case 'gallery':
        $format_string      = __( 'Galleries', 'twentyfourteen' );
        $format_string_more = __( 'More galleries', 'twentyfourteen' );
        break;
      case 'aside':
      default:
        $format_string      = __( 'Asides', 'twentyfourteen' );
        $format_string_more = __( 'More asides', 'twentyfourteen' );
        break;
    }

    $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 2;
    $title  = ! empty( $instance['title'] ) ? $instance['title'] : $format_string;
    $title  = apply_filters( 'widget_title', $title, $instance, $this->id_base );

    $ephemera = new WP_Query(
      array(
        'order'          => 'DESC',
        'posts_per_page' => $number,
        'no_found_rows'  => true,
        'post_status'    => 'publish',
        'post__not_in'   => get_option( 'sticky_posts' ),
        'tax_query'      => array(
          array(
            'taxonomy' => 'post_format',
            'terms'    => array( "post-format-$format" ),
            'field'    => 'slug',
            'operator' => 'IN',
          ),
        ),
      )
    );

    if ( $ephemera->have_posts() ) :
      $tmp_content_width        = $GLOBALS['content_width'];
      $GLOBALS['content_width'] = 306;

      echo $args['before_widget'];
      ?>
			<h1 class="widget-title <?php echo esc_attr( $format ); ?>">
				<a class="entry-format" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>"><?php echo esc_html( $title ); ?></a>
			</h1>
			<ol>

				<?php
        while ( $ephemera->have_posts() ) :
          $ephemera->the_post();
          $tmp_more        = $GLOBALS['more'];
          $GLOBALS['more'] = 0;
          ?>
				<li>
				<article <?php post_class(); ?>>
				<div class="entry-content">
					<?php
          if ( has_post_format( 'gallery' ) ) :

            if ( post_password_required() ) :
              the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ) );
              else :
                $images = array();

                $galleries = get_post_galleries( get_the_ID(), false );
                if ( isset( $galleries[0]['ids'] ) ) {
                  $images = explode( ',', $galleries[0]['ids'] );
                }

                if ( ! $images ) :
                  $images = get_posts(
                    array(
                      'fields'      => 'ids',
                      'numberposts' => -1,
                      'order'       => 'ASC',
 
[1] [2] Next »

 View on Trac

Published: 19th December 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: Twenty_Fourteen_Ephemera_Widget::widget
Class ref: Twenty_Fourteen_Ephemera_Widget
Plugin ref: Twenty Fourteen
Version: 3.5
Sourcefile: inc/widgets.php
File ref: inc/widgets.php
Deprecated?: No
API Letters: E,F,T,W

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites