user-registration' ) !== false;
return $is_trigger_for_user_registration ? false : $trigger;
}
/**
* Update notice
*
* @param array $args Plugin args.
*/
public static function in_plugin_update_message( $args ) {
$transient_name = 'ur_upgrade_notice_' . $args['Version'];
$upgrade_notice = get_transient( $transient_name );
if ( false === $upgrade_notice ) {
$response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/user-registration/trunk/readme.txt' );
if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
$upgrade_notice = self::parse_update_notice( $response['body'], $args['new_version'] );
set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
}
}
echo wp_kses_post( $upgrade_notice );
}
/**
* Parse update notice from readme.
*
* @param string $content Readme content.
* @param string $new_version New version.
*/
private static function parse_update_notice( $content, $new_version ) {
// Output Upgrade Notice.
$matches = null;
$regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( UR_VERSION ) . '\s*=|$)~Uis';
$upgrade_notice = '';
if ( preg_match( $regexp, $content, $matches ) ) {
$version = trim( $matches[1] );
$notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
// Check the latest stable version and ignore trunk.
if ( $version === $new_version && version_compare( UR_VERSION, $version, '<' ) ) {
$upgrade_notice .= '';
$upgrade_notice .= '';
foreach ( $notices as $line ) {
$line = trim( $line ); // Remove extra whitespace
if ( empty( $line ) ) {
continue; // Skip empty lines
}
$line = preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '$1', $line );
$line = preg_replace( '~^###\s*(.*)~', '$1
', $line );
if ( ! preg_match( '~^|
';
if ( isset( $_GET['activate'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
unset( $_GET['activate'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
unset( $user_registration_free_activated, $user_registration_free_deactivated );
}
}
add_action( 'admin_notices', 'user_registration_free_notice' );
// Do not process the plugin code further.
return;
}
// Global for backwards compatibility.
$GLOBALS['user-registration'] = UR();