Add options for summary #80

Merged
linos merged 15 commits from custom_summary into main 2024-12-06 18:27:08 +01:00
7 changed files with 20 additions and 20 deletions
Showing only changes of commit dddfa70f1f - Show all commits

View file

@ -77,7 +77,7 @@ jobs:
- name: Run General Tests
run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=activitypub_event_bridge
run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=event_bridge_for_activitypub
env:
PHP_VERSION: ${{ matrix.php-version }}

View file

@ -69,7 +69,7 @@
"test-wp-event-manager": "phpunit --filter=wp_event_manager",
"test-eventin": "phpunit --filter=eventin",
"test-modern-events-calendar-lite": "phpunit --filter=modern_events_calendar_lite",
"test-activitypub-event-bridge-shortcodes": "phpunit --filter=activitypub_event_bridge_shortcodes",
"test-activitypub-event-bridge-shortcodes": "phpunit --filter=event_bridge_for_activitypub_shortcodes",
"test-eventprime": "phpunit --filter=eventprime",
"test-event-organiser": "phpunit --filter=event_organiser",
"test-all": "phpunit"

View file

@ -27,8 +27,8 @@ define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION', current( get_file_data( __FILE__, array( 'Version' ), 'plugin' ) ) );
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_DOMAIN', 'event-bridge-for-activitypub' );
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_ACTIVITYPUB_PLUGIN_MIN_VERSION', '3.2.2' );
define( 'ACTIVITYPUB_EVENT_BRIDGE_CUSTOM_SUMMARY', "<ul>\n <li>[ap_start_time]</li>\n <li>[ap_end_time]</li>\n <li>[ap_location]</li>\n</ul>\n[ap_hashcats][ap_hashtags]" );
define( 'ACTIVITYPUB_EVENT_BRIDGE_DEFAULT_SUMMARY_TYPE', 'preset' );
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY', "<ul>\n <li>[ap_start_time]</li>\n <li>[ap_end_time]</li>\n <li>[ap_location]</li>\n</ul>\n[ap_hashcats][ap_hashtags]" );
define( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE', 'preset' );
// Include and register the autoloader class for automatic loading of plugin classes.
require_once EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/includes/class-autoloader.php';

View file

@ -446,7 +446,7 @@ abstract class Event extends Post {
$summary = \preg_replace( '/[\n\r\t]/', '', $summary );
$summary = \trim( $summary );
$summary = \apply_filters( 'activitypub_event_bridge_the_summary', $summary, $post );
$summary = \apply_filters( 'event_bridge_for_activitypub_the_summary', $summary, $post );
// Unregister the shortcodes.
Shortcodes::unregister();
@ -518,10 +518,10 @@ abstract class Event extends Post {
* @return string The Template.
*/
protected function get_event_summary_template() {
$summary = \get_option( 'activitypub_event_bridge_custom_summary', ACTIVITYPUB_EVENT_BRIDGE_CUSTOM_SUMMARY );
$template = $summary ?? ACTIVITYPUB_EVENT_BRIDGE_CUSTOM_SUMMARY;
$summary = \get_option( 'event_bridge_for_activitypub_custom_summary', EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY );
$template = $summary ?? EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY;
return apply_filters( 'activitypub_event_bridge_summary_template', $template, $this->wp_object );
return apply_filters( 'event_bridge_for_activitypub_summary_template', $template, $this->wp_object );
}
/**

View file

@ -85,12 +85,12 @@ class Settings {
\register_setting(
'activitypub-event-bridge',
'activitypub_event_bridge_custom_summary',
'event_bridge_for_activitypub_custom_summary',
array(
'type' => 'string',
'description' => \__( 'Define your own custom summary template for events', 'activitypub-event-bridge' ),
'show_in_rest' => true,
'default' => ACTIVITYPUB_EVENT_BRIDGE_CUSTOM_SUMMARY,
'default' => EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY,
)
);
}

View file

@ -47,7 +47,7 @@ $current_category_mapping = \get_option( 'event_bridge_for_activitypub_ev
<p><?php esc_html_e( 'Many Fediverse applications (e.g., Mastodon) don\'t fully support events, instead they will show a summary text along with the events title and the URL to your Website.', 'event-bridge-for-activitypub' ); ?></p>
<p>
<label for="activitypub_summary_type_preset">
<input type="radio" name="activitypub_summary_type" id="activitypub_summary_type_preset" value="preset" <?php echo \checked( 'preset', \get_option( 'activitypub_summary_type', ACTIVITYPUB_EVENT_BRIDGE_DEFAULT_SUMMARY_TYPE ) ); ?> />
<input type="radio" name="activitypub_summary_type" id="activitypub_summary_type_preset" value="preset" <?php echo \checked( 'preset', \get_option( 'activitypub_summary_type', EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE ) ); ?> />
<?php \esc_html_e( 'Automatic (default)', 'activitypub' ); ?>
-
<span class="description">
@ -57,7 +57,7 @@ $current_category_mapping = \get_option( 'event_bridge_for_activitypub_ev
</p>
<p>
<label for="activitypub_summary_type_custom">
<input type="radio" name="activitypub_summary_type" id="activitypub_summary_type_custom" value="custom" <?php echo \checked( 'custom', \get_option( 'activitypub_summary_type', ACTIVITYPUB_EVENT_BRIDGE_DEFAULT_SUMMARY_TYPE ) ); ?> />
<input type="radio" name="activitypub_summary_type" id="activitypub_summary_type_custom" value="custom" <?php echo \checked( 'custom', \get_option( 'activitypub_summary_type', EVENT_BRIDGE_FOR_ACTIVITYPUB_DEFAULT_SUMMARY_TYPE ) ); ?> />
<?php \esc_html_e( 'Custom', 'event-bridge-for-activitypub' ); ?>
-
<span class="description">
@ -66,7 +66,7 @@ $current_category_mapping = \get_option( 'event_bridge_for_activitypub_ev
</label>
</p>
<div id="activitypub_summary_type_custom-details">
<textarea name="event_bridge_for_activitypub_custom_summary" id="event_bridge_for_activitypub_custom_summary" rows="10" cols="50" class="large-text" placeholder="<?php echo wp_kses( ACTIVITYPUB_EVENT_BRIDGE_CUSTOM_SUMMARY, 'post' ); ?>"><?php echo esc_textarea( wp_kses( \get_option( 'event_bridge_for_activitypub_custom_summary', ACTIVITYPUB_EVENT_BRIDGE_CUSTOM_SUMMARY ), 'post' ) ); ?></textarea>
<textarea name="event_bridge_for_activitypub_custom_summary" id="event_bridge_for_activitypub_custom_summary" rows="10" cols="50" class="large-text" placeholder="<?php echo wp_kses( EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY, 'post' ); ?>"><?php echo esc_textarea( wp_kses( \get_option( 'event_bridge_for_activitypub_custom_summary', EVENT_BRIDGE_FOR_ACTIVITYPUB_CUSTOM_SUMMARY ), 'post' ) ); ?></textarea>
<details>
<summary><?php esc_html_e( 'See a list Template Tags available for the summary.', 'activitypub' ); ?></summary>
<div class="description">

View file

@ -2,7 +2,7 @@
/**
* Test file for Activitypub Shortcodes.
*
* @package ActivityPub_Event_Bridge
* @package Event_Bridge_For_ActivityPub
* @license AGPL-3.0-or-later
*/
@ -25,7 +25,7 @@ class Test_Activitypub_Event_Bridge_Shortcodes extends WP_UnitTestCase {
}
// Make sure that ActivityPub support is enabled for The Events Calendar.
$aec = \ActivityPub_Event_Bridge\Setup::get_instance();
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
$aec->activate_activitypub_support_for_active_event_plugins();
// Delete all posts afterwards.
@ -44,7 +44,7 @@ class Test_Activitypub_Event_Bridge_Shortcodes extends WP_UnitTestCase {
// Call the transformer Factory.
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
if ( ! $transformer instanceof \ActivityPub_Event_Bridge\Activitypub\Transformer\Event ) {
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
return;
}
@ -77,7 +77,7 @@ class Test_Activitypub_Event_Bridge_Shortcodes extends WP_UnitTestCase {
// Call the transformer Factory.
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
if ( ! $transformer instanceof \ActivityPub_Event_Bridge\Activitypub\Transformer\Event ) {
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
return;
}
@ -110,7 +110,7 @@ class Test_Activitypub_Event_Bridge_Shortcodes extends WP_UnitTestCase {
// Call the transformer Factory.
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
if ( ! $transformer instanceof \ActivityPub_Event_Bridge\Activitypub\Transformer\Event ) {
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
return;
}
@ -138,7 +138,7 @@ class Test_Activitypub_Event_Bridge_Shortcodes extends WP_UnitTestCase {
// Call the transformer Factory.
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
if ( ! $transformer instanceof \ActivityPub_Event_Bridge\Activitypub\Transformer\Event ) {
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
return;
}
@ -174,7 +174,7 @@ class Test_Activitypub_Event_Bridge_Shortcodes extends WP_UnitTestCase {
// Call the transformer Factory.
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
if ( ! $transformer instanceof \ActivityPub_Event_Bridge\Activitypub\Transformer\Event ) {
if ( ! $transformer instanceof \Event_Bridge_For_ActivityPub\Activitypub\Transformer\Event ) {
return;
}