Skip to content

Commit

Permalink
Enable friendships on upgrade if applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Mar 11, 2024
1 parent 5e05cde commit b371455
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ public function admin_menu() {
add_submenu_page( 'friends', __( 'Add New Friend', 'friends' ), __( 'Add New Friend', 'friends' ), $required_role, 'add-friend', array( $this, 'render_admin_add_friend' ) );
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain
add_submenu_page( 'friends', __( 'Settings' ), __( 'Settings' ), $required_role, 'friends-settings', array( $this, 'render_admin_settings' ) );
if ( isset( $_GET['page'] ) && in_array( $_GET['page'], apply_filters( 'friends_admin_settings_slugs', array( 'friends-settings', 'friends-notification-manager', 'friends-wp-friendships', 'friends-import-export' ) ) ) ) {
if (
isset( $_GET['page'] ) &&
in_array(
$_GET['page'],
apply_filters( 'friends_admin_settings_slugs', array( 'friends-settings', 'friends-notification-manager', 'friends-wp-friendships', 'friends-import-export' ) )
)
) {
add_submenu_page( 'friends', __( 'Notification Manager', 'friends' ), '- ' . __( 'Notification Manager', 'friends' ), $required_role, 'friends-notification-manager', array( $this, 'render_admin_notification_manager' ) );
add_submenu_page( 'friends', __( 'Friendships', 'friends' ), '- ' . __( 'Friendships', 'friends' ), $required_role, 'friends-wp-friendships', array( $this, 'render_admin_wp_friendship_settings' ) );
add_submenu_page( 'friends', __( 'Import/Export', 'friends' ), '- ' . __( 'Import/Export', 'friends' ), $required_role, 'friends-import-export', array( $this, 'render_admin_import_export' ) );
Expand Down
10 changes: 10 additions & 0 deletions includes/class-friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,16 @@ public static function upgrade_plugin( $upgrader_object, $options ) {
}
$previous_version = get_option( 'friends_plugin_version' );

if ( version_compare( $previous_version, '2.9.0', '<' ) ) {
$users = User_Query::all_associated_users();
foreach ( $users->get_results() as $user ) {
if ( ! ( $user instanceof Subscription ) ) {
// We have a user that is not a virtual user, so the friendship functionality had been used.
update_option( 'friends_enable_wp_friendships', 1 );
break;
}
}
}
if ( version_compare( $previous_version, '0.20.1', '<' ) ) {
$users = User_Query::all_associated_users();
foreach ( $users->get_results() as $user ) {
Expand Down

0 comments on commit b371455

Please sign in to comment.