diff --git a/assets/wordpress-bdp.css b/assets/wordpress-bdp.css index d70f95a..d10e3e7 100644 --- a/assets/wordpress-bdp.css +++ b/assets/wordpress-bdp.css @@ -393,4 +393,14 @@ li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after, background-color: #FFFFFF !important; } +.bdp-newplugin-button:hover { + color: #ffffff !important; + background-color: #1d4899 !important; +} +.bdp-newplugin-button { + background-color: #ffffff !important; + padding: 5px 20px !important; + cursor: pointer !important; + color: #1d4899 !important; +} diff --git a/bdp-kompass.php b/bdp-kompass.php index 421173e..3ce5898 100644 --- a/bdp-kompass.php +++ b/bdp-kompass.php @@ -2,7 +2,7 @@ /** * Plugin Name: BdP Kompass * Description: Wordpress-Plugin zur Unterstützung von Stämmen im Bund der Pfadfinderinnen und Pfadfinder e.V. zur optimalen Verwaltung eurer Webseite - * Version: 4.6.2 + * Version: 4.8.1 * Tags: bdp, utility, helper * Requires at least: 6.0 * Requires PHP: 8.2 @@ -34,7 +34,6 @@ function bdp_plugin_init() { if (null == get_option('kompass_already_installed', null)) { Seo::setup(); - Calendar::setup(); Security::setup(); update_option('kompass_already_installed', true); wp_redirect( 'site-health.php?tab=bdp_enhanced_security'); diff --git a/includes/frontend-functions.php b/includes/frontend-functions.php index 029034c..689bf07 100644 --- a/includes/frontend-functions.php +++ b/includes/frontend-functions.php @@ -20,3 +20,51 @@ function bdp_update_dashboard_style() { wp_enqueue_style('custom-calendar-styles', BDP_LV_PLUGIN_URL . '/assets/calendar.css'); wp_enqueue_style('custom-security-styles', BDP_LV_PLUGIN_URL . '/assets/security.css'); } + +function kompass_install_plugin($url, $slug) { + // Überprüfen, ob die URL gültig ist + if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { + echo 'Ungültige URL'; + return; + } + + // Dateinamen und Pfad festlegen + $tmp_file = download_url($url); + + // Überprüfen, ob der Download erfolgreich war + if (is_wp_error($tmp_file)) { + echo 'Download-Fehler: ' . $tmp_file->get_error_message(); + return; + } + + // Pfad des Plugins + $plugin_folder = WP_PLUGIN_DIR; + + // Plugin Upgrader Klassen einbinden + require_once ABSPATH . 'wp-admin/includes/file.php'; + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + require_once ABSPATH . 'wp-admin/includes/misc.php'; + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; + require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; + + // Plugin upgrader initialisieren + $upgrader = new Plugin_Upgrader(new WP_Ajax_Upgrader_Skin()); + + // Plugin installieren + $result = $upgrader->install($tmp_file); + + // Temp Datei löschen + unlink($tmp_file); + activate_plugin($slug . '/' . $slug . '.php' ); + + + // Überprüfen, ob die Installation erfolgreich war + if (is_wp_error($result)) { + echo 'Installations-Fehler: ' . $result->get_error_message(); + } else { + echo 'Plugin erfolgreich installiert'; + } + +} + diff --git a/modules/KompassSettings/Controllers/SettingsPage.php b/modules/KompassSettings/Controllers/SettingsPage.php index c48d08f..2428e76 100644 --- a/modules/KompassSettings/Controllers/SettingsPage.php +++ b/modules/KompassSettings/Controllers/SettingsPage.php @@ -6,6 +6,49 @@ namespace Bdp\Modules\KompassSettings\Controllers; class SettingsPage { public static function add_menu() { + if ( + null !== get_option('bdp_calendar_source_url', null ) || + !file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php') + ) + { + add_menu_page( + 'Kalender Installation', + 'Kalender Installation', + 'manage_options', + 'kompass-calendar', + ['Bdp\Modules\PluginInstaller\Controllers\InstallSingleplugin', 'install_calendar'], + 'dashicons-calendar-alt', + 2 + ); + + if ( file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php') ) { + add_action( 'admin_notices', array( 'Bdp\Modules\PluginInstaller\Controllers\OutdatedModule', 'calender' ) ); + } + } + + + if ( + !file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../solea/solea.php') + ) + { + add_menu_page( + 'Installiere solea (Veranstaltungen)', + 'Installiere solea (Veranstaltungen)', + 'manage_options', + 'kompass-events', + ['Bdp\Modules\PluginInstaller\Controllers\InstallSingleplugin', 'install_events'], + 'dashicons-tickets-alt', + 2 + ); + + } + + + + + + + add_submenu_page('options-general.php', 'kompass Einstellungen', 'kompass Einstellungen', @@ -63,10 +106,8 @@ class SettingsPage if (isset($_REQUEST['update_options']) && $_REQUEST['update_options'] == true) { switch ($tab) { case 'tab2': - update_option('bdp_calendar_categories', json_encode($_POST['category'])); - update_option('bdp_calendar_source_url', $_POST['bdp_calendar_source_url']); - $showMessage = __('The settings were saved.', BDP_LV_PLUGIN_SLUG); - break; + kompass_print_message_box('Diese Funktion wird nicht mdehr unterstützt.', 'error'); + break; case 'tab3': update_option('kompass_seo_google_verification', $_POST['kompass_seo_google_verification']); diff --git a/modules/calendar/classes/Calendar.class.php b/modules/calendar/classes/Calendar.class.php index 7b00912..da29a54 100644 --- a/modules/calendar/classes/Calendar.class.php +++ b/modules/calendar/classes/Calendar.class.php @@ -5,25 +5,6 @@ class Calendar public $ical; private $categories = []; - public static function setup() - { - $pageName = 'Kalender'; - $page_exists = get_page_by_path($pageName, OBJECT, 'page'); - - // Wenn die Seite nicht existiert, erstelle sie - if (!$page_exists) { - $page_id = wp_insert_post(array( - 'post_title' => $pageName, - 'post_content' => '{{calendar}}', - 'post_status' => 'publish', - 'post_type' => 'page', - )); - - update_option('bdp_calendar_source_url', 'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics'); - } - } - - public static function printCalendar($content) : string { // Der zu ersetzende String $original_string = '{{calendar}}'; @@ -67,8 +48,10 @@ class Calendar } - $calendarUrl = get_option('bdp_calendar_source_url', 'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics'); - + $calendarUrl = get_option('bdp_calendar_source_url', null); + if (null === '') { + return; + } $this->ical = new \ICal('', array( 'defaultSpan' => 2, // Default value 'defaultTimeZone' => '', diff --git a/modules/plugin-installer/Controllers/class-installsingleplugin.php b/modules/plugin-installer/Controllers/class-installsingleplugin.php new file mode 100644 index 0000000..a28f5cf --- /dev/null +++ b/modules/plugin-installer/Controllers/class-installsingleplugin.php @@ -0,0 +1,57 @@ +ID, false ); + } + $calendar_connection = get_option( 'bdp_calendar_source_url', + 'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics' ); + if ( 'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics' !== $calendar_connection ) { + update_option( 'kronos_calendar_url', $calendar_connection ); + } + delete_option( 'bdp_calendar_source_url' ); + + + kompass_install_plugin( 'https://repos.contelli.de/plugins/kronos/download', 'kronos' ); + + + } + } else { + $install_link = admin_url( 'admin.php?page=kompass-calendar&install=true' ); + require dirname( __FILE__ ) . '/../views/install-item.php'; + } + } + + public static function install_events () + { + if ( isset( $_REQUEST[ 'install' ] ) ) { + if ( !file_exists( dirname( BDP_LV_STARTUP_FILE ) . '/../solea/solea.php' ) ) { + kompass_install_plugin( 'https://repos.contelli.de/plugins/solea/download', 'solea' ); + } + } else { + $install_link = admin_url( 'admin.php?page=kompass-events&install=true' ); + require dirname( __FILE__ ) . '/../views/install-item.php'; + } + } +} \ No newline at end of file diff --git a/modules/plugin-installer/Controllers/class-outdatedmodule.php b/modules/plugin-installer/Controllers/class-outdatedmodule.php new file mode 100644 index 0000000..0de638b --- /dev/null +++ b/modules/plugin-installer/Controllers/class-outdatedmodule.php @@ -0,0 +1,21 @@ + + +
+ Um die gewünschte Komponente zu aktivieren, klicke bitte hier auf aktivieren.
+ kompass führt dabei die Installation im Hintergrund durch. +
+ Jetzt installieren +
+
diff --git a/modules/plugin-installer/views/outdated-component.php b/modules/plugin-installer/views/outdated-component.php new file mode 100644 index 0000000..18f9322 --- /dev/null +++ b/modules/plugin-installer/views/outdated-component.php @@ -0,0 +1,18 @@ + + +
+ kompass hat festgestellt, dass du die Komponente nutzt, die nicht weiterentwickelt wird.
+ Es steht eine neue Version bereit, bitte klicke hier, um die Aktualisierung durchzuführen. +
+ diff --git a/style.css b/style.css index 5f0eb16..7aba2c4 100644 --- a/style.css +++ b/style.css @@ -50,4 +50,4 @@ wp-submenu ul, #wp-admin-bar-wp-logo { display: none; -} \ No newline at end of file +}