2024-07-17 16:17:54 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2024-08-15 15:59:58 +02:00
|
|
|
* General settings class.
|
2024-07-17 16:17:54 +02:00
|
|
|
*
|
2024-08-15 15:59:58 +02:00
|
|
|
* This file contains the General class definition, which handles the "General" settings
|
|
|
|
* page for the ActivityPub Event Extension Plugin, providing options for configuring various general settings.
|
2024-07-17 16:17:54 +02:00
|
|
|
*
|
|
|
|
* @package Activitypub_Event_Extensions
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Activitypub_Event_Extensions\Admin;
|
|
|
|
|
2024-08-15 15:59:58 +02:00
|
|
|
// Exit if accessed directly.
|
|
|
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
2024-07-17 16:17:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class responsible for Event Plugin related admin notices.
|
|
|
|
*
|
|
|
|
* Notices for guiding to proper configuration of ActivityPub with event plugins.
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
class Settings_Page {
|
|
|
|
|
2024-08-15 15:59:58 +02:00
|
|
|
/**
|
2024-07-17 16:17:54 +02:00
|
|
|
* TODO:
|
2024-08-15 15:59:58 +02:00
|
|
|
* - [ ] create settings page
|
2024-07-17 16:17:54 +02:00
|
|
|
* - [ ] skeleton
|
|
|
|
* - [ ] Autoloader
|
|
|
|
* - [ ] Common settings?
|
|
|
|
* - [ ] Hook points
|
|
|
|
* - [ ] let transformers hook settings into the page
|
|
|
|
* - [ ] provide setting-type-classes for hooks
|
|
|
|
* - [ ] True/False
|
|
|
|
* - [ ] Number
|
|
|
|
* - [ ] advanced for mapping
|
|
|
|
*/
|
|
|
|
|
2024-08-15 15:59:58 +02:00
|
|
|
const STATIC = 'Activitypub_Event_Extensions\Admin\Settings_Page';
|
|
|
|
|
|
|
|
const SETTINGS_SLUG = 'activitypub-events';
|
2024-07-17 16:17:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Warning if the plugin is Active and the ActivityPub plugin is not.
|
|
|
|
*/
|
|
|
|
public static function admin_menu() {
|
|
|
|
\add_options_page(
|
|
|
|
'Activitypub Event Extension',
|
|
|
|
'Activitypub Events',
|
|
|
|
'manage_options',
|
2024-08-15 15:59:58 +02:00
|
|
|
self::SETTINGS_SLUG,
|
|
|
|
array( self::STATIC, 'settings_page' )
|
2024-07-17 16:17:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-18 16:24:05 +02:00
|
|
|
/**
|
|
|
|
* Adds Link to the settings page in the plugin page.
|
|
|
|
* It's called via apply_filter('plugin_action_links_' . PLUGIN_NAME).
|
|
|
|
*
|
2024-08-15 15:59:58 +02:00
|
|
|
* @param array $links Already added links.
|
|
|
|
* @return array Original links but with link to setting page added.
|
2024-07-18 16:24:05 +02:00
|
|
|
*/
|
|
|
|
public static function settings_link( $links ) {
|
|
|
|
return array_merge(
|
|
|
|
$links,
|
|
|
|
array(
|
2024-08-15 15:59:58 +02:00
|
|
|
'<a href="' . admin_url( 'options-general.php?page=' . self::SETTINGS_SLUG ) . '">Settings</a>',
|
2024-07-18 16:24:05 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2024-07-17 16:17:54 +02:00
|
|
|
|
|
|
|
public static function settings_page() {
|
|
|
|
if ( empty( $_GET['tab'] ) ) {
|
|
|
|
$tab = 'general';
|
|
|
|
} else {
|
|
|
|
$tab = sanitize_key( $_GET['tab'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
submenu_options = {
|
|
|
|
tab => {name => ''
|
|
|
|
active => true|false}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2024-08-15 15:59:58 +02:00
|
|
|
// TODO: generate this somehow.
|
|
|
|
// Maybe with filters, similar as with the settings!
|
2024-07-17 16:17:54 +02:00
|
|
|
$submenu_options = array(
|
|
|
|
'general' => array(
|
2024-08-15 15:59:58 +02:00
|
|
|
'name' => 'General',
|
|
|
|
'active' => false,
|
2024-07-17 16:17:54 +02:00
|
|
|
),
|
|
|
|
'events_manager' => array(
|
2024-08-15 15:59:58 +02:00
|
|
|
'name' => 'Events Manager',
|
2024-07-17 16:17:54 +02:00
|
|
|
'active' => false,
|
|
|
|
),
|
|
|
|
'gatherpress' => array(
|
2024-08-15 15:59:58 +02:00
|
|
|
'name' => 'Gatherpress',
|
2024-07-17 16:17:54 +02:00
|
|
|
'active' => false,
|
|
|
|
),
|
|
|
|
'the_events_calendar' => array(
|
2024-08-15 15:59:58 +02:00
|
|
|
'name' => 'The Events Calendar',
|
2024-07-17 16:17:54 +02:00
|
|
|
'active' => false,
|
|
|
|
),
|
|
|
|
'vsel' => array(
|
2024-08-15 15:59:58 +02:00
|
|
|
'name' => 'VS Event',
|
2024-07-17 16:17:54 +02:00
|
|
|
'active' => false,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2024-08-15 15:59:58 +02:00
|
|
|
$submenu_options[ $tab ]['active'] = true;
|
2024-07-17 16:17:54 +02:00
|
|
|
|
2024-07-18 17:46:29 +02:00
|
|
|
$args = array(
|
2024-08-15 15:59:58 +02:00
|
|
|
'slug' => self::SETTINGS_SLUG,
|
2024-07-18 17:46:29 +02:00
|
|
|
'options' => $submenu_options,
|
|
|
|
);
|
2024-07-17 16:17:54 +02:00
|
|
|
|
|
|
|
switch ( $tab ) {
|
|
|
|
case 'general':
|
2024-08-15 15:59:58 +02:00
|
|
|
\load_template( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . 'templates/settings-general.php', true, $args );
|
2024-07-17 16:17:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
2024-07-18 17:46:29 +02:00
|
|
|
\load_template( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . 'templates/settings-extractor.php', true, $args );
|
2024-07-17 16:17:54 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|