Skip to content

Commit

Permalink
Fix issues when Plugins API is not available
Browse files Browse the repository at this point in the history
Make sure all variables are defined.
Display an error message when the Plugins API is not available.
Bump plugin version to 1.0.0-RC.
Add custom headers to generated POT file.
Refresh POT file.
  • Loading branch information
imath committed Nov 12, 2019
1 parent 03fe5fd commit d682ce4
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 67 deletions.
2 changes: 1 addition & 1 deletion class-bp-beta-tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: BP Beta Tester
* Plugin URI: https://github.com/buddypress/bp-beta-tester
* Description: A plugin to switch between stable, beta or RC versions of BuddyPress.
* Version: 1.0.0-beta1
* Version: 1.0.0-RC
* Author: The BuddyPress Community
* Author URI: https://buddypress.org
* Text Domain: bp-beta-tester
Expand Down
90 changes: 50 additions & 40 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ function bp_beta_tester_admin_page() {
$latest = '';
$new_transient = null;
$is_latest_stable = false;
$installed = array();
$action = '';
$url = '';

// Disable the override.
remove_filter( 'pre_site_transient_update_plugins', 'bp_beta_tester_reset_update_plugins' );
Expand All @@ -238,11 +241,8 @@ function bp_beta_tester_admin_page() {
$releases = array_keys( $versions );
$latest = reset( $releases );
$is_latest_stable = false === strpos( $latest, '-' );
$installed = array();
$plugin_file = 'buddypress/bp-loader.php';
$url = '';
$revert = array();
$action = '';

if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
$installed = get_plugin_data( WP_PLUGIN_DIR . '/buddypress/bp-loader.php', false, false );
Expand Down Expand Up @@ -330,7 +330,7 @@ function bp_beta_tester_admin_page() {
</div>
</div>
<nav class="bp-beta-tester-tabs-wrapper <?php echo ! $has_downgrade_tab || ! $has_upgrade_tab ? 'one-col' : 'two-cols'; ?>" aria-label="<?php esc_html_e( 'Main actions', 'bp-beta-tester' ); ?>">
<?php if ( $has_upgrade_tab ) : ?>
<?php if ( $has_upgrade_tab && $url ) : ?>
<a href="<?php echo esc_url( $url ); ?>" class="bp-beta-tester-tab active">
<?php echo esc_html( $action ); ?>
</a>
Expand All @@ -351,53 +351,63 @@ function bp_beta_tester_admin_page() {
</div>
<hr class="wp-header-end">
<div class="bp-beta-tester-body">
<h2 class="thanks">
<?php
printf(
/* translators: %1$s is the current user display name and %2$s is a heart dashicon. */
esc_html__( 'Thank you so much %1$s %2$s', 'bp-beta-tester' ),
esc_html( wp_get_current_user()->display_name ),
'<span class="dashicons dashicons-heart"></span>'
);
?>
</h2>

<p><?php esc_html_e( 'Thanks for contributing to BuddyPress: beta testing the plugin is very important to make sure it behaves the right way for you and for the community.', 'bp-beta-tester' ); ?></p>
<p><?php esc_html_e( 'Although the BuddyPress Core Development Team is regularly testing it, it\'s very challenging to test every possible configuration of WordPress and BuddyPress.', 'bp-beta-tester' ); ?></p>
<p>
<?php
printf(
/* translators: %s is the link to the WP Core Contributor handbook page about installing WordPress locally. */
esc_html__( 'Please make sure to avoid using this plugin on a production site: beta testing is always safer when it\'s done on a %s of your site or on a testing site.', 'bp-beta-tester' ),
'<a href="' . esc_url( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' ) . '">' . esc_html__( 'local copy', 'bp-beta-tester' ) . '</a>'
);
?>
</p>

<?php if ( $is_latest_stable ) : ?>
<p>
<?php if ( is_wp_error( $api ) ) : ?>

<div id="message" class="notice notice-error">
<p><?php echo wp_kses( $api->get_error_message(), array( 'a' => array( 'href' => true ) ) ); ?></p>
</div>

<?php else : ?>

<h2 class="thanks">
<?php
printf(
/* translators: %1$s is the link to the BuddyPress account on Twitter and %2$s is the link to the BuddyPress blog. */
esc_html__( 'There is no pre-releases to test currently. Please consider following BuddyPress %1$s or checking %2$s regularly to be informed of the next pre-releases.', 'bp-beta-tester' ),
'<a href="' . esc_url( 'https://twitter.com/BuddyPress' ) . '">' . esc_html__( 'on Twitter', 'bp-beta-tester' ) . '</a>',
'<a href="' . esc_url( 'https://buddypress.org/blog/' ) . '">' . esc_html__( 'our blog', 'bp-beta-tester' ) . '</a>'
/* translators: %1$s is the current user display name and %2$s is a heart dashicon. */
esc_html__( 'Thank you so much %1$s %2$s', 'bp-beta-tester' ),
esc_html( wp_get_current_user()->display_name ),
'<span class="dashicons dashicons-heart"></span>'
);
?>
</p>
<?php elseif ( isset( $installed['is_stable'] ) && ! $installed['is_stable'] ) : ?>
<h2><?php esc_html_e( 'Have you found a bug or a possible improvement?', 'bp-beta-tester' ); ?></h2>
</h2>

<p><?php esc_html_e( 'Thanks for contributing to BuddyPress: beta testing the plugin is very important to make sure it behaves the right way for you and for the community.', 'bp-beta-tester' ); ?></p>
<p><?php esc_html_e( 'Although the BuddyPress Core Development Team is regularly testing it, it\'s very challenging to test every possible configuration of WordPress and BuddyPress.', 'bp-beta-tester' ); ?></p>
<p>
<?php
printf(
/* translators: %1$s is the link to the BuddyPress Trac and %2$s is the link to the BuddyPress Support forums. */
esc_html__( 'Please let us know about it opening a new ticket on our %1$s or posting a new topic in our %2$s.', 'bp-beta-tester' ),
'<a href="' . esc_url( 'https://buddypress.trac.wordpress.org/newticket' ) . '">' . esc_html__( 'Development Tracker', 'bp-beta-tester' ) . '</a>',
'<a href="' . esc_url( 'https://buddypress.org/support/' ) . '">' . esc_html__( 'support forums', 'bp-beta-tester' ) . '</a>'
/* translators: %s is the link to the WP Core Contributor handbook page about installing WordPress locally. */
esc_html__( 'Please make sure to avoid using this plugin on a production site: beta testing is always safer when it\'s done on a %s of your site or on a testing site.', 'bp-beta-tester' ),
'<a href="' . esc_url( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' ) . '">' . esc_html__( 'local copy', 'bp-beta-tester' ) . '</a>'
);
?>
</p>
<p><?php esc_html_e( 'One of the Core Developers/Support forum moderators will review your feedback and we\'ll do our best to fix it before the stable version is made available to the public.', 'bp-beta-tester' ); ?></p>

<?php if ( $is_latest_stable ) : ?>
<p>
<?php
printf(
/* translators: %1$s is the link to the BuddyPress account on Twitter and %2$s is the link to the BuddyPress blog. */
esc_html__( 'There is no pre-releases to test currently. Please consider following BuddyPress %1$s or checking %2$s regularly to be informed of the next pre-releases.', 'bp-beta-tester' ),
'<a href="' . esc_url( 'https://twitter.com/BuddyPress' ) . '">' . esc_html__( 'on Twitter', 'bp-beta-tester' ) . '</a>',
'<a href="' . esc_url( 'https://buddypress.org/blog/' ) . '">' . esc_html__( 'our blog', 'bp-beta-tester' ) . '</a>'
);
?>
</p>
<?php elseif ( isset( $installed['is_stable'] ) && ! $installed['is_stable'] ) : ?>
<h2><?php esc_html_e( 'Have you found a bug or a possible improvement?', 'bp-beta-tester' ); ?></h2>
<p>
<?php
printf(
/* translators: %1$s is the link to the BuddyPress Trac and %2$s is the link to the BuddyPress Support forums. */
esc_html__( 'Please let us know about it opening a new ticket on our %1$s or posting a new topic in our %2$s.', 'bp-beta-tester' ),
'<a href="' . esc_url( 'https://buddypress.trac.wordpress.org/newticket' ) . '">' . esc_html__( 'Development Tracker', 'bp-beta-tester' ) . '</a>',
'<a href="' . esc_url( 'https://buddypress.org/support/' ) . '">' . esc_html__( 'support forums', 'bp-beta-tester' ) . '</a>'
);
?>
</p>
<p><?php esc_html_e( 'One of the Core Developers/Support forum moderators will review your feedback and we\'ll do our best to fix it before the stable version is made available to the public.', 'bp-beta-tester' ); ?></p>
<?php endif; ?>
<?php endif; ?>
</div>
<?php
Expand Down
2 changes: 1 addition & 1 deletion inc/globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
function bp_beta_tester_globals() {
$bpbt = bp_beta_tester();

$bpbt->version = '1.0.0-beta1';
$bpbt->version = '1.0.0-RC';

// Paths.
$bpbt->dir = plugin_dir_path( dirname( __FILE__ ) );
Expand Down
44 changes: 22 additions & 22 deletions languages/bp-beta-tester.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the same license as the BP Beta Tester plugin.
msgid ""
msgstr ""
"Project-Id-Version: BP Beta Tester 1.0.0-beta1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/bp-beta-tester\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Project-Id-Version: BP Beta Tester 1.0.0-RC\n"
"Report-Msgid-Bugs-To: https://github.com/buddypress/bp-beta-tester/issues\n"
"Last-Translator: imath <[email protected]>\n"
"Language-Team: ENGLISH\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2019-11-04T18:13:31+00:00\n"
"POT-Creation-Date: 2019-11-12T10:14:39+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.3.0\n"
"X-Domain: bp-beta-tester\n"
Expand Down Expand Up @@ -45,8 +45,8 @@ msgid "Upgrade to %s"
msgstr ""

#: inc/functions.php:327
#: inc/functions.php:489
#: inc/functions.php:510
#: inc/functions.php:499
#: inc/functions.php:520
msgid "Beta Test BuddyPress"
msgstr ""

Expand All @@ -60,66 +60,66 @@ msgid "Downgrade to %s"
msgstr ""

#. translators: %1$s is the current user display name and %2$s is a heart dashicon.
#: inc/functions.php:358
#: inc/functions.php:367
msgid "Thank you so much %1$s %2$s"
msgstr ""

#: inc/functions.php:365
#: inc/functions.php:374
msgid "Thanks for contributing to BuddyPress: beta testing the plugin is very important to make sure it behaves the right way for you and for the community."
msgstr ""

#: inc/functions.php:366
#: inc/functions.php:375
msgid "Although the BuddyPress Core Development Team is regularly testing it, it's very challenging to test every possible configuration of WordPress and BuddyPress."
msgstr ""

#. translators: %s is the link to the WP Core Contributor handbook page about installing WordPress locally.
#: inc/functions.php:371
#: inc/functions.php:380
msgid "Please make sure to avoid using this plugin on a production site: beta testing is always safer when it's done on a %s of your site or on a testing site."
msgstr ""

#: inc/functions.php:372
#: inc/functions.php:381
msgid "local copy"
msgstr ""

#. translators: %1$s is the link to the BuddyPress account on Twitter and %2$s is the link to the BuddyPress blog.
#: inc/functions.php:382
#: inc/functions.php:391
msgid "There is no pre-releases to test currently. Please consider following BuddyPress %1$s or checking %2$s regularly to be informed of the next pre-releases."
msgstr ""

#: inc/functions.php:383
#: inc/functions.php:392
msgid "on Twitter"
msgstr ""

#: inc/functions.php:384
#: inc/functions.php:393
msgid "our blog"
msgstr ""

#: inc/functions.php:389
#: inc/functions.php:398
msgid "Have you found a bug or a possible improvement?"
msgstr ""

#. translators: %1$s is the link to the BuddyPress Trac and %2$s is the link to the BuddyPress Support forums.
#: inc/functions.php:394
#: inc/functions.php:403
msgid "Please let us know about it opening a new ticket on our %1$s or posting a new topic in our %2$s."
msgstr ""

#: inc/functions.php:395
#: inc/functions.php:404
msgid "Development Tracker"
msgstr ""

#: inc/functions.php:396
#: inc/functions.php:405
msgid "support forums"
msgstr ""

#: inc/functions.php:400
#: inc/functions.php:409
msgid "One of the Core Developers/Support forum moderators will review your feedback and we'll do our best to fix it before the stable version is made available to the public."
msgstr ""

#. translators: the %s placeholder is for the BuddyPress release tag.
#: inc/functions.php:470
#: inc/functions.php:480
msgid "The BuddyPress version %s is not available on WordPress.org."
msgstr ""

#: inc/functions.php:488
#: inc/functions.php:498
msgid "BuddyPress Beta Tester"
msgstr ""
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"wpcs": "./vendor/bin/phpcs class-bp-beta-tester.php inc/*.php --standard=WordPress",
"pot": "wp i18n make-pot . languages/bp-beta-tester.pot"
"pot": "wp i18n make-pot . languages/bp-beta-tester.pot --headers='{\"Report-Msgid-Bugs-To\": \"https://github.com/buddypress/bp-beta-tester/issues\", \"Last-Translator\": \"imath <[email protected]>\", \"Language-Team\": \"ENGLISH\"}'"
},
"keywords": [
"buddypress",
Expand All @@ -26,5 +26,5 @@
"type": "git",
"url": "https://github.com/buddypress/bp-beta-tester.git"
},
"version": "1.0.0-beta1"
"version": "1.0.0-RC"
}

0 comments on commit d682ce4

Please sign in to comment.