Making WordPress.org

Ticket #7251: 7251-add-simple-button.diff

File 7251-add-simple-button.diff, 1.7 KB (added by tellyworth, 17 months ago)

Add a simple button.

  • plugins/plugin-directory/class-template.php

     
    722722        }
    723723
    724724        /**
     725         * Generate a live preview (playground) link for a given plugin.
     726         *
     727         * @param int|\WP_Post|null $post    Optional. Post ID or post object. Defaults to global $post.
     728         * @param string            $landing_page The landing page for the preview. Option. Default: /wp-admin/plugins.php.
     729         * @return string The preview url.
     730         */
     731        public static function preview_link( $post = null, $landing_page = '/wp-admin/plugins.php' ) {
     732                $post = get_post( $post );
     733
     734                return sprintf( 'https://playground.wordpress.net/?plugin=%s&login=1&url=%s', esc_attr( $post->post_name ), esc_attr( $landing_page ) );
     735        }
     736
     737        /**
    725738         * Properly encodes a string to UTF-8.
    726739         *
    727740         * @static
  • themes/pub/wporg-plugins/template-parts/plugin-single.php

     
    4040
    4141                        <?php if ( 'publish' === get_post_status() || current_user_can( 'plugin_admin_view', $post ) ) : ?>
    4242                                <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>"><?php esc_html_e( 'Download', 'wporg-plugins' ); ?></a>
     43                                <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::preview_link() ); ?>"><?php esc_html_e( 'Live Preview', 'wporg-plugins' ); ?></a>
    4344                        <?php endif; ?>
    4445                </div>
    4546