';
}
diff --git a/includes/squat-radar-instance.php b/includes/squat-radar-instance.php
index db62124..14c542d 100644
--- a/includes/squat-radar-instance.php
+++ b/includes/squat-radar-instance.php
@@ -62,7 +62,7 @@ class Squat_Radar_Instance {
register_sidebar([
'name' => __( 'Squat Radar Shortcodes'),
- 'description'=> __( 'This widget area is not by default displayed on frontend. It can be displayed with all its widgets with the [squat_radar] shortcode; or used to hold active widgets displayed with their own [squat_radar_widget id="X"] shortcode, see instructions on widget configuration for the id.', 'squat-radar' ),
+ 'description'=> __( 'This widget area is not by default displayed on frontend. It can be displayed with all its widgets with the [squat_radar_sidebar] shortcode.', 'squat-radar' ),
'id' => 'squat_radar_widget_shortcode',
'before_widget' => '
',
'after_widget' => '
',
diff --git a/includes/squat-radar-widget.php b/includes/squat-radar-widget.php
index e41a8bc..c67f029 100644
--- a/includes/squat-radar-widget.php
+++ b/includes/squat-radar-widget.php
@@ -22,9 +22,7 @@ class Squat_Radar_Widget extends WP_Widget {
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'] );
- add_action( 'wp_enqueue_style', [__CLASS__, 'widget_style'] );
-
- add_shortcode( 'squat_radar_widget', [__CLASS__, 'shortcode' ] );
+ add_action( 'wp_enqueue_scripts', [__CLASS__, 'widget_style'] );
add_action( 'squat_radar_widget_cache_cron', [__CLASS__, 'cache_cron'] );
add_option( 'squat_radar_widget_cron_run', []);
@@ -32,44 +30,13 @@ class Squat_Radar_Widget extends WP_Widget {
static public function widget_style() {
wp_register_style( 'squat-radar-widget', SQUAT_RADAR_URL . '/assets/squat-radar.css' );
+ wp_enqueue_style( 'squat-radar-widget' );
}
static public function widget_script() {
wp_register_script( 'squat-radar-widget', SQUAT_RADAR_URL . '/assets/squat-radar.js', ['jquery'] );
}
- /**
- * Output a widget using 'squat_radar_widget' shortcode.
- *
- * Requires the widget ID.
- *
- * @example [squat_radar_widget id="1"]
- */
- static public function shortcode( $attributes, $content = '' ) {
- $defaults = [
- 'id' => '__i__',
- ];
- $attributes = shortcode_atts($defaults, $attributes, 'squat_radar_widget');
-
- // Return early if ID is unknown.
- $option = get_option( 'widget_squat_radar' );
- if (! isset( $option[$attributes['id']] )) {
- if ( current_user_can( 'administrator' ) ) {
- $content = '' . __('Squat Radar Widget shortcode ID not recognised. Check the suggestion at the top of the widget in the adminstration interface.', 'squat-radar') . '';
- }
- return $content;
- }
-
- $instance = $option[$attributes['id']];
- // render the widget
- ob_start();
- // To allow overriding the args here? For before after etc.
- the_widget( __CLASS__, $instance);
- $content = ob_get_clean();
-
- return $content;
- }
-
public static function cache_cron() {
$now = time();
$last_run = get_option('squat_radar_widget_cron_run', []);
@@ -86,12 +53,15 @@ class Squat_Radar_Widget extends WP_Widget {
protected static function cache_refresh($instance) {
$connector = new Squat_Radar_Connector();
- // @todo Languages...
- try {
- $data = $connector->events($instance['url']['keys']['facets'], $instance['fields'], $language, $instance['limit'], 0, TRUE );
- }
- catch ( Squat_Radar_Connector_Exception $e ) {
- return FALSE;
+ $languages = apply_filters( 'wpml_active_languages', NULL);
+ $languages = array_merge($instance['url']['keys']['language'], (array) $languages);
+ foreach ($languages as $language) {
+ try {
+ $data = $connector->events($instance['url']['keys']['facets'], $instance['fields'], $language, $instance['limit'], 0, TRUE );
+ }
+ catch ( Squat_Radar_Connector_Exception $e ) {
+ return FALSE;
+ }
}
return TRUE;
@@ -99,7 +69,6 @@ class Squat_Radar_Widget extends WP_Widget {
public function widget( $args, $instance ) {
- wp_enqueue_style( 'squat-radar-widget' );
$widget_id = 'squat_radar_widget_' . $this->number;
echo $args['before_widget'];
@@ -158,7 +127,7 @@ class Squat_Radar_Widget extends WP_Widget {
public static function instance_events_html($instance) {
$language = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : $instance['url']['keys']['language'];
$connector = new Squat_Radar_Connector();
- $data = $connector->events($instance['url']['keys']['facets'], $instance['fields'], $language, $instance['limit'], $instance['cache_expire'], TRUE );
+ $data = $connector->events($instance['url']['keys']['facets'], $instance['fields'], $language, $instance['limit'], $instance['cache_expire']);
$html = '';
foreach ($data['result'] as $id => $event) {
$output = apply_filters( 'squat_radar_format_event', $event, $instance['fields'], ['instance' => $instance] );
@@ -170,19 +139,6 @@ class Squat_Radar_Widget extends WP_Widget {
public function form( $instance ) {
- //
- // Introduction.
- //
- echo "
";
- echo __('If you want to display this single widget in a page or post use the Shortcode:') . ' ';
- if ( $this->number == '__i__' ) {
- echo '' . __( 'Shortcode will be available once you have saved this the first time') . '';
- }
- else {
- esc_attr_e( '[squat_radar_widget id="' . $this->number . '"]' );
- }
- echo "
' . __('A comma seperated list of field API names. Examples: phone, price, flyer, offline:address:thoroughfare. Some fields might need an additonal filter to format them properly. Can also be used instead of checkboxes to define the order fields are displayed in.') . '
';
+ echo '
' . __('A comma seperated list of field API names. Examples: phone, price, flyer, offline:address:thoroughfare. Some fields might need an additonal filter to format them properly.') . '
' . __('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.') . '
';
+ echo '
' . __('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.') . '