1
0
Fork 0
forked from lino/radar-wp

Bump 2.0.6 - did these only get committed to SVN and not git?

This commit is contained in:
ekes 2021-01-20 14:49:00 +01:00
parent c57a3a776a
commit 3ff30b8fb7
5 changed files with 46 additions and 21 deletions

View file

@ -59,7 +59,7 @@ class Squat_Radar_Connector {
$result = []; $result = [];
// Urldecode not required here because of the regex match. // Urldecode not required here because of the regex match.
// Radar paramaters here are transcoded so will match. // Radar paramaters here are transcoded so will match.
if (preg_match('|//radar.squat.net/([a-z]{2})/events/([a-zA-Z0-9/]*)|', $url, $matches)) { if (preg_match('|//radar.squat.net/([a-z]{2})/events/([a-zA-Z0-9\-/]*)|', $url, $matches)) {
$result['language'] = $matches[1]; $result['language'] = $matches[1];
foreach (array_chunk(explode('/', $matches[2]), 2) as $key_value_pair) { foreach (array_chunk(explode('/', $matches[2]), 2) as $key_value_pair) {
$result['facets'][$key_value_pair[0]] = $key_value_pair[1]; $result['facets'][$key_value_pair[0]] = $key_value_pair[1];
@ -90,7 +90,7 @@ class Squat_Radar_Connector {
// Urlencode should do nothing here @see comment in decode_search_url. // Urlencode should do nothing here @see comment in decode_search_url.
// If someone has snuck something in it will however help. // If someone has snuck something in it will however help.
foreach ( $facets as $key => $value ) { foreach ( $facets as $key => $value ) {
$query[] = ['facets[' . urlencode($key) . '][]' => urlencode($value)]; $query['facets[' . urlencode($key) . ']'][] = urlencode($value);
} }
if ( ! empty($fields) ) { if ( ! empty($fields) ) {
// {raw}urlencode is encoding : and , both of which are valid pchar. // {raw}urlencode is encoding : and , both of which are valid pchar.

View file

@ -339,12 +339,12 @@ class Squat_Radar_Formatter {
static public function field_summary_html($value, $original, $field, $context) { static public function field_summary_html($value, $original, $field, $context) {
if ( $field[0] == 'summary' ) { if ( $field[0] == 'summary' ) {
// Summary is only populated if there is an explict summary. // Summary is only populated if there is an explict summary.
if ( empty( trim($value) ) ) { $value = trim($value);
if ( empty( $value ) ) {
array_shift($field); array_shift($field);
if (is_array($field)) { if (is_array($field)) {
$field_tree = array_reverse($field); $field_tree = array_reverse($field);
$sibling_fields = self::getValue($context['event'], $field_tree); $sibling_fields = self::getValue($context['event'], $field_tree);
$value = print_r($context['event'], true);
if (! empty( $sibling_fields['value'] ) ) { if (! empty( $sibling_fields['value'] ) ) {
$value = wp_trim_words( $sibling_fields['value'], 30 ); $value = wp_trim_words( $sibling_fields['value'], 30 );
} }
@ -366,7 +366,10 @@ class Squat_Radar_Formatter {
* image:file:url * image:file:url
*/ */
static public function field_image_html($value, $original, $field, $context) { static public function field_image_html($value, $original, $field, $context) {
if ($field[0] == 'url' && $field[1] == 'file' && $field[2] == 'image') { if ( isset($field[0]) && $field[0] == 'url' &&
isset($field[1]) && $field[1] == 'file' &&
isset($field[2]) && $field[2] == 'image'
) {
return '<img src="'. esc_url_raw($original) .'" class="squat-radar-image" \>'; return '<img src="'. esc_url_raw($original) .'" class="squat-radar-image" \>';
} }

View file

@ -40,7 +40,7 @@ class Squat_Radar_Widget extends WP_Widget {
* Enqueue scripts callback, add CSS. * Enqueue scripts callback, add CSS.
*/ */
static public function widget_style() { static public function widget_style() {
wp_register_style( 'squat-radar-widget', SQUAT_RADAR_URL . '/assets/squat-radar.css' ); wp_register_style( 'squat-radar-widget', SQUAT_RADAR_URL . 'assets/squat-radar.css' );
wp_enqueue_style( 'squat-radar-widget' ); wp_enqueue_style( 'squat-radar-widget' );
} }
@ -48,7 +48,7 @@ class Squat_Radar_Widget extends WP_Widget {
* Enqueue scripts callback, add JS. * Enqueue scripts callback, add JS.
*/ */
static public function widget_script() { static public function widget_script() {
wp_register_script( 'squat-radar-widget', SQUAT_RADAR_URL . '/assets/squat-radar.js', ['jquery'] ); wp_register_script( 'squat-radar-widget', SQUAT_RADAR_URL . 'assets/squat-radar.js', ['jquery'] );
} }
/** /**
@ -121,7 +121,7 @@ class Squat_Radar_Widget extends WP_Widget {
else { else {
wp_enqueue_script( 'squat-radar-widget'); 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', 'squat_radar_widget', [ 'ajaxurl' => admin_url( 'admin-ajax.php' ) ] );
wp_localize_script( 'squat-radar-widget', $widget_id, $instance ); wp_localize_script( 'squat-radar-widget', $widget_id, ['number' => $this->number] );
echo '<div id="' . $widget_id . '" class="squat-radar-widget squat-radar-ajax"><a href="' . esc_url_raw( $instance['url']['value'] ) . '">' echo '<div id="' . $widget_id . '" class="squat-radar-widget squat-radar-ajax"><a href="' . esc_url_raw( $instance['url']['value'] ) . '">'
. esc_url( $instance['url']['value'] ) . esc_url( $instance['url']['value'] )
@ -140,9 +140,16 @@ class Squat_Radar_Widget extends WP_Widget {
} }
$data = []; $data = [];
$instance = $_POST['instance'];
// Load instance configuration from ID.
$instance_number = (int) $_POST['instance']['number'];
$widget_options_all = get_option('widget_squat_radar');
if ( ! isset($widget_options_all[$instance_number]) ) {
wp_die();
}
try { try {
$data['html'] = self::instance_events_html($instance); $data['html'] = self::instance_events_html($widget_options_all[$instance_number]);
} }
catch ( Squat_Radar_Connector_Exception $e ) { catch ( Squat_Radar_Connector_Exception $e ) {
$data = ['is_error' => TRUE]; $data = ['is_error' => TRUE];
@ -193,7 +200,7 @@ class Squat_Radar_Widget extends WP_Widget {
// //
$field_id = esc_attr( $this->get_field_id( 'limit' ) ); $field_id = esc_attr( $this->get_field_id( 'limit' ) );
$field_name = esc_attr( $this->get_field_name( 'limit' ) ); $field_name = esc_attr( $this->get_field_name( 'limit' ) );
$field_label = esc_attr( 'Number of events to display:', 'squat-radar' ); $field_label = esc_attr( 'Max number of events to display:', 'squat-radar' );
$field_value = empty( $instance['limit'] ) ? '10' : (int) $instance['limit']; $field_value = empty( $instance['limit'] ) ? '10' : (int) $instance['limit'];
$field_class = 'tiny-text'; $field_class = 'tiny-text';
echo "<p>"; echo "<p>";
@ -219,7 +226,7 @@ class Squat_Radar_Widget extends WP_Widget {
echo '<div class="description error">' . __('The URL was not recognised as a Radar Events search result. It needs to include the domain and the rest of the /events/search/path like: https://radar.squat.net/en/events/city/City_Name/group/123 Start from <a href="https://radar.squat.net/en/events" target="_blank">https://radar.squat.net/en/events</a> and use the filters in the right hand colunm there before copying the URL from your browser address bar.', 'squat-radar') . '</div>'; echo '<div class="description error">' . __('The URL was not recognised as a Radar Events search result. It needs to include the domain and the rest of the /events/search/path like: https://radar.squat.net/en/events/city/City_Name/group/123 Start from <a href="https://radar.squat.net/en/events" target="_blank">https://radar.squat.net/en/events</a> and use the filters in the right hand colunm there before copying the URL from your browser address bar.', 'squat-radar') . '</div>';
} }
else { else {
echo '<div class="description">' . __('Go to <a href="https://radar.squat.net/en/events" target="_blank">https://radar.squat.net/en/events</a> and filter for the events you want to show. Then copy the URL from your address bar into here. It will look similar to: https://radar.squat.net/en/events/city/City_Name/group/123', 'squat-radar') . '</div>'; echo '<div class="description">' . __('Go to <a href="https://radar.squat.net/en/events" target="_blank">https://radar.squat.net/en/events</a> and filter for the events you want to show. Then copy the URL from your address bar into here. It will look similar to: https://radar.squat.net/en/events/city/City_Name/group/123 for example the URL to show all international callouts is https://radar.squat.net/en/events/callout/international-callout', 'squat-radar') . '</div>';
} }
if ( empty($instance['url']['error']) && ! empty( $instance['url']['keys'] ) ) { if ( empty($instance['url']['error']) && ! empty( $instance['url']['keys'] ) ) {
@ -240,6 +247,18 @@ class Squat_Radar_Widget extends WP_Widget {
echo '<fieldset>'; echo '<fieldset>';
echo '<legend>' . __('Fields', 'squat-radar') . '</legend>'; echo '<legend>' . __('Fields', 'squat-radar') . '</legend>';
echo '<p>'; echo '<p>';
// Some sensible checkbox defaults.
if ( empty($instance['fields']) ) {
$instance['fields'] = [
'title_field' => '',
'date_time:time_start' => '',
'body:summary' => '',
'category' => '',
'offline:address' => '',
'offline:map' => '',
'url' => '',
];
}
foreach ($this->preset_fields() as $api_field_name => $field_label) { foreach ($this->preset_fields() as $api_field_name => $field_label) {
$field_id = esc_attr( $this->get_field_id( 'field-' . $api_field_name ) ); $field_id = esc_attr( $this->get_field_id( 'field-' . $api_field_name ) );
$field_name = esc_attr( $this->get_field_name( 'field-' . $api_field_name ) ); $field_name = esc_attr( $this->get_field_name( 'field-' . $api_field_name ) );
@ -298,7 +317,7 @@ class Squat_Radar_Widget extends WP_Widget {
$checked = checked( $use_cron, TRUE, FALSE ); $checked = checked( $use_cron, TRUE, FALSE );
echo "<input type=\"checkbox\" class=\"checkbox\" id=\"$field_id\" name=\"$field_name\"$checked />"; echo "<input type=\"checkbox\" class=\"checkbox\" id=\"$field_id\" name=\"$field_name\"$checked />";
echo "<label for=\"$field_id\">$field_label</label><br />"; echo "<label for=\"$field_id\">$field_label</label><br />";
echo '<div class="description">' . __('Experimental. Do not use AJAX, but always display the cached version of the events. Update the cache after the expiry length using cron. Works best if you have a regular external cronjob running.') . '</div>'; echo '<div class="description">' . __('Do not use AJAX, but always display the cached version of the events. Update the cache after the expiry length using cron. Works best if you have a regular external cronjob running.') . '</div>';
echo '</fieldset>'; echo '</fieldset>';

View file

@ -1,9 +1,9 @@
=== squat-radar === === squat-radar ===
Tags: calendar,events Tags: calendar,events
Requires at least: 4.8 Requires at least: 4.0
Tested up to: 5.1 Tested up to: 5.4
Requires PHP: 5.4.0 Requires PHP: 5.4.0
Stable tag: 2.0.0 Stable tag: 2.0.6
License: GPLv2 or later License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ -13,11 +13,15 @@ Provides integration with https://radar.squat.net/ to display events on your Wor
Enable the plugin as normal for your system. Enable the plugin as normal for your system.
Once activated: Once activated:
1. Visit the Widgets page. Here you will now see \'Squat Radar Events\' widget, and the \'Squat Radar Shortcode\' sidebar. 1. Visit the Widgets page. Here you will now see 'Squat Radar Events' widget, and the 'Squat Radar Shortcode' sidebar.
2. Add the widget to either the sidebar you want, or if you want to use the shortcode in content, the \'Squat Radar Shortcode\' sidebar. 2. Add the widget to either the sidebar you want, or if you want to use the shortcode in content, the 'Squat Radar Shortcode' sidebar.
3. To configure the sidebar go to https://radar.squat.net/events and filter for the events you want to show. Maybe your city and group, or a category etc. 3. To configure the sidebar go to https://radar.squat.net/events and filter for the events you want to show. Maybe your city and group, or a category etc.
4. Once you have the events filter you want copy the address from your address bar into the widget. 4. Once you have the events filter you want copy the address from your address bar into the widget.
5. Select which fields you would like to show. 5. Select which fields you would like to show.
If you put the widget in a displayed sidebar that\'s it. The filtered list of upcoming events will now show up. If you put the widget in a displayed sidebar that's it. The filtered list of upcoming events will now show up.
If you used the Shortcode sidebar, add [squat_radar_sidebar] to the content where you want the events to display. If you used the Shortcode sidebar, add [squat_radar_sidebar] to the content where you want the events to display.
If you put the shortcode in a page called 'Events', make sure you've disabled any plugins which would suppress the contents of that page, for example 'The Events Calendar'.
For extra-easy instructions with screenshots, look here:
https://network23.org/blog/2019/10/18/radar-events-plugin/

View file

@ -11,9 +11,8 @@
* Plugin Name: Squat Radar calendar integration * Plugin Name: Squat Radar calendar integration
* Plugin URI: https://0xacab.org/radar/radar-wp * Plugin URI: https://0xacab.org/radar/radar-wp
* Description: 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.0 * Version: 2.0.6
* Author: Radar contributors * Author: Radar contributors
* Author URI: https://0xacab.org/radar/radar-wp
* License: GPL-2.0+ * License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: squat-radar * Text Domain: squat-radar