Skip to content

Commit

Permalink
Add a new section to inform about what to expect from next release
Browse files Browse the repository at this point in the history
If there are development notes on [BP Devel](https://bpdevel.wordpress.com), we are now adding a new section that includes a link to the `development-notes/$next-version` category of our blog.

This new feature deserves a new version on the WP Plugins directory.

Fixes #2
  • Loading branch information
imath committed Apr 9, 2020
1 parent a1ab4a8 commit 53cbd70
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 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
* Version: 1.1.0
* Author: The BuddyPress Community
* Author URI: https://buddypress.org
* Text Domain: bp-beta-tester
Expand Down
59 changes: 59 additions & 0 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,19 @@ function bp_beta_tester_admin_page() {
?>
</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 ( bp_beta_tester_version_has_dev_notes( $latest ) ) : ?>
<h2><?php esc_html_e( 'What to expect from next release?', 'bp-beta-tester' ); ?></h2>
<p>
<?php
printf(
/* translators: %s is the link to next release development notes. */
esc_html__( 'We wrote some development notes about it. Please, make sure to check them on %s.', 'bp-beta-tester' ),
'<a href="' . esc_url( bp_beta_tester_get_version_dev_notes_url( $latest ) ) . '">' . esc_html__( 'our Development Blog', 'bp-beta-tester' ) . '</a>'
);
?>
</p>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</div>
Expand Down Expand Up @@ -488,6 +501,52 @@ function bp_beta_tester_plugins_api( $res = null, $action = '', $args = array()
}
add_filter( 'plugins_api_result', 'bp_beta_tester_plugins_api', 10, 3 );

/**
* Gets a version development notes URL.
*
* @since 1.1.0
*
* @param string $version The version to get development notes for.
* @return string The version development notes URL.
*/
function bp_beta_tester_get_version_dev_notes_url( $version = '' ) {
$version = (float) $version;

if ( ! $version ) {
return false;
}

// Categories are using an hyphen instead of a dot on BP Devel.
$version = number_format( $version, 1, '-', '' );

return sprintf( 'https://bpdevel.wordpress.com/category/development-notes/%s/', esc_attr( $version ) );
}

/**
* Checks if some development notes are available on BP Devel.
*
* @since 1.1.0
*
* @param string $version The version to check develompent notes for.
* @return boolean True if there are some develompent notes. False otherwise.
*/
function bp_beta_tester_version_has_dev_notes( $version = '' ) {
global $wp_version;

if ( ! $version ) {
return false;
}

$response = wp_remote_get(
bp_beta_tester_get_version_dev_notes_url( $version ),
array(
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
)
);

return 200 === wp_remote_retrieve_response_code( $response );
}

/**
* Add a Dashboard submenu.
*
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';
$bpbt->version = '1.1.0';

// Paths.
$bpbt->dir = plugin_dir_path( dirname( __FILE__ ) );
Expand Down
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"type": "git",
"url": "https://github.com/buddypress/bp-beta-tester.git"
},
"version": "1.0.0"
"version": "1.1.0"
}

0 comments on commit 53cbd70

Please sign in to comment.