From e861ade6b6af8c2743166a7764768452d381b23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Thu, 4 Jan 2024 14:50:29 +0100 Subject: [PATCH] Fix code to follow latest upstream changes https://github.com/Automattic/wordpress-activitypub/commit/4c297acfd454a13260900ff0f97a9e3f425e960c --- activitypub-event-transformers.php | 14 +++++------ .../activitypub/transformer/class-tribe.php | 2 +- .../transformer/class-vs-event.php | 25 +++++++++---------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/activitypub-event-transformers.php b/activitypub-event-transformers.php index 63e8c91..e4f2ecc 100644 --- a/activitypub-event-transformers.php +++ b/activitypub-event-transformers.php @@ -44,8 +44,8 @@ add_filter( * Add admin notices for improved usability. */ function check_some_other_plugin() { - if ( is_plugin_active('activitypub/activitypub.php') ) { - if ( is_plugin_active('very-simple-event-list/vsel.php') ) { + if ( is_plugin_active( 'activitypub/activitypub.php' ) ) { + if ( is_plugin_active( 'very-simple-event-list/vsel.php' ) ) { add_action( 'admin_notices', 'vsel_admin_notices' ); } } @@ -54,10 +54,10 @@ function check_some_other_plugin() { add_action( 'admin_init', 'check_some_other_plugin' ); function vsel_admin_notices() { - $is_vsel_edit_page = isset($_GET['post_type']) && $_GET['post_type'] === 'event'; - $is_vsel_settings_page = strpos($_SERVER['REQUEST_URI'], '/wp-admin/options-general.php?page=vsel') !== false ; - $is_vsel_page = $is_vsel_edit_page || $is_vsel_settings_page; - $vsel_post_type_is_activitypub_enabeld = in_array( 'event', get_option( 'activitypub_support_post_types') ); + $is_vsel_edit_page = isset( $_GET['post_type'] ) && $_GET['post_type'] === 'event'; + $is_vsel_settings_page = strpos( $_SERVER['REQUEST_URI'], '/wp-admin/options-general.php?page=vsel' ) !== false; + $is_vsel_page = $is_vsel_edit_page || $is_vsel_settings_page; + $vsel_post_type_is_activitypub_enabeld = in_array( 'event', get_option( 'activitypub_support_post_types' ) ); if ( $is_vsel_page && ! $vsel_post_type_is_activitypub_enabeld ) { $vsel_plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/very-simple-event-list/vsel.php' ); $activitypub_plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/activitypub/activitypub.php' ); @@ -69,7 +69,7 @@ function vsel_admin_notices() { ), $activitypub_plugin_data['Name'], $vsel_plugin_data['Name'], - admin_url('options-general.php?page=activitypub&tab=settings') + admin_url( 'options-general.php?page=activitypub&tab=settings' ) ); wp_admin_notice( $notice, diff --git a/includes/activitypub/transformer/class-tribe.php b/includes/activitypub/transformer/class-tribe.php index d82bb41..270201f 100644 --- a/includes/activitypub/transformer/class-tribe.php +++ b/includes/activitypub/transformer/class-tribe.php @@ -97,7 +97,7 @@ class Tribe extends Post { // todo make it possible that one event can have multiple categories? // using cat_slugs isn't 100% nice way to do this, don't know if it's a good idea - $categories = tribe_get_event_cat_slugs( $this->object->ID ); + $categories = tribe_get_event_cat_slugs( $this->wp_object->ID ); if ( count( $categories ) === 0 ) { return null; diff --git a/includes/activitypub/transformer/class-vs-event.php b/includes/activitypub/transformer/class-vs-event.php index cb44641..79f1598 100644 --- a/includes/activitypub/transformer/class-vs-event.php +++ b/includes/activitypub/transformer/class-vs-event.php @@ -13,7 +13,6 @@ use Activitypub\Model\Blog_user; use function Activitypub\get_rest_url_by_path; - if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } @@ -81,7 +80,7 @@ class VS_Event extends Post { * @return array The Place. */ public function get_location() { - $address = get_post_meta( $this->object->ID, 'event-location', true ); + $address = get_post_meta( $this->wp_object->ID, 'event-location', true ); $place = new Place(); $place->set_type( 'Place' ); $place->set_name( $address ); @@ -93,7 +92,7 @@ class VS_Event extends Post { * Get the end time from the events metadata. */ protected function get_end_time() { - $end_time = get_post_meta( $this->object->ID, 'event-date', true ); + $end_time = get_post_meta( $this->wp_object->ID, 'event-date', true ); return \gmdate( 'Y-m-d\TH:i:s\Z', $end_time ); } @@ -101,7 +100,7 @@ class VS_Event extends Post { * Get the end time from the events metadata. */ protected function get_start_time() { - $start_time = get_post_meta( $this->object->ID, 'event-start-date', true ); + $start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true ); return \gmdate( 'Y-m-d\TH:i:s\Z', $start_time ); } @@ -109,7 +108,7 @@ class VS_Event extends Post { * Get the event link from the events metadata. */ private function get_event_link() { - $event_link = get_post_meta( $this->object->ID, 'event-link', true ); + $event_link = get_post_meta( $this->wp_object->ID, 'event-link', true ); if ( $event_link ) { return array( 'type' => 'Link', @@ -140,7 +139,7 @@ class VS_Event extends Post { * @return string $category */ protected function get_category() { - $post_categories = wp_get_post_terms( $this->object->ID, 'event_cat' ); + $post_categories = wp_get_post_terms( $this->wp_object->ID, 'event_cat' ); if ( empty( $post_categories ) ) { return 'MEETING'; @@ -201,16 +200,16 @@ class VS_Event extends Post { * @return string $summary The custom event summary. */ public function get_summary() { - if ( $this->object->excerpt ) { - $excerpt = $this->object->post_excerpt; - } else if ( get_post_meta( $this->object->ID, 'event-summary', true ) ) { - $excerpt = get_post_meta( $this->object->ID, 'event-summary', true ); + if ( $this->wp_object->excerpt ) { + $excerpt = $this->wp_object->post_excerpt; + } else if ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) { + $excerpt = get_post_meta( $this->wp_object->ID, 'event-summary', true ); } else { $excerpt = $this->get_content(); } - $address = get_post_meta( $this->object->ID, 'event-location', true ); - $start_time = get_post_meta( $this->object->ID, 'event-start-date', true ); + $address = get_post_meta( $this->wp_object->ID, 'event-location', true ); + $start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true ); $datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); $start_time_string = wp_date( $datetime_format, $start_time ); $summary = "šŸ“ {$address}\nšŸ“… {$start_time_string}\n\n{$excerpt}"; @@ -231,7 +230,7 @@ class VS_Event extends Post { ->set_comments_enabled( true ) ->set_external_participation_url( $this->get_url() ) ->set_status( 'CONFIRMED' ) - ->set_name( get_the_title( $this->object->ID ) ) + ->set_name( get_the_title( $this->wp_object->ID ) ) ->set_timezone( $object->get_locale ) ->set_is_online( false ) ->set_in_language( $this->get_locale() )