v4.8.1 #3
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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']);
|
||||
|
@ -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' => '',
|
||||
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* File: class-installsingleplugin.php
|
||||
*
|
||||
*
|
||||
* @since 2024-08-12
|
||||
* @license GPL-3.0-or-later
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
|
||||
namespace Bdp\Modules\PluginInstaller\Controllers;
|
||||
|
||||
use Plugin_Upgrader;
|
||||
use WP_Ajax_Upgrader_Skin;
|
||||
|
||||
class InstallSingleplugin
|
||||
{
|
||||
public static function install_calendar ()
|
||||
{
|
||||
if ( isset( $_REQUEST[ 'install' ] ) ) {
|
||||
if ( !file_exists( dirname( BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php' ) ) {
|
||||
$pageName = 'Kalender';
|
||||
$page_exists = get_page_by_path( $pageName, OBJECT, 'page' );
|
||||
if ( is_object( $page_exists ) ) {
|
||||
wp_delete_post( $page_exists->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';
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* File: class-outdatedmodule.php
|
||||
*
|
||||
*
|
||||
* @since 2024-08-12
|
||||
* @license GPL-3.0-or-later
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
|
||||
namespace Bdp\Modules\PluginInstaller\Controllers;
|
||||
|
||||
class OutdatedModule
|
||||
{
|
||||
public static function calender() {
|
||||
$module = 'Kalender';
|
||||
$install_url = admin_url('admin.php?page=kompass-calendar');
|
||||
require dirname(__FILE__) . '/../views/outdated-component.php';
|
||||
}
|
||||
}
|
20
modules/plugin-installer/views/install-item.php
Normal file
20
modules/plugin-installer/views/install-item.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* File: install-item.php
|
||||
*
|
||||
*
|
||||
* @since 2024-08-12
|
||||
* @license GPL-3.0-or-later
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<div style="width: 80%; margin: 50px auto; border-style: solid; border-width: 2px; border-color: #1d4899; padding: 10px;">
|
||||
Um die gewünschte Komponente zu aktivieren, klicke bitte hier auf aktivieren.<br />
|
||||
kompass führt dabei die Installation im Hintergrund durch.
|
||||
<div style="text-align: center">
|
||||
<a href="<?php echo $install_link; ?>" class="button bdp-newplugin-button">Jetzt installieren</a>
|
||||
</div>
|
||||
</div>
|
18
modules/plugin-installer/views/outdated-component.php
Normal file
18
modules/plugin-installer/views/outdated-component.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* File: outdated-component.php
|
||||
*
|
||||
*
|
||||
* @since 2024-08-12
|
||||
* @license GPL-3.0-or-later
|
||||
*
|
||||
* @package
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<div style="padding: 10px 10px; font-size: 15pt; margin-top: 20px; line-height: 30px; background-color: #fafafa; border-left: #f10905 10px solid;">
|
||||
kompass hat festgestellt, dass du die Komponente <?php echo esc_html($module); ?> nutzt, die nicht weiterentwickelt wird.<br />
|
||||
Es steht eine neue Version bereit, bitte klicke <a href="<?php echo esc_url($install_url); ?>">hier</a>, um die Aktualisierung durchzuführen.
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user