Refactoring: each event plugin is now represented by the implementation of a Event_Plugin base class. #24
6 changed files with 364 additions and 0 deletions
|
@ -109,6 +109,17 @@ class Setup {
|
|||
return self::$instance;
|
||||
}
|
||||
|
||||
public static function get_event_plugins() {
|
||||
// Get all plugin definition classes from the includes/plugins folder.
|
||||
$plugin_files = glob( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . 'includes/plugins/class-*.php' );
|
||||
|
||||
foreach ( $plugin_files as $plugin_file ) {
|
||||
require_once $plugin_file;
|
||||
|
||||
}
|
||||
return $basenames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that checks for supported activated event plugins.
|
||||
*
|
||||
|
|
71
includes/plugins/class-events-manager.php
Normal file
71
includes/plugins/class-events-manager.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* Events Manager.
|
||||
*
|
||||
* Defines all the necessary meta information for the Events Manager WordPress Plugin.
|
||||
*
|
||||
* @link https://wordpress.org/plugins/events-manager/
|
||||
* @package Activitypub_Event_Extensions
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
namespace Activitypub_Event_Extensions\Plugins;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
require_once __DIR__ . '/interface-event-plugin.php';
|
||||
|
||||
/**
|
||||
* Interface for a supported event plugin.
|
||||
*
|
||||
* This interface defines which information is necessary for a supported event plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Events_Manager implements Event_Plugin {
|
||||
/**
|
||||
* Returns the full plugin file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_plugin_file(): string {
|
||||
return 'the-events-calendar/the-events-calendar.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event post type of the plugin.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_post_type(): string {
|
||||
return defined( 'EM_POST_TYPE_EVENT' ) ? constant( 'EM_POST_TYPE_EVENT' ) : 'event';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the main settings page of the plugin.
|
||||
*
|
||||
* @return string The settings page url.
|
||||
*/
|
||||
public static function get_settings_page(): string {
|
||||
return 'wp-admin/edit.php?post_type=event&page=events-manager-options#general';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActivityPub transformer class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_activitypub_transformer_class_name(): string {
|
||||
return 'GatherPress';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the taxonomy used for the plugin's event categories.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_taxonomy(): string {
|
||||
return defined( 'EM_TAXONOMY_CATEGORY' ) ? constant( 'EM_TAXONOMY_CATEGORY' ) : 'event-categories';
|
||||
}
|
||||
}
|
76
includes/plugins/class-gatherpress.php
Normal file
76
includes/plugins/class-gatherpress.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* GatherPress.
|
||||
*
|
||||
* Defines all the necessary meta information for the GatherPress plugin.
|
||||
*
|
||||
* @link https://wordpress.org/plugins/gatherpress/
|
||||
* @package Activitypub_Event_Extensions
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
namespace Activitypub_Event_Extensions\Plugins;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
require_once __DIR__ . '/interface-event-plugin.php';
|
||||
|
||||
use Activitypub_Event_Extensions\Plugins\Event_Plugin;
|
||||
use GatherPress\Core\Event;
|
||||
use GatherPress\Core\Topic;
|
||||
use GatherPress\Core\Utility;
|
||||
|
||||
/**
|
||||
* Interface for a supported event plugin.
|
||||
*
|
||||
* This interface defines which information is necessary for a supported event plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Gatherpress implements Event_Plugin {
|
||||
/**
|
||||
* Returns the full plugin file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_plugin_file(): string {
|
||||
return 'the-events-calendar/the-events-calendar.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event post type of the plugin.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_post_type(): string {
|
||||
return Event::POST_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the main settings page of the plugin.
|
||||
*
|
||||
* @return string The settings page url.
|
||||
*/
|
||||
public static function get_settings_page(): string {
|
||||
return Utility::prefix_key( 'general' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActivityPub transformer class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_activitypub_transformer_class_name(): string {
|
||||
return 'GatherPress';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the taxonomy used for the plugin's event categories.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_taxonomy(): string {
|
||||
return Topic::TAXONOMY;
|
||||
}
|
||||
}
|
76
includes/plugins/class-the-events-calendar.php
Normal file
76
includes/plugins/class-the-events-calendar.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* The Events Calendar.
|
||||
*
|
||||
* Defines all the necessary meta information for the events calendar.
|
||||
*
|
||||
* @link https://wordpress.org/plugins/the-events-calendar/
|
||||
* @package Activitypub_Event_Extensions
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
namespace Activitypub_Event_Extensions\Plugins;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
require_once __DIR__ . '/interface-event-plugin.php';
|
||||
|
||||
use Activitypub_Event_Extensions\Plugins\Event_Plugin;
|
||||
|
||||
/**
|
||||
* Interface for a supported event plugin.
|
||||
*
|
||||
* This interface defines which information is necessary for a supported event plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class The_Events_Calendar implements Event_plugin {
|
||||
/**
|
||||
* Returns the full plugin file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_plugin_file(): string {
|
||||
return 'the-events-calendar/the-events-calendar.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event post type of the plugin.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_post_type(): string {
|
||||
return \Tribe__Events__Main::POSTTYPE;
|
||||
}
|
||||
|
||||
const POST_TYPE = class_exists( 'Tribe__Events__Main' ) ? \Tribe__Events__Main::POSTTYPE : 'tribe_event';
|
||||
|
||||
/**
|
||||
* Returns the ID of the main settings page of the plugin.
|
||||
*
|
||||
* @return string The settings page url.
|
||||
*/
|
||||
public static function get_settings_page(): string {
|
||||
// TODO: Tribe\Events\Admin\Settings::settings_page_id.
|
||||
return 'edit.php?post_type=tribe_events&page=tec-events-settings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActivityPub transformer class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_activitypub_transformer_class_name(): string {
|
||||
return 'Tribe';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the taxonomy used for the plugin's event categories.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_taxonomy(): string {
|
||||
return Tribe__Events__Main::TAXONOMY;
|
||||
}
|
||||
}
|
72
includes/plugins/class-vs-event-list.php
Normal file
72
includes/plugins/class-vs-event-list.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* VS Events LIst.
|
||||
*
|
||||
* Defines all the necessary meta information for the WordPress event plugin
|
||||
* "Very Simple Events List".
|
||||
*
|
||||
* @link https://de.wordpress.org/plugins/very-simple-event-list/
|
||||
* @package Activitypub_Event_Extensions
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
namespace Activitypub_Event_Extensions\Plugins;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
require_once __DIR__ . '/interface-event-plugin.php';
|
||||
|
||||
/**
|
||||
* Interface for a supported event plugin.
|
||||
*
|
||||
* This interface defines which information is necessary for a supported event plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class VS_Event_List implements Event_Plugin {
|
||||
/**
|
||||
* Returns the full plugin file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_plugin_file(): string {
|
||||
return 'very-simple-event-list/vsel.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event post type of the plugin.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_post_type(): string {
|
||||
return 'event';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the main settings page of the plugin.
|
||||
*
|
||||
* @return string The settings page url.
|
||||
*/
|
||||
public static function get_settings_page(): string {
|
||||
return 'settings_page_vsel';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActivityPub transformer class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_activitypub_transformer_class_name(): string {
|
||||
return 'VS_Event';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the taxonomy used for the plugin's event categories.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_taxonomy(): string {
|
||||
return 'event_cat';
|
||||
}
|
||||
}
|
58
includes/plugins/interface-event-plugin.php
Normal file
58
includes/plugins/interface-event-plugin.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/**
|
||||
* Interface for defining supported Event Plugins.
|
||||
*
|
||||
* Basic information that each supported event needs for this plugin to work.
|
||||
*
|
||||
* @package Activitypub_Event_Extensions
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
namespace Activitypub_Event_Extensions\Plugins;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
/**
|
||||
* Interface for a supported event plugin.
|
||||
*
|
||||
* This interface defines which information is necessary for a supported event plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface Event_Plugin {
|
||||
/**
|
||||
* Returns the full plugin file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_plugin_file(): string;
|
||||
|
||||
/**
|
||||
* Returns the event post type of the plugin.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_post_type(): string;
|
||||
|
||||
/**
|
||||
* Returns the ID of the main settings page of the plugin.
|
||||
*
|
||||
* @return string The settings page url.
|
||||
*/
|
||||
public static function get_settings_page(): string;
|
||||
|
||||
/**
|
||||
* Returns the ActivityPub transformer class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_activitypub_transformer_class_name(): string;
|
||||
|
||||
/**
|
||||
* Returns the taxonomy used for the plugin's event categories.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_taxonomy(): string;
|
||||
}
|
Loading…
Reference in a new issue