Making WordPress.org

Changeset 5854


Ignore:
Timestamp:
08/31/2017 09:03:22 PM (7 years ago)
Author:
coreymckrill
Message:

WordCamp Sponsors: Additional parameters for the shortcode

This adds or updates the following parameters in the [sponsors]
shortcode:

link

The default value none will not link the title and logo. The current
value website will link both to the external sponsor website. The new
value post will link both to the single sponsors post.

title

The default value visible will show the h3 with the sponsors title,
linked accordingly to the link attribute. Other values will omit the
title.

content

The default value full will print the content. The value excerpt
will print the first 55 words of the content, adding a "continue
reading" (with hidden screen reader title) at the end. Any other value,
like none, will hide the content, so only the logo and/or title will
be shown.

excerpt_length

Sets the number of words to be used in the excerpt (default is 55).

Props Kau-Boy
Fixes #1751

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r5853 r5854  
    11241124
    11251125        $attr = shortcode_atts( array(
    1126             'link' => 'none'
     1126            'link'           => 'none',
     1127            'title'          => 'visible',
     1128            'content'        => 'full',
     1129            'excerpt_length' => 55,
    11271130        ), $attr );
    11281131
     
    11551158
    11561159                <div id="wcorg-sponsor-<?php the_ID(); ?>" class="wcorg-sponsor">
    1157                     <?php if ( 'website' == $attr['link'] && $website ) : ?>
    1158                         <h3><a href="<?php echo esc_attr( esc_url( $website ) ); ?>"><?php the_title(); ?></a></h3>
    1159                     <?php else : ?>
    1160                         <h3><?php the_title(); ?></h3>
     1160                    <?php if ( 'visible' === $attr['title'] ) : ?>
     1161                        <?php if ( 'website' === $attr['link'] && $website ) : ?>
     1162                            <h3><a href="<?php echo esc_attr( esc_url( $website ) ); ?>"><?php the_title(); ?></a></h3>
     1163                        <?php elseif ( 'post' === $attr['link'] ) : ?>
     1164                            <h3><a href="<?php echo esc_attr( esc_url( get_permalink() ) ); ?>"><?php the_title(); ?></a></h3>
     1165                        <?php else : ?>
     1166                            <h3><?php the_title(); ?></h3>
     1167                        <?php endif; ?>
    11611168                    <?php endif; ?>
    11621169
     
    11661173                                <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?>
    11671174                            </a>
     1175                        <?php elseif ( 'post' == $attr['link'] ) : ?>
     1176                            <a href="<?php echo esc_attr( esc_url( get_permalink() ) ); ?>">
     1177                                <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?>
     1178                            </a>
    11681179                        <?php else : ?>
    11691180                            <?php the_post_thumbnail( 'wcb-sponsor-logo-horizontal-2x', array( 'alt' => get_the_title() ) ); ?>
    11701181                        <?php endif; ?>
    11711182
    1172                         <?php the_content(); ?>
     1183                        <?php if ( 'full' === $attr['content'] ) : ?>
     1184                            <?php the_content(); ?>
     1185                        <?php elseif ( 'excerpt' === $attr['content'] ) : ?>
     1186                            <?php echo wpautop(
     1187                                wp_trim_words(
     1188                                    get_the_content(),
     1189                                    absint( $attr['excerpt_length'] ),
     1190                                    apply_filters( 'excerpt_more', ' ' . '&hellip;' )
     1191                                )
     1192                            ); ?>
     1193                        <?php endif; ?>
    11731194                    </div>
    11741195                </div><!-- #sponsor -->
Note: See TracChangeset for help on using the changeset viewer.