WIP: Add Event Sources Logic (ActivityPub follows) #86
3 changed files with 46 additions and 7 deletions
|
@ -11,4 +11,24 @@ jQuery( function( $ ) {
|
|||
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false );
|
||||
}
|
||||
} );
|
||||
|
||||
// Function to toggle visibility of custom details based on selected radio button.
|
||||
function toggleCustomDetailsForSummary() {
|
||||
if ($("#event_bridge_for_activitypub_summary_type_custom").is(':checked')) {
|
||||
$("#event_bridge_for_activitypub_summary_type_custom-details").show();
|
||||
} else {
|
||||
$("#event_bridge_for_activitypub_summary_type_custom-details").hide();
|
||||
}
|
||||
}
|
||||
|
||||
// Run the toggle function on page load.
|
||||
$(document).ready(function() {
|
||||
toggleCustomDetailsForSummary(); // Set the correct state on load.
|
||||
|
||||
// Listen for changes on the radio buttons
|
||||
$("input[name=event_bridge_for_activitypub_summary_type]").change(function() {
|
||||
toggleCustomDetailsForSummary(); // Update visibility on change.
|
||||
});
|
||||
});
|
||||
|
||||
} );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Plugin Name: Event Bridge for ActivityPub
|
||||
* Description: Integrating popular event plugins with the ActivityPub plugin.
|
||||
* Plugin URI: https://event-federation.eu/
|
||||
* Version: 0.3.2.6
|
||||
* Version: 0.3.2.7
|
||||
* Author: André Menrath
|
||||
* Author URI: https://graz.social/@linos
|
||||
* Text Domain: event-bridge-for-activitypub
|
||||
|
|
|
@ -414,22 +414,41 @@ class Setup {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the transmogrifier.
|
||||
* Get the transmogrifier class.
|
||||
*
|
||||
* Retrieves the appropriate transmogrifier class based on the active event plugin.
|
||||
*
|
||||
* @return string|null The transmogrifier class name or null if not available.
|
||||
*/
|
||||
public static function get_transmogrifier() {
|
||||
// Retrieve singleton instance.
|
||||
$setup = self::get_instance();
|
||||
|
||||
$event_sources_active = get_option( 'event_bridge_for_activitypub_event_sources_active', false );
|
||||
// Get plugin options.
|
||||
$event_sources_active = (bool) get_option( 'event_bridge_for_activitypub_event_sources_active', false );
|
||||
$event_plugin = get_option( 'event_bridge_for_activitypub_plugin_used_for_event_source_feature', '' );
|
||||
|
||||
if ( ! $event_sources_active || ! $event_plugin ) {
|
||||
return;
|
||||
// Bail out if event sources are not active or no plugin is specified.
|
||||
if ( ! $event_sources_active || empty( $event_plugin ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the list of active event plugins.
|
||||
$active_event_plugins = $setup->get_active_event_plugins();
|
||||
|
||||
// Loop through active plugins to find a match.
|
||||
foreach ( $active_event_plugins as $active_event_plugin ) {
|
||||
if ( strrpos( $active_event_plugin::class, $event_plugin ) ) {
|
||||
return $active_event_plugin::get_transmogrifier_class();
|
||||
// Retrieve the class name of the active plugin.
|
||||
$active_plugin_class = get_class( $active_event_plugin );
|
||||
|
||||
// Check if the active plugin class name contains the specified event plugin name.
|
||||
if ( false !== strpos( $active_plugin_class, $event_plugin ) ) {
|
||||
// Return the transmogrifier class provided by the plugin.
|
||||
return $active_event_plugin->get_transmogrifier_class();
|
||||
}
|
||||
}
|
||||
|
||||
// Return null if no matching plugin is found.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue