__( "Ce widget vous permet d'afficher la liste de vos derniers résultats", 'agenda-running' )
);
parent::__construct(
'AgendaRunningResultats', //base id
__( 'AgendaRunning - Résultats', 'agenda-running' ), //title
$widget_ops
);
}
/**
* Displaying the widget on the back-end
* @param array $instance An instance of the widget
*/
public function form( $instance ) {
$widget_defaults = array(
'title' => 'Résultats',
'number_events' => 5
);
$title = esc_attr($instance['title']);
$affichage = esc_attr($instance['affichage']);
$css = esc_attr($instance['css']);
$instance = wp_parse_args( (array) $instance, $widget_defaults );
?>
";
echo $args['before_title'];
echo apply_filters('widget_title', $instance['title']);
echo $args['after_title'];
$affichage = $instance['affichage'];
echo "";
if(!$affichage)
$affichage = "{TITRE} ({DISTANCE})
{LIEU} - {DATE}
{CHRONO}";
//Preparing the query for events
$meta_quer_args = array(
'relation' => 'AND',
array(
'key' => 'event-date',
'value' => time(),
'compare' => '<'
)
);
$query_args = array(
'post_type' => 'agenda-running',
'posts_per_page' => isset($instance['number_events']) ? $instance['number_events'] : 5,
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'meta_key' => 'event-date',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_query' => $meta_quer_args
);
$AgendaRunning = new WP_Query( $query_args );
while( $AgendaRunning->have_posts() ): $AgendaRunning->the_post();
$data['title'] = get_the_title();
$data['date'] = get_post_meta( get_the_ID(), 'event-date', true );
$data['lieu'] = get_post_meta( get_the_ID(), 'event-lieu', true );
$data['type'] = get_post_meta( get_the_ID(), 'event-type', true );
$data['distance'] = get_post_meta( get_the_ID(), 'event-distance', true );
$data['url'] = get_post_meta( get_the_ID(), 'event-url', true );
$data['chrono'] = get_post_meta( get_the_ID(), 'event-chrono', true );
$data['image'] = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
$html = get_infos_html($affichage, $data);
echo "".$html."
";
endwhile;
wp_reset_query();
echo "";
echo $after_widget;
}
}
class AgendaRunningNEXT extends WP_Widget {
/**
* Initializing the widget
*/
public function __construct() {
$widget_ops = array(
'description' => __( "Ce widget vous permet d'afficher la liste de vos prochaines courses", 'agenda-running' )
);
parent::__construct(
'AgendaRunningAgenda', //base id
__( 'AgendaRunning - Agenda', 'agenda-running' ), //title
$widget_ops
);
}
/**
* Displaying the widget on the back-end
* @param array $instance An instance of the widget
*/
public function form( $instance ) {
$widget_defaults = array(
'title' => 'Agenda',
'number_events' => 5
);
$title = esc_attr($instance['title']);
$affichage = esc_attr($instance['affichage']);
$css = esc_attr($instance['css']);
$instance = wp_parse_args( (array) $instance, $widget_defaults );
?>
";
echo $args['before_title'];
echo apply_filters('widget_title', $instance['title']);
echo $args['after_title'];
$affichage = $instance['affichage'];
echo "";
if(!$affichage)
$affichage = "{TITRE} {DATE}
{DISTANCE} - {LIEU}";
//Preparing the query for events
$meta_quer_args = array(
'relation' => 'AND',
array(
'key' => 'event-date',
'value' => time(),
'compare' => '>='
)
);
$query_args = array(
'post_type' => 'agenda-running',
'posts_per_page' => isset($instance['number_events']) ? $instance['number_events'] : 5,
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'meta_key' => 'event-date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => $meta_quer_args
);
$AgendaRunning = new WP_Query( $query_args );
while( $AgendaRunning->have_posts() ): $AgendaRunning->the_post();
$data['title'] = get_the_title();
$data['date'] = get_post_meta( get_the_ID(), 'event-date', true );
$data['lieu'] = get_post_meta( get_the_ID(), 'event-lieu', true );
$data['type'] = get_post_meta( get_the_ID(), 'event-type', true );
$data['distance'] = get_post_meta( get_the_ID(), 'event-distance', true );
$data['url'] = get_post_meta( get_the_ID(), 'event-url', true );
$data['chrono'] = get_post_meta( get_the_ID(), 'event-chrono', true );
$data['image'] = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
$html = get_infos_html($affichage, $data);
echo "".$html."
";
endwhile;
wp_reset_query();
echo "";
echo $after_widget;
}
}
class AgendaRunningRP extends WP_Widget {
/**
* Initializing the widget
*/
public function __construct() {
$widget_ops = array(
'description' => __( "Ce widget vous permet d'afficher la liste de vos records personnel", 'agenda-running' )
);
parent::__construct(
'AgendaRunningRP', //base id
__( 'AgendaRunning - Records Personnel', 'agenda-running' ), //title
$widget_ops
);
}
/**
* Displaying the widget on the back-end
* @param array $instance An instance of the widget
*/
public function form( $instance ) {
$widget_defaults = array(
'title' => 'Records Personnel'
);
$title = esc_attr($instance['title']);
$affichage = esc_attr($instance['affichage']);
$css = esc_attr($instance['css']);
$instance = wp_parse_args( (array) $instance, $widget_defaults );
?>
";
echo $args['before_title'];
echo apply_filters('widget_title', $instance['title']);
echo $args['after_title'];
$affichage = $instance['affichage'];
echo "";
if(!$affichage)
$affichage = "{TYPE} : {CHRONO}";
$rps = array("5k","10k","15k","semimarathon","marathon","100k");
//Preparing the query for events
foreach($rps as $rp){
$meta_quer_args = array(
'relation' => 'AND',
array(
'key' => 'event-type',
'value' => $rp,
'compare' => '='
),
array(
'key' => 'event-chrono',
'value' => '',
'compare' => '!='
)
);
$query_args = array(
'post_type' => 'agenda-running',
'posts_per_page' => 1,
'post_status' => 'publish',
'ignore_sticky_posts' => false,
'meta_key' => 'event-chrono',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => $meta_quer_args
);
$AgendaRunning = new WP_Query( $query_args );
while( $AgendaRunning->have_posts() ): $AgendaRunning->the_post();
$data['title'] = get_the_title();
$data['date'] = get_post_meta( get_the_ID(), 'event-date', true );
$data['lieu'] = get_post_meta( get_the_ID(), 'event-lieu', true );
$data['type'] = get_post_meta( get_the_ID(), 'event-type', true );
$data['distance'] = get_post_meta( get_the_ID(), 'event-distance', true );
$data['url'] = get_post_meta( get_the_ID(), 'event-url', true );
$data['chrono'] = get_post_meta( get_the_ID(), 'event-chrono', true );
$data['image'] = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' );
$html = get_infos_html($affichage, $data);
echo "".$html."
";
endwhile;
wp_reset_query();
}
echo "";
echo $after_widget;
}
}
function AgendaRunning_lists_widget() {
register_widget( 'AgendaRunningPAST' );
register_widget( 'AgendaRunningNEXT' );
register_widget( 'AgendaRunningRP' );
}
add_action( 'widgets_init', 'AgendaRunning_lists_widget' );