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

@ -40,7 +40,7 @@ class Squat_Radar_Widget extends WP_Widget {
* Enqueue scripts callback, add CSS.
*/
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' );
}
@ -48,7 +48,7 @@ class Squat_Radar_Widget extends WP_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'] );
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 {
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, $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'] ) . '">'
. esc_url( $instance['url']['value'] )
@ -140,9 +140,16 @@ class Squat_Radar_Widget extends WP_Widget {
}
$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 {
$data['html'] = self::instance_events_html($instance);
$data['html'] = self::instance_events_html($widget_options_all[$instance_number]);
}
catch ( Squat_Radar_Connector_Exception $e ) {
$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_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_class = 'tiny-text';
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>';
}
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'] ) ) {
@ -240,6 +247,18 @@ class Squat_Radar_Widget extends WP_Widget {
echo '<fieldset>';
echo '<legend>' . __('Fields', 'squat-radar') . '</legend>';
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) {
$field_id = esc_attr( $this->get_field_id( '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 );
echo "<input type=\"checkbox\" class=\"checkbox\" id=\"$field_id\" name=\"$field_name\"$checked />";
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>';