forked from lino/radar-wp
First alpha: working style, dynamic sidebars, part tested cron.
This commit is contained in:
parent
a6f657092d
commit
2342ebb052
6 changed files with 81 additions and 77 deletions
|
@ -29,7 +29,15 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.squat-radar .squat-radar-datetime::before {
|
.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: '';
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
float: none;
|
float: none;
|
||||||
|
@ -38,6 +46,15 @@
|
||||||
|
|
||||||
.squat-radar .squat-radar-list li {
|
.squat-radar .squat-radar-list li {
|
||||||
display: inline;
|
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 {
|
.squat-radar a.squat-radar-url-more {
|
||||||
|
|
|
@ -18,6 +18,7 @@ jQuery(function($){
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$(widget).empty();
|
||||||
$(widget).append(result.html);
|
$(widget).append(result.html);
|
||||||
// $(".squat-li a").on('click', function(e){
|
// $(".squat-li a").on('click', function(e){
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,8 @@ class Squat_Radar_Connector {
|
||||||
}
|
}
|
||||||
|
|
||||||
function events( $facets, $fields = [], $language = NULL, $limit = 10, $expiration = 10800, $reset = FALSE ) {
|
function events( $facets, $fields = [], $language = NULL, $limit = 10, $expiration = 10800, $reset = FALSE ) {
|
||||||
$fields = array_merge($fields, ['uuid', 'title', 'url', 'event_status']);
|
// Fields we often want to get data out of but not necessarily are chosen to be shown.
|
||||||
|
$fields = array_merge($fields, ['uuid', 'title', 'body:value', 'url', 'event_status']);
|
||||||
$transient_key = 'squat_radar_events_' . sha1(implode($facets) . implode($fields) . $language . $limit);
|
$transient_key = 'squat_radar_events_' . sha1(implode($facets) . implode($fields) . $language . $limit);
|
||||||
if (! $reset && $data = get_transient( $transient_key )) {
|
if (! $reset && $data = get_transient( $transient_key )) {
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Squat_Radar_Formatter {
|
||||||
add_filter('squat_radar_field_html', [__CLASS__, 'field_date_html'], 5, 4);
|
add_filter('squat_radar_field_html', [__CLASS__, 'field_date_html'], 5, 4);
|
||||||
add_filter('squat_radar_field_html', [__CLASS__, 'field_location_html'], 5, 4);
|
add_filter('squat_radar_field_html', [__CLASS__, 'field_location_html'], 5, 4);
|
||||||
add_filter('squat_radar_field_html', [__CLASS__, 'field_link_html'], 5, 4);
|
add_filter('squat_radar_field_html', [__CLASS__, 'field_link_html'], 5, 4);
|
||||||
|
add_filter('squat_radar_field_html', [__CLASS__, 'field_summary_html'], 5, 4);
|
||||||
// Field 'url' was already turned into a <a> link, by field_link_html.
|
// Field 'url' was already turned into a <a> link, by field_link_html.
|
||||||
// The field_image_html is an example of an override with more specificity.
|
// The field_image_html is an example of an override with more specificity.
|
||||||
add_filter('squat_radar_field_html', [__CLASS__, 'field_image_html'], 7, 4);
|
add_filter('squat_radar_field_html', [__CLASS__, 'field_image_html'], 7, 4);
|
||||||
|
@ -76,26 +77,26 @@ class Squat_Radar_Formatter {
|
||||||
// There can only be one date. With repeat etc. but just one.
|
// There can only be one date. With repeat etc. but just one.
|
||||||
// Repeating events will appear as a new item for each repeat in the feed.
|
// Repeating events will appear as a new item for each repeat in the feed.
|
||||||
$value = $value[0];
|
$value = $value[0];
|
||||||
$output = '<span class="squat-radar-event-start-end">';
|
$output = '<span class="squat-radar-event-start-end">';
|
||||||
$output .= self::field_date_format( $value['time_start'], 'start' );
|
$output .= self::field_date_format( $value['time_start'], 'start' );
|
||||||
if ($value['time_start'] != $value['time_end']) {
|
if ($value['time_start'] != $value['time_end']) {
|
||||||
$time_only = ( substr($value['time_start'], 0, 10) == substr($value['time_end'], 0, 10) );
|
$time_only = ( substr($value['time_start'], 0, 10) == substr($value['time_end'], 0, 10) );
|
||||||
$output .= self::field_date_format( $value['time_end'], 'end', $time_only );
|
$output .= ' - ' . self::field_date_format( $value['time_end'], 'end', $time_only );
|
||||||
}
|
}
|
||||||
$output .= '</span>';
|
$output .= '</span>';
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
case 'time_start':
|
case 'time_start':
|
||||||
|
$value = $value[0];
|
||||||
$output = '<span class="squat-radar-event-start">';
|
$output = '<span class="squat-radar-event-start">';
|
||||||
$output .= self::field_date_format($value, 'start');
|
$output .= self::field_date_format($value, 'start');
|
||||||
$output .= '</span>';
|
$output .= '</span>';
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
case 'time_end':
|
case 'time_end':
|
||||||
|
$value = $value[0];
|
||||||
$output = '<span class="squat-radar-event-start">';
|
$output = '<span class="squat-radar-event-end">';
|
||||||
$output .= self::field_date_format($value, 'start');
|
$output .= self::field_date_format($value, 'end');
|
||||||
$output .= '</span>';
|
$output .= '</span>';
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
|
@ -150,16 +151,16 @@ class Squat_Radar_Formatter {
|
||||||
* }
|
* }
|
||||||
* ]
|
* ]
|
||||||
*/
|
*/
|
||||||
function field_location_html($value, $original, $field, $context) {
|
static public function field_location_html($value, $original, $field, $context) {
|
||||||
switch ($field[0]) {
|
switch ($field[0]) {
|
||||||
case 'map':
|
case 'map':
|
||||||
$output = [];
|
$output = [];
|
||||||
foreach ($value as $map) {
|
foreach ($value as $map) {
|
||||||
if ( is_array($map) && $map['lat'] !== NULL && $map['lon'] !== NULL ) {
|
if ( is_array($map) && ! empty($map['lat']) && $map['lat'] !== NULL && $map['lon'] !== NULL ) {
|
||||||
$this_output = '<span class="squat-radar-location squat-radar-location-map-link">';
|
$this_output = '<span class="squat-radar-location squat-radar-location-map-link">';
|
||||||
$lat = $map['lat'];
|
$lat = $map['lat'];
|
||||||
$lon = $map['lon'];
|
$lon = $map['lon'];
|
||||||
$this_output .= "<a href=\"https://www.openstreetmap.org/?mlat=$lat&mlon=$lon#map=14/$lat/$lon\">";
|
$this_output .= "<a href=\"https://www.openstreetmap.org/?mlat=$lat&mlon=$lon#map=14/$lat/$lon\" target=\"_blank\">";
|
||||||
$this_output .= __('[Map]', 'squat-radar');
|
$this_output .= __('[Map]', 'squat-radar');
|
||||||
$this_output .= '</a></span>';
|
$this_output .= '</a></span>';
|
||||||
$output[] = $this_output;
|
$output[] = $this_output;
|
||||||
|
@ -196,7 +197,7 @@ class Squat_Radar_Formatter {
|
||||||
/**
|
/**
|
||||||
* Item Radar links implementation of 'squat_radar_field_html' filter.
|
* Item Radar links implementation of 'squat_radar_field_html' filter.
|
||||||
*/
|
*/
|
||||||
function field_link_html($value, $original, $field, $context) {
|
static public function field_link_html($value, $original, $field, $context) {
|
||||||
if ( ($field[0] == 'title' || $field[0] == 'title_field') && ! empty($context['event']['url'])) {
|
if ( ($field[0] == 'title' || $field[0] == 'title_field') && ! empty($context['event']['url'])) {
|
||||||
return '<a href="' . esc_url($context['event']['url']) . '" class="squat-radar-url squat-radar-url-title">' . sanitize_text_field( $value ) . '</a>';
|
return '<a href="' . esc_url($context['event']['url']) . '" class="squat-radar-url squat-radar-url-title">' . sanitize_text_field( $value ) . '</a>';
|
||||||
}
|
}
|
||||||
|
@ -230,13 +231,40 @@ class Squat_Radar_Formatter {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item Radar summary implementation of 'squat_radar_field_html' filter.
|
||||||
|
*/
|
||||||
|
static public function field_summary_html($value, $original, $field, $context) {
|
||||||
|
if ( $field[0] == 'summary' ) {
|
||||||
|
// Summary is only populated if there is an explict summary.
|
||||||
|
if ( empty( trim($value) ) ) {
|
||||||
|
array_shift($field);
|
||||||
|
if (is_array($field)) {
|
||||||
|
$field_tree = array_reverse($field);
|
||||||
|
$sibling_fields = self::getValue($context['event'], $field_tree);
|
||||||
|
$value = print_r($context['event'], true);
|
||||||
|
if (! empty( $sibling_fields['value'] ) ) {
|
||||||
|
$value = wp_trim_words( $sibling_fields['value'], 30 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty($value) ) {
|
||||||
|
$value = '<span class="squat-radar-body-summary">' . wp_kses_post( $value ) . '</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format image implementation of 'squat_radar_field_html' filter.
|
* Format image implementation of 'squat_radar_field_html' filter.
|
||||||
*
|
*
|
||||||
* Deliberatly run after field_link_html. Showing how to override an existing filter.
|
* Deliberatly run after field_link_html. Showing how to override an existing filter.
|
||||||
* image:file:url
|
* image:file:url
|
||||||
*/
|
*/
|
||||||
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 ($field[0] == 'url' && $field[1] == 'file' && $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" \>';
|
||||||
}
|
}
|
||||||
|
@ -261,7 +289,7 @@ class Squat_Radar_Formatter {
|
||||||
* @return string
|
* @return string
|
||||||
* Flattend array with additional default classes.
|
* Flattend array with additional default classes.
|
||||||
*/
|
*/
|
||||||
function field_html($value, $original, $field, $context) {
|
static public function field_html($value, $original, $field, $context) {
|
||||||
if ($value != $original) {
|
if ($value != $original) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +334,7 @@ class Squat_Radar_Formatter {
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$value = '<span class="squat-radar-' . sanitize_html_class($field[0]) . '">' . $value . '</span>';
|
$value = '<span class="squat-radar-' . sanitize_html_class($field[0]) . '">' . wp_kses_post( $value ) . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -315,8 +343,8 @@ class Squat_Radar_Formatter {
|
||||||
/**
|
/**
|
||||||
* Title field HTML implentation of 'squat_radar_field_html' filter.
|
* Title field HTML implentation of 'squat_radar_field_html' filter.
|
||||||
*/
|
*/
|
||||||
function field_title_html($value, $original, $field, $context) {
|
static public function field_title_html($value, $original, $field, $context) {
|
||||||
if ($field[0] == 'title' && count($field) == 1) {
|
if (($field[0] == 'title' || $field[0] == 'title_field') && count($field) == 1) {
|
||||||
$value = '<h3 class="squat-radar-title">' . $value . '</h3>';
|
$value = '<h3 class="squat-radar-title">' . $value . '</h3>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Squat_Radar_Instance {
|
||||||
|
|
||||||
register_sidebar([
|
register_sidebar([
|
||||||
'name' => __( 'Squat Radar Shortcodes'),
|
'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',
|
'id' => 'squat_radar_widget_shortcode',
|
||||||
'before_widget' => '<div class="widget %2$s">',
|
'before_widget' => '<div class="widget %2$s">',
|
||||||
'after_widget' => '</div>',
|
'after_widget' => '</div>',
|
||||||
|
|
|
@ -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_squat_radar_events', [__CLASS__, 'ajax_callback'] );
|
||||||
add_action( 'wp_ajax_nopriv_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_scripts', [__CLASS__, 'widget_script'] );
|
||||||
add_action( 'wp_enqueue_style', [__CLASS__, 'widget_style'] );
|
add_action( 'wp_enqueue_scripts', [__CLASS__, 'widget_style'] );
|
||||||
|
|
||||||
add_shortcode( 'squat_radar_widget', [__CLASS__, 'shortcode' ] );
|
|
||||||
|
|
||||||
add_action( 'squat_radar_widget_cache_cron', [__CLASS__, 'cache_cron'] );
|
add_action( 'squat_radar_widget_cache_cron', [__CLASS__, 'cache_cron'] );
|
||||||
add_option( 'squat_radar_widget_cron_run', []);
|
add_option( 'squat_radar_widget_cron_run', []);
|
||||||
|
@ -32,44 +30,13 @@ class Squat_Radar_Widget extends WP_Widget {
|
||||||
|
|
||||||
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' );
|
||||||
}
|
}
|
||||||
|
|
||||||
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'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 = '<span class="error">' . __('Squat Radar Widget shortcode ID not recognised. Check the suggestion at the top of the widget in the adminstration interface.', 'squat-radar') . '</span>';
|
|
||||||
}
|
|
||||||
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() {
|
public static function cache_cron() {
|
||||||
$now = time();
|
$now = time();
|
||||||
$last_run = get_option('squat_radar_widget_cron_run', []);
|
$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) {
|
protected static function cache_refresh($instance) {
|
||||||
$connector = new Squat_Radar_Connector();
|
$connector = new Squat_Radar_Connector();
|
||||||
|
|
||||||
// @todo Languages...
|
$languages = apply_filters( 'wpml_active_languages', NULL);
|
||||||
try {
|
$languages = array_merge($instance['url']['keys']['language'], (array) $languages);
|
||||||
$data = $connector->events($instance['url']['keys']['facets'], $instance['fields'], $language, $instance['limit'], 0, TRUE );
|
foreach ($languages as $language) {
|
||||||
}
|
try {
|
||||||
catch ( Squat_Radar_Connector_Exception $e ) {
|
$data = $connector->events($instance['url']['keys']['facets'], $instance['fields'], $language, $instance['limit'], 0, TRUE );
|
||||||
return FALSE;
|
}
|
||||||
|
catch ( Squat_Radar_Connector_Exception $e ) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -99,7 +69,6 @@ class Squat_Radar_Widget extends WP_Widget {
|
||||||
|
|
||||||
|
|
||||||
public function widget( $args, $instance ) {
|
public function widget( $args, $instance ) {
|
||||||
wp_enqueue_style( 'squat-radar-widget' );
|
|
||||||
$widget_id = 'squat_radar_widget_' . $this->number;
|
$widget_id = 'squat_radar_widget_' . $this->number;
|
||||||
|
|
||||||
echo $args['before_widget'];
|
echo $args['before_widget'];
|
||||||
|
@ -158,7 +127,7 @@ class Squat_Radar_Widget extends WP_Widget {
|
||||||
public static function instance_events_html($instance) {
|
public static function instance_events_html($instance) {
|
||||||
$language = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : $instance['url']['keys']['language'];
|
$language = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : $instance['url']['keys']['language'];
|
||||||
$connector = new Squat_Radar_Connector();
|
$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 = '';
|
$html = '';
|
||||||
foreach ($data['result'] as $id => $event) {
|
foreach ($data['result'] as $id => $event) {
|
||||||
$output = apply_filters( 'squat_radar_format_event', $event, $instance['fields'], ['instance' => $instance] );
|
$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 ) {
|
public function form( $instance ) {
|
||||||
|
|
||||||
//
|
|
||||||
// Introduction.
|
|
||||||
//
|
|
||||||
echo "<p>";
|
|
||||||
echo __('If you want to display this single widget in a page or post use the Shortcode:') . ' ';
|
|
||||||
if ( $this->number == '__i__' ) {
|
|
||||||
echo '<em>' . __( 'Shortcode will be available once you have saved this the first time') . '</em>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
esc_attr_e( '[squat_radar_widget id="' . $this->number . '"]' );
|
|
||||||
}
|
|
||||||
echo "</p>";
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Title.
|
// Title.
|
||||||
//
|
//
|
||||||
|
@ -279,7 +235,7 @@ class Squat_Radar_Widget extends WP_Widget {
|
||||||
echo "<label for=\"$field_id\">$field_label</label>";
|
echo "<label for=\"$field_id\">$field_label</label>";
|
||||||
echo "<input class=\"$field_class\" id=\"$field_id\" name=\"$field_name\" type=\"text\" value=\"$field_value\">";
|
echo "<input class=\"$field_class\" id=\"$field_id\" name=\"$field_name\" type=\"text\" value=\"$field_value\">";
|
||||||
echo "</p>";
|
echo "</p>";
|
||||||
echo '<div class="description">' . __('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.') . '</div>';
|
echo '<div class="description">' . __('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.') . '</div>';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cache expiry.
|
// Cache expiry.
|
||||||
|
@ -306,7 +262,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">' . __('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">' . __('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 '</fieldset>';
|
echo '</fieldset>';
|
||||||
|
|
||||||
|
@ -369,7 +325,7 @@ class Squat_Radar_Widget extends WP_Widget {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$options['use_cron'] = TRUE;
|
$options['use_cron'] = TRUE;
|
||||||
cache_refresh($options);
|
self::cache_refresh($options);
|
||||||
if ( ! wp_next_scheduled( 'squat_radar_widget_cache_cron' ) ) {
|
if ( ! wp_next_scheduled( 'squat_radar_widget_cache_cron' ) ) {
|
||||||
wp_schedule_event( time() + $options['cache_expire'], 'hourly', 'squat_radar_widget_cache_cron');
|
wp_schedule_event( time() + $options['cache_expire'], 'hourly', 'squat_radar_widget_cache_cron');
|
||||||
}
|
}
|
||||||
|
@ -385,6 +341,7 @@ class Squat_Radar_Widget extends WP_Widget {
|
||||||
'date_time' => __( 'Date and Time (start and optional end)' ),
|
'date_time' => __( 'Date and Time (start and optional end)' ),
|
||||||
'date_time:time_start' => __( 'Date and Time (start only)' ),
|
'date_time:time_start' => __( 'Date and Time (start only)' ),
|
||||||
'body' => __( 'Body' ),
|
'body' => __( 'Body' ),
|
||||||
|
'body:summary' => __( 'Body (teaser, summary)' ),
|
||||||
'category' => __( 'Categories' ),
|
'category' => __( 'Categories' ),
|
||||||
'topic' => __( 'Tags' ),
|
'topic' => __( 'Tags' ),
|
||||||
'offline:address' => __( 'Address' ),
|
'offline:address' => __( 'Address' ),
|
||||||
|
|
Loading…
Reference in a new issue