From 7cbb7bb6e6fd4e7b5ca0a3e385078b0842901b23 Mon Sep 17 00:00:00 2001 From: JJ Date: Thu, 15 Aug 2024 13:16:46 -0400 Subject: [PATCH 1/4] add buddypress to local environment for testing --- composer.json | 1 + composer.lock | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 52183ae60..6106ed221 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,7 @@ "wp-coding-standards/wpcs": "^3.1", "wp-phpunit/wp-phpunit": "^6.6", "wpackagist-plugin/advanced-custom-fields": "6.3.4", + "wpackagist-plugin/buddypress": "14.0.0", "wpackagist-plugin/classic-editor": "1.6.4", "wpackagist-plugin/easy-digital-downloads": "3.3.1", "wpackagist-plugin/jetpack": "13.6", diff --git a/composer.lock b/composer.lock index 339b8eac8..c27b19915 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "10410efd54bb48d70f99c5e81ba94947", + "content-hash": "8238a49e6491e7a1369be939e9e43b83", "packages": [ { "name": "composer/installers", @@ -8468,6 +8468,24 @@ "type": "wordpress-plugin", "homepage": "https://wordpress.org/plugins/advanced-custom-fields/" }, + { + "name": "wpackagist-plugin/buddypress", + "version": "14.0.0", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/buddypress/", + "reference": "tags/14.0.0" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/buddypress.14.0.0.zip" + }, + "require": { + "composer/installers": "^1.0 || ^2.0" + }, + "type": "wordpress-plugin", + "homepage": "https://wordpress.org/plugins/buddypress/" + }, { "name": "wpackagist-plugin/classic-editor", "version": "1.6.4", From 20ac7b878e0d9fe0b52bdeec312daffcbe2dcb73 Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 16 Aug 2024 10:42:43 -0400 Subject: [PATCH 2/4] wip: working through various scenarios --- connectors/class-connector-buddypress.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/connectors/class-connector-buddypress.php b/connectors/class-connector-buddypress.php index 2a4c160a8..12810fae3 100644 --- a/connectors/class-connector-buddypress.php +++ b/connectors/class-connector-buddypress.php @@ -173,6 +173,13 @@ public function get_context_labels() { * @return array Action links */ public function action_links( $links, $record ) { + + // Check we have access to BuddyPress on this blog and that the user will have access to the links. + if ( ! $this->is_dependency_satisfied() || ! bp_current_user_can_moderate() ) { + return; + } + + // In the links, we also need to check the functions themselves as they're dependent on the BuddyPress module being enabled. if ( in_array( $record->context, array( 'components' ), true ) ) { $option_key = $record->get_meta( 'option_key', true ); @@ -181,7 +188,7 @@ public function action_links( $links, $record ) { array( 'page' => 'bp-components', ), - admin_url( 'admin.php' ) + get_admin_url( $record->blog_id, 'admin.php' ) ); } elseif ( 'bp-pages' === $option_key ) { $page_id = $record->get_meta( 'page_id', true ); @@ -190,7 +197,7 @@ public function action_links( $links, $record ) { array( 'page' => 'bp-page-settings', ), - admin_url( 'admin.php' ) + get_admin_url( $record->blog_id, 'admin.php' ) ); if ( $page_id ) { @@ -203,7 +210,7 @@ public function action_links( $links, $record ) { array( 'page' => $record->get_meta( 'page', true ), ), - admin_url( 'admin.php' ) + get_admin_url( $record->blog_id, 'admin.php' ) ); } elseif ( in_array( $record->context, array( 'groups' ), true ) && function_exists( 'groups_get_group' ) ) { $group_id = $record->get_meta( 'id', true ); @@ -218,7 +225,7 @@ public function action_links( $links, $record ) { $base_url = \bp_get_admin_url( 'admin.php?page=bp-groups&gid=' . $group_id ); $delete_url = wp_nonce_url( $base_url . '&action=delete', 'bp-groups-delete' ); $edit_url = $base_url . '&action=edit'; - $visit_url = \bp_get_group_permalink( $group ); + $visit_url = function_exists( 'bp_get_group_url' ) ? \bp_get_group_url( $group ) : \bp_get_group_permalink( $group ); $links[ esc_html__( 'Edit group', 'stream' ) ] = $edit_url; $links[ esc_html__( 'View group', 'stream' ) ] = $visit_url; From dfc469825dcac6aeceb73cb8f2157a0c6d112fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Krzemin=CC=81ski?= Date: Fri, 4 Oct 2024 13:29:01 +0200 Subject: [PATCH 3/4] Align .nvmrc Node version with package.json --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index 209e3ef4b..2a393af59 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20 +20.18.0 From 452adb138020f097bb4aa6cf06e23436c219886f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Krzemin=CC=81ski?= Date: Tue, 8 Oct 2024 14:01:29 +0200 Subject: [PATCH 4/4] chore: fix return type for no action links --- connectors/class-connector-buddypress.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectors/class-connector-buddypress.php b/connectors/class-connector-buddypress.php index 12810fae3..490516fbb 100644 --- a/connectors/class-connector-buddypress.php +++ b/connectors/class-connector-buddypress.php @@ -176,7 +176,7 @@ public function action_links( $links, $record ) { // Check we have access to BuddyPress on this blog and that the user will have access to the links. if ( ! $this->is_dependency_satisfied() || ! bp_current_user_can_moderate() ) { - return; + return []; } // In the links, we also need to check the functions themselves as they're dependent on the BuddyPress module being enabled.