Changeset 6284 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php
- Timestamp:
- 12/18/2017 05:42:35 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php
r6251 r6284 9 9 10 10 namespace WordPressdotorg\Plugin_Directory\Theme; 11 11 12 use WordPressdotorg\Plugin_Directory\Template; 12 13 use WordPressdotorg\Plugin_Directory\Tools; 13 14 14 // Returns an absolute url to the current url, no matter what that actually is. 15 function wporg_plugins_self_link() { 16 $site_path = preg_replace( '!^' . preg_quote( parse_url( home_url(), PHP_URL_PATH ), '!' ) . '!', '', $_SERVER['REQUEST_URI'] ); 17 return home_url( $site_path ); 18 } 19 20 function wporg_plugins_template_last_updated() { 21 return '<span title="' . get_the_time('Y-m-d') . '">' . sprintf( _x( '%s ago', 'wporg-plugins' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) ) . '</span>'; 22 } 23 24 function wporg_plugins_template_compatible_up_to() { 25 $tested = get_post_meta( get_the_id(), 'tested', true ) ; 26 if ( ! $tested ) { 27 $tested = _x( 'unknown', 'unknown version', 'wporg-plugins' ); 28 } 29 return esc_html( $tested ); 30 } 31 32 function wporg_plugins_template_requires() { 33 return esc_html( get_post_meta( get_the_id(), 'requires', true ) ); 34 } 35 36 function wporg_plugins_the_version() { 37 return esc_html( get_post_meta( get_the_id(), 'version', true ) ); 38 } 39 40 function wporg_plugins_download_link() { 41 return esc_url( Template::download_link( get_the_id() ) ); 42 } 43 15 /** 16 * Returns a list of authors. 17 * 18 * @return string 19 */ 44 20 function wporg_plugins_template_authors() { 45 21 $contributors = get_post_meta( get_the_id(), 'contributors', true ); … … 58 34 59 35 $author_links = array(); 60 $and_more = false;36 $and_more = false; 61 37 foreach ( $authors as $user ) { 62 38 $author_links[] = sprintf( '<a href="%s">%s</a>', 'https://profiles.wordpress.org/' . $user->user_nicename . '/', $user->display_name ); … … 68 44 69 45 if ( $and_more ) { 70 return sprintf( '<cite> By: %s, and others.</cite>', implode( ', ', $author_links ) );46 return sprintf( '<cite> By: %s, and others.</cite>', implode( ', ', $author_links ) ); 71 47 } else { 72 return sprintf( '<cite> By: %s</cite>', implode(', ', $author_links ) ); 73 } 74 } 75 48 return sprintf( '<cite> By: %s</cite>', implode( ', ', $author_links ) ); 49 } 50 } 76 51 77 52 /** … … 81 56 */ 82 57 function the_plugin_banner( $post = null ) { 83 echo Template::get_plugin_banner( $post, 'html' ); 58 echo Template::get_plugin_banner( $post, 'html' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped 84 59 } 85 60 … … 95 70 96 71 $is_favorited = Tools::favorited_plugin( get_post( $post ) ); 97 ?>98 <div class="plugin-favorite">99 <a href="<?php echo esc_url( Template::get_favorite_link() ); ?>" class="plugin-favorite-heart<?php echo $is_favorited ? ' favorited' : ''; ?>">72 ?> 73 <div class="plugin-favorite"> 74 <a href="<?php echo esc_url( Template::get_favorite_link() ); ?>" class="plugin-favorite-heart<?php echo $is_favorited ? ' favorited' : ''; ?>"> 100 75 <span class="screen-reader-text"> 101 76 <?php 102 77 if ( $is_favorited ) { 103 78 /* translators: %s: plugin name */ 104 printf( __( 'Unfavorite %s', 'wporg-plugins' ), get_the_title() );79 printf( esc_html__( 'Unfavorite %s', 'wporg-plugins' ), get_the_title() ); 105 80 } else { 106 81 /* translators: %s: plugin name */ 107 printf( __( 'Favorite %s', 'wporg-plugins' ), get_the_title() );82 printf( esc_html__( 'Favorite %s', 'wporg-plugins' ), get_the_title() ); 108 83 } 109 84 ?> 110 85 </span> 111 </a>112 <script>113 jQuery( '.plugin-favorite-heart' )114 .on( 'click touchstart animationend', function() {115 jQuery( this ).toggleClass( 'is-animating' );116 } )117 .on( 'click', function() {118 jQuery( this ).toggleClass( 'favorited' );119 } );120 </script>121 </div>122 <?php86 </a> 87 <script> 88 jQuery( '.plugin-favorite-heart' ) 89 .on( 'click touchstart animationend', function () { 90 jQuery( this ).toggleClass( 'is-animating' ); 91 } ) 92 .on( 'click', function () { 93 jQuery( this ).toggleClass( 'favorited' ); 94 } ); 95 </script> 96 </div> 97 <?php 123 98 } 124 99 … … 133 108 $url = get_post_meta( $post->ID, 'header_author_uri', true ); 134 109 $author = strip_tags( get_post_meta( $post->ID, 'header_author', true ) ) ?: get_the_author(); 135 $author = esc_html( Template::encode( $author ) );136 110 $author = $url ? '<a class="url fn n" rel="nofollow" href="' . esc_url( $url ) . '">' . $author . '</a>' : $author; 137 111 138 printf( _x( 'By %s', 'post author', 'wporg-plugins' ), '<span class="author vcard">' . $author . '</span>' ); 112 /* translators: post author. */ 113 printf( esc_html_x( 'By %s', 'post author', 'wporg-plugins' ), '<span class="author vcard">' . wp_kses_post( $author ) . '</span>' ); 139 114 } 140 115 … … 145 120 */ 146 121 function the_active_plugin_notice( $post = null ) { 147 if ( ! in_array( get_post_status( $post ), [ 'rejected', 'closed'], true ) ) {148 echo get_plugin_status_notice( $post);122 if ( ! in_array( get_post_status( $post ), [ 'rejected', 'closed' ], true ) ) { 123 echo wp_kses_post( get_plugin_status_notice( $post ) ); 149 124 }; 150 125 } … … 156 131 */ 157 132 function the_closed_plugin_notice( $post = null ) { 158 echo get_closed_plugin_notice( $post);133 echo wp_kses_post( get_closed_plugin_notice( $post ) ); 159 134 } 160 135 … … 169 144 $notice = ''; 170 145 171 if ( in_array( get_post_status( $post ), [ 'rejected', 'closed'], true ) ) {146 if ( in_array( get_post_status( $post ), [ 'rejected', 'closed' ], true ) ) { 172 147 $notice = get_plugin_status_notice( $post ); 173 148 174 if ( get_current_user_id() == $post->post_author ) {149 if ( get_current_user_id() === (int) $post->post_author ) { 175 150 $info_notice = '<div class="plugin-notice notice notice-info notice-alt"><p>%s</p></div><!-- .plugin-notice -->'; 176 151 $message = sprintf( 177 /* translators: 1: plugins@wordpress.org */152 /* translators: 1: plugins@wordpress.org */ 178 153 __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporgplugins' ), 179 154 'plugins@wordpress.org' … … 244 219 $closed_date = get_post_meta( get_the_ID(), 'plugin_closed_date', true ); 245 220 if ( ! empty( $closed_date ) ) { 221 /* translators: Closing date. */ 246 222 $message = sprintf( __( 'This plugin was closed on %s and is no longer available for download.', 'wporg-plugins' ), mysql2date( get_option( 'date_format' ), $closed_date ) ); 247 223 } else {
Note: See TracChangeset
for help on using the changeset viewer.