diff --git a/inc/class-wp-object.php b/inc/class-wp-object.php index 239f734..4840491 100644 --- a/inc/class-wp-object.php +++ b/inc/class-wp-object.php @@ -33,6 +33,7 @@ abstract class WP_Object { * @param bool $hide_empty Optional flag to hide the meta box if there is no meta. */ public function render_meta_table( string $title = '', bool $hide_empty = false ) { + // Store meta. $meta = []; diff --git a/inc/objects/class-bp-group.php b/inc/objects/class-bp-group.php index 22bb97f..2505a0b 100644 --- a/inc/objects/class-bp-group.php +++ b/inc/objects/class-bp-group.php @@ -37,11 +37,17 @@ protected function __construct() { * Add meta boxes to the BuddyPress group edit screen. */ public function add_meta_boxes() { - // Get screen id. - $screen_id = get_current_screen()->id; + + // Ensure the group id is set. + if ( ! isset( $_GET['gid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended + return; + } // Store group id. - $this->object_id = (int) sanitize_text_field( wp_unslash( $_GET['gid'] ?? 0 ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $this->object_id = (int) sanitize_text_field( wp_unslash( $_GET['gid'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended + + // Get screen id. + $screen_id = get_current_screen()->id; // Group meta. add_meta_box( @@ -82,6 +88,12 @@ public function render_terms() { // Loop through taxonomies and terms and build data array. foreach ( $taxonomies as $taxonomy ) { + $taxonomy_object = get_taxonomy( $taxonomy->name ); + + if ( empty( $taxonomy_object ) ) { + continue; + } + // Reset data for this taxonomy. $data = []; @@ -106,12 +118,6 @@ public function render_terms() { ]; } - $taxonomy_object = get_taxonomy( $taxonomy->name ); - - if ( empty( $taxonomy_object ) ) { - continue; - } - ( new Table( $data, [