From 7083316af136bb63f288ad7b5513669a166a336b Mon Sep 17 00:00:00 2001 From: ekes Date: Thu, 24 Mar 2022 21:22:19 +0100 Subject: [PATCH 1/6] Fixes and updates to not break 5.9 --- assets/squat-radar.js | 13 +------ includes/squat-radar-widget.php | 60 +++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/assets/squat-radar.js b/assets/squat-radar.js index 00394f9..8939ee9 100644 --- a/assets/squat-radar.js +++ b/assets/squat-radar.js @@ -7,7 +7,7 @@ jQuery(function($){ type: 'POST', data: { action: "squat_radar_events", - instance: window[widget.id], + instance: squat_radar_widget[widget.id], }, success: function(result){ @@ -20,17 +20,6 @@ jQuery(function($){ } else { $(widget).empty(); $(widget).append(result.html); -// $(".squat-li a").on('click', function(e){ - -// if (this.hasAttribute("data-link")) { -// e.preventDefault(); -// $(this).parent().find('p').show(); -// this.textContent = this.getAttribute('data-nog-meer'); -// this.setAttribute('href', this.getAttribute('data-link')); -// this.removeAttribute('data-link'); -// } -// -// }); } }, error: function(res){ diff --git a/includes/squat-radar-widget.php b/includes/squat-radar-widget.php index f4a6eef..26034ac 100644 --- a/includes/squat-radar-widget.php +++ b/includes/squat-radar-widget.php @@ -25,11 +25,11 @@ class Squat_Radar_Widget extends WP_Widget { /** * Register the widget */ - public static function register_widget() { - register_widget( __CLASS__ ); + public static function register_widget() { + register_widget( __CLASS__ ); add_action( 'wp_ajax_squat_radar_events', [__CLASS__, 'ajax_callback'] ); add_action( 'wp_ajax_nopriv_squat_radar_events', [__CLASS__, 'ajax_callback'] ); - add_action( 'wp_enqueue_scripts', [__CLASS__, 'widget_script'] ); + wp_register_script( 'squat-radar-widget', SQUAT_RADAR_URL . 'assets/squat-radar.js', ['jquery'] ); add_action( 'wp_enqueue_scripts', [__CLASS__, 'widget_style'] ); add_action( 'squat_radar_widget_cache_cron', [__CLASS__, 'cache_cron'] ); @@ -44,13 +44,6 @@ class Squat_Radar_Widget extends WP_Widget { wp_enqueue_style( 'squat-radar-widget' ); } - /** - * Enqueue scripts callback, add JS. - */ - static public function widget_script() { - wp_register_script( 'squat-radar-widget', SQUAT_RADAR_URL . 'assets/squat-radar.js', ['jquery'] ); - } - /** * Cron action. * @@ -66,7 +59,7 @@ class Squat_Radar_Widget extends WP_Widget { } } } - add_option('squat_radar_widget_cron_run', $last_run); + update_option('squat_radar_widget_cron_run', $last_run); } /** @@ -75,9 +68,9 @@ class Squat_Radar_Widget extends WP_Widget { protected static function cache_refresh($instance) { $connector = new Squat_Radar_Connector(); - $languages = apply_filters('wpml_active_languages', NULL); - $languages = is_array($languages) ? array_keys($languages) : []; - $languages = array_merge($instance['url']['keys']['language'], $languages); + $languages = apply_filters('wpml_active_languages', NULL); + $languages = is_array($languages) ? array_keys($languages) : []; + $languages = array_merge([$instance['url']['keys']['language']], $languages); foreach ($languages as $language) { try { // Force update. Don't set expire. @@ -119,9 +112,12 @@ class Squat_Radar_Widget extends WP_Widget { } } else { - wp_enqueue_script( 'squat-radar-widget'); - wp_localize_script( 'squat-radar-widget', 'squat_radar_widget', [ 'ajaxurl' => admin_url( 'admin-ajax.php' ) ] ); - wp_localize_script( 'squat-radar-widget', $widget_id, ['number' => $this->number] ); + wp_enqueue_script( 'squat-radar-widget'); + wp_add_inline_script('squat-radar-widget', + 'const squat_radar_widget = ' . json_encode( [ + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + $widget_id => $this->number, + ] ) . ';', 'before'); echo '
' . esc_url( $instance['url']['value'] ) @@ -142,7 +138,7 @@ class Squat_Radar_Widget extends WP_Widget { $data = []; // Load instance configuration from ID. - $instance_number = (int) $_POST['instance']['number']; + $instance_number = (int) $_POST['instance']; $widget_options_all = get_option('widget_squat_radar'); if ( ! isset($widget_options_all[$instance_number]) ) { wp_die(); @@ -181,7 +177,6 @@ class Squat_Radar_Widget extends WP_Widget { * Widget options. */ public function form( $instance ) { - // // Title. // @@ -329,8 +324,7 @@ class Squat_Radar_Widget extends WP_Widget { * Save widget options. */ public function update( $new_instance, $old_instance ) { - $options = []; - + $options = []; if ( ! empty( $new_instance['title'] ) ) { $options['title'] = sanitize_text_field( $new_instance['title'] ); } @@ -338,10 +332,18 @@ class Squat_Radar_Widget extends WP_Widget { $options['title'] = ''; } - if ( ! empty($new_instance['url']) ) { - $keys = $this->connector->decode_search_url($new_instance['url']); + if ( ! empty($new_instance['url']) ) { + // The value passed here changes somewhere post WP5.4. + // More recent versions have the options array in the instance. + if (is_string($new_instance['url'])) { + $url = $new_instance['url']; + } + else { + $url = $new_instance['url']['value']; + } + $keys = $this->connector->decode_search_url($url); $options['url']['keys'] = $keys; - $options['url']['value'] = $new_instance['url']; + $options['url']['value'] = $url; if (empty($keys)) { $options['url']['error'] = 'URL not recognised'; } @@ -350,14 +352,20 @@ class Squat_Radar_Widget extends WP_Widget { $options['url'] = ['value' => '', 'keys' => []]; } - $options['fields'] = []; + // When called by 5.9 ajax this contains the already set array. + // Just check it's sane. + $options['fields'] = is_array($new_instance['fields']) ? $new_instance['fields'] : []; + array_filter($options['fields'], function ($v, $k) { + return ($v == $k) && (preg_match('([^a-zA-Z_:])', $k) === 0); + }, ARRAY_FILTER_USE_BOTH); + foreach ($this->preset_fields() as $field_name => $field_label) { if ( ! empty($new_instance['field-' . $field_name]) ) { $options['fields'][$field_name] = $field_name; } } - if ( ! empty($new_instance['fields']) ) { + if ( ! empty($new_instance['fields']) && is_string($new_instance['fields']) ) { $matches = []; preg_match_all('/([a-zA-Z_:]+)/', $new_instance['fields'], $matches); $options['fields'] += array_combine($matches[0], $matches[0]); From 75cb545d2b8067646bfadaad03ccfa334b5a69c9 Mon Sep 17 00:00:00 2001 From: ekes Date: Thu, 24 Mar 2022 21:28:41 +0100 Subject: [PATCH 2/6] Prepare for new release. --- readme.txt | 8 ++++---- squat-radar.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/readme.txt b/readme.txt index f13c7ea..6a5c78e 100644 --- a/readme.txt +++ b/readme.txt @@ -1,9 +1,9 @@ === squat-radar === Tags: calendar,events -Requires at least: 4.0 -Tested up to: 5.8 -Requires PHP: 5.4.0 -Stable tag: 2.0.8 +Requires at least: 5.3 +Tested up to: 5.9 +Requires PHP: 7.4.0 +Stable tag: 2.0.9 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/squat-radar.php b/squat-radar.php index cff8dc8..58bda56 100644 --- a/squat-radar.php +++ b/squat-radar.php @@ -11,7 +11,7 @@ * Plugin Name: Squat Radar calendar integration * Plugin URI: https://0xacab.org/radar/radar-wp * Description: Provides widget, and shortcode, integration for displaying events from https://radar.squat.net/ agenda. - * Version: 2.0.8 + * Version: 2.0.9 * Author: Radar contributors * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt From 9d40e375bfaf9a49ee87d9354aa5072809000911 Mon Sep 17 00:00:00 2001 From: lino Date: Mon, 19 Aug 2024 03:50:32 +0200 Subject: [PATCH 3/6] add custom functionality --- assets/squat-radar.css | 144 ++++++++++++++--------------- includes/squat-radar-formatter.php | 10 +- plugin-change-README.txt | 45 +++++++++ squat-radar.php | 3 +- 4 files changed, 126 insertions(+), 76 deletions(-) create mode 100644 plugin-change-README.txt diff --git a/assets/squat-radar.css b/assets/squat-radar.css index bc17894..ff69778 100644 --- a/assets/squat-radar.css +++ b/assets/squat-radar.css @@ -1,72 +1,72 @@ -.squat-radar.radar-event { - margin-bottom: 1em; - padding-bottom: 1em; - border-bottom: 1px solid #ddd; - text-align:left; -} -.squat-radar.radar-event::after { - content: ''; - display: block; - float: none; - clear: both; -} -.squat-radar.rader-event:last-child { - border-bottom: 0; - padding-bottom: 0; - margin-bottom: 0; -} -.squat-radar.radar-event-cancelled { - text-decoration: line-through; -} - -.squat-radar .squat-radar-title { - line-height: 1; - font-size: 1.4em; - margin-bottom: 0.2em; -} - -.squat-radar .squat-radar-datetime { - font-weight: bold; -} - -.squat-radar .squat-radar-datetime.squat-radar-datetime-start::before { - content: ''; - display: block; - float: none; - clear: both; -} - -.squat-radar .squat-radar-event-start-end::after, -.squat-radar .squat-radar-event-start { - content: ''; - display: block; - float: none; - clear: both; -} - -.squat-radar .squat-radar-list li { - display: inline; - list-style: none; -} - -.squat-radar .squat-radar-list li:after { - content: ", "; -} - -.squat-radar .squat-radar-list li:last-child:after { - content: ""; -} - -.squat-radar a.squat-radar-url-more { - padding: .4180469716em 1.11575em; - margin-left: 10px; -/* margin-bottom: 10px;*/ - float: right; -} -.squat-radar a.squat-radar-url-more:hover { - color: white !important; -} - -.squat_radar a.squat-radar-url-more:focus { - outline: 0; -} +.squat-radar.radar-event { + margin-bottom: 1em; + padding-bottom: 1em; + border-bottom: 1px solid #ddd; + text-align:left; +} +.squat-radar.radar-event::after { + content: ''; + display: block; + float: none; + clear: both; +} +.squat-radar.rader-event:last-child { + border-bottom: 0; + padding-bottom: 0; + margin-bottom: 0; +} +.squat-radar.radar-event-cancelled { + text-decoration: line-through; +} + +.squat-radar .squat-radar-title { + line-height: 1; + font-size: 1.4em; + margin-bottom: 0.2em; +} + +.squat-radar .squat-radar-datetime { + font-weight: bold; +} + +.squat-radar .squat-radar-datetime.squat-radar-datetime-start::before { + content: ''; + display: block; + float: none; + clear: both; +} + +.squat-radar .squat-radar-event-start-end::after, +.squat-radar .squat-radar-event-start { + content: ''; + display: block; + float: none; + clear: both; +} + +.squat-radar .squat-radar-list li { + display: inline; + list-style: none; +} + +.squat-radar .squat-radar-list li:after { + content: ", "; +} + +.squat-radar .squat-radar-list li:last-child:after { + content: ""; +} + +.squat-radar a.squat-radar-url-more { + padding: .4180469716em 1.11575em; + margin-left: 10px; +/* margin-bottom: 10px;*/ + float: right; +} +.squat-radar a.squat-radar-url-more:hover { + color: white; +} + +.squat_radar a.squat-radar-url-more:focus { + outline: 0; +} diff --git a/includes/squat-radar-formatter.php b/includes/squat-radar-formatter.php index 8481f49..06288dc 100644 --- a/includes/squat-radar-formatter.php +++ b/includes/squat-radar-formatter.php @@ -209,7 +209,8 @@ class Squat_Radar_Formatter { private static function field_date_format($time, $start_end, $time_only = FALSE) { - $date_format = get_option('squat_radar_date_format', 'j M Y'); + $date_format = get_option('squat_radar_date_format', 'd.m.'); + $year_format = get_option('squat_radar_date_format', 'Y'); $time_format = get_option('squat_radar_time_format', 'H:i'); // Remove offset to stop time being converted to UTC. @@ -220,6 +221,9 @@ class Squat_Radar_Formatter { $output .= ''; $output .= date_i18n($date_format, strtotime($time)); $output .= ' '; + $output .= ''; + $output .= date_i18n($year_format, strtotime($time)); + $output .= ' '; } $output .= ''; $output .= date_i18n($time_format, strtotime($time)); @@ -301,11 +305,11 @@ class Squat_Radar_Formatter { */ static public function field_link_html($value, $original, $field, $context) { if ( ($field[0] == 'title' || $field[0] == 'title_field') && ! empty($context['event']['url'])) { - return '' . sanitize_text_field( $value ) . ''; + return '' . sanitize_text_field( $value ) . ''; } if ($field[0] == 'url' && count($field) == 1) { - return '' . __('more…', 'squat-radar') . ''; + return '' . __('more…', 'squat-radar') . ''; } elseif ($field[0] == 'url') { $title = esc_url($value); diff --git a/plugin-change-README.txt b/plugin-change-README.txt new file mode 100644 index 0000000..81be109 --- /dev/null +++ b/plugin-change-README.txt @@ -0,0 +1,45 @@ +PATH: /wp-content/plugins/squat-radar-calendar-integration/includes/squat-radar-formatter.php + + + +In dem Block der Datumsangabe wurde das Tag/Monat und Jahr separiert. (Und deutsche Zeitangaben) + + private static function field_date_format($time, $start_end, $time_only = FALSE) { + + $date_format = get_option('squat_radar_date_format', 'd.m.'); + $year_format = get_option('squat_radar_date_format', 'Y'); + $time_format = get_option('squat_radar_time_format', 'H:i'); + + // Remove offset to stop time being converted to UTC. + $time = substr($time, 0, -6); + + $output = ''; + if ( ! $time_only ) { + $output .= ''; + $output .= date_i18n($date_format, strtotime($time)); + $output .= ' '; + $output .= ''; + $output .= date_i18n($year_format, strtotime($time)); + $output .= ' '; + } + + +Links werden im anderen Tab geöffnet (target="_blank" hinzufügen) + +static public function field_link_html($value, $original, $field, $context) { + if ( ($field[0] == 'title' || $field[0] == 'title_field') && ! empty($context['event']['url'])) { + return '' . sanitize_text_field( $value ) . ''; + } + + if ($field[0] == 'url' && count($field) == 1) { + return '' . __('more…', 'squat-radar') . ''; + } + + + + +css squat-radar.css +important entfernen +.squat-radar a.squat-radar-url-more:hover { + color: white !important; +} diff --git a/squat-radar.php b/squat-radar.php index 58bda56..a24eb02 100644 --- a/squat-radar.php +++ b/squat-radar.php @@ -8,7 +8,7 @@ * @package Squat_Radar * * @wordpress-plugin - * Plugin Name: Squat Radar calendar integration + * Plugin Name: Squat Radar calendar integration custom * Plugin URI: https://0xacab.org/radar/radar-wp * Description: Provides widget, and shortcode, integration for displaying events from https://radar.squat.net/ agenda. * Version: 2.0.9 @@ -17,6 +17,7 @@ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Text Domain: squat-radar * Domain Path: /languages + * Gitea Plugin URI: https://git.systemausfall.org/newyorck/radar-wp-custom */ if ( ! defined( 'ABSPATH' ) ) { From a9ef9963afadd46a425319de0cf02662a61b16c8 Mon Sep 17 00:00:00 2001 From: lino Date: Mon, 19 Aug 2024 03:56:53 +0200 Subject: [PATCH 4/6] add new description to test update --- squat-radar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squat-radar.php b/squat-radar.php index a24eb02..61138f4 100644 --- a/squat-radar.php +++ b/squat-radar.php @@ -10,7 +10,7 @@ * @wordpress-plugin * Plugin Name: Squat Radar calendar integration custom * Plugin URI: https://0xacab.org/radar/radar-wp - * Description: Provides widget, and shortcode, integration for displaying events from https://radar.squat.net/ agenda. + * Description: Custom: Provides widget, and shortcode, integration for displaying events from https://radar.squat.net/ agenda. * Version: 2.0.9 * Author: Radar contributors * License: GPL-2.0+ From 98c8386a1ca68848a958bf3556e014bd399c3716 Mon Sep 17 00:00:00 2001 From: lino Date: Mon, 19 Aug 2024 04:06:18 +0200 Subject: [PATCH 5/6] update plugin path --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5963699..e4456ca 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "radar-wp/squat-radar", + "name": "radar-wp-custom/squat-radar", "description": "Wordpress Calendar widget for https://radar.squat.net/ events", "type": "wordpress-plugin", "homepage": "https://radar.squat.net", From 14abfc0d666fcfa8606a657e71c84e07a05a1a7d Mon Sep 17 00:00:00 2001 From: lino Date: Mon, 19 Aug 2024 04:08:12 +0200 Subject: [PATCH 6/6] add new description to test update --- squat-radar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squat-radar.php b/squat-radar.php index 61138f4..a24eb02 100644 --- a/squat-radar.php +++ b/squat-radar.php @@ -10,7 +10,7 @@ * @wordpress-plugin * Plugin Name: Squat Radar calendar integration custom * Plugin URI: https://0xacab.org/radar/radar-wp - * Description: Custom: Provides widget, and shortcode, integration for displaying events from https://radar.squat.net/ agenda. + * Description: Provides widget, and shortcode, integration for displaying events from https://radar.squat.net/ agenda. * Version: 2.0.9 * Author: Radar contributors * License: GPL-2.0+