Commit 2bcf2829 authored by agnez's avatar agnez

flux rss pour rcr via plugin, page prod comment devenir

parent 422fd6e6
<?php
/**
* @package gasap-rssrcr
* @version 1.0
*/
/*
Plugin Name: GASAP RSS 4 RCR
Description: Plugin for the GASAP network, creating RSS feed with GASAPs for Réseau des consomateurs responsables
Author: Lore Mipsum
Text Domain: gasap-rssrcr
Domain Path: /languages
Version: 1.0
Author URI: http://mipsum.be/
*/
defined( 'ABSPATH' ) or die();
add_action( 'plugins_loaded', 'gasap_rssrcr_load_plugin_textdomain' );
function gasap_rssrcr_load_plugin_textdomain() {
load_plugin_textdomain( 'gasap-rssrcr', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action('init', 'gasap_custom_rss_init');
function gasap_custom_rss_init(){
add_feed('gasap2rcr', 'gasap_custom_rss');
}
/* Show the RSS Feed on domain.com/?feed=gasap2rcr or domain.com/feed/gasap2rcr. */
function gasap_custom_rss() {
global $post;
$posts = query_posts( array (
'post_type' => 'gasap',
'posts_per_page'=>-1,
'orderby' => 'title',
'order' => 'ASC' )
);
function get_gasap_details($id){
global $wpdb;
$table_name = $wpdb->prefix . 'places_locator';
$sql = "
SELECT *
FROM {$table_name}
WHERE post_ID = $id
";
$items = $wpdb->get_results($sql);
$prepared_statement = $wpdb->prepare( "SELECT %f,long,lat FROM {$table_name} WHERE post_ID = %d", $id );
$values = $wpdb->get_col( $prepared_statement );
foreach ($items as $item) {
$test = absint( $item->street_number );
$long = absint( $item->long );?>
<gasapcity><?php echo $item->city; ?></gasapcity>
<gasapstreet><?php echo $item->street; ?></gasapstreet>
<gasaplat><?php echo $item->lat; ?></gasaplat>
<gasaplong><?php echo $item->long; ?></gasaplong>
<?php
}
}
// Setting up content type and charset headers
header('Content-Type: '.feed_content_type('rss-http').';charset='.get_option('blog_charset'), true);
// Setting up valid XML encoding
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
?>
<!-- Declaring XML Validators namespaces -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
<?php do_action('rss2_ns'); ?>>
<!-- Declaring channel with articles data -->
<?php $dateTimeFormat = 'D, M d Y H:i:s'; ?>
<channel>
<title><?php _e( 'export GASAPs pour RCR', 'gasap-rssrcr' ); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss('description') ?></description>
<lastBuildDate><?php echo mysql2date($dateTimeFormat, get_lastpostmodified(), false); ?></lastBuildDate>
<language><?php echo get_option('rss_language'); ?></language>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'daily' ); ?></sy:updatePeriod>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency><?php
do_action('rss2_head');
if(have_posts()!=''){
while (have_posts()) : the_post(); ?>
<item>
<gasap id="<?php echo $post->ID; ?>"><?php the_title_rss(); ?></gasap>
<link><?php the_permalink_rss(); ?></link>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php get_gasap_details($post->ID); ?>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
</item><?php
endwhile;
}else {
echo 'no posts found';
} ?>
</channel>
</rss><?php
}?>
\ No newline at end of file
<?php /* Silence, so that search engines don't index/crawl this folder and it's contents */ ?>
\ No newline at end of file
# Copyright (C) 2017 GASAP RSS 4 RCR
# This file is distributed under the same license as the GASAP RSS 4 RCR package.
msgid ""
msgstr ""
"Project-Id-Version: GASAP RSS 4 RCR 1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/gasap-rssrcr\n"
"POT-Creation-Date: 2017-07-31 18:56+0200\n"
"PO-Revision-Date: 2017-07-31 18:57+0200\n"
"Last-Translator: Lore <lore@mipsum.be>\n"
"Language-Team: \n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.11\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: gasap-rssrcr.php:85
msgid "export GASAPs pour RCR"
msgstr "Export des fiches GASAP pour le RCR"
#. Plugin Name of the plugin/theme
msgid "GASAP RSS 4 RCR"
msgstr ""
#. Description of the plugin/theme
msgid ""
"Plugin for the GASAP network, creating RSS feed with GASAPs for Réseau des "
"consomateurs responsables"
msgstr ""
"Plugin pour le réseau GASAP et le Réseau des consommateurs responsables : "
"flux RSS pour exporter les fiches GASAP"
#. Author of the plugin/theme
msgid "Lore Mipsum"
msgstr ""
#. Author URI of the plugin/theme
msgid "http://mipsum.be/"
msgstr ""
# Copyright (C) 2017 GASAP RSS 4 RCR
# This file is distributed under the same license as the GASAP RSS 4 RCR package.
msgid ""
msgstr ""
"Project-Id-Version: GASAP RSS 4 RCR 1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/gasap-rssrcr\n"
"POT-Creation-Date: 2017-07-31 16:56:33+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#: gasap-rssrcr.php:85
msgid "export GASAPs pour RCR"
msgstr ""
#. Plugin Name of the plugin/theme
msgid "GASAP RSS 4 RCR"
msgstr ""
#. Description of the plugin/theme
msgid ""
"Plugin for the GASAP network, creating RSS feed with GASAPs for Réseau des "
"consomateurs responsables"
msgstr ""
#. Author of the plugin/theme
msgid "Lore Mipsum"
msgstr ""
#. Author URI of the plugin/theme
msgid "http://mipsum.be/"
msgstr ""
......@@ -235,6 +235,20 @@ main .uk-container{
border: none;
height: 40px;
}
}#snippet_comment_devenir_prod /*p8*/{
color: @global-muted-color;
.uk-grid{
background: url(images/bg_devenir_prod.png) center 65px no-repeat transparent;
.uk-width-medium-1-3{
padding-top: 2em;
}
}
.content{
width: 200px;
margin: 0 auto;
font-size: small;
padding-top: 1em;
}
}
#snippet_reseau_pourquoi,/*p6*/
#snippet_les_engagements /*p12*/{
......@@ -664,6 +678,11 @@ main .uk-container.credits{
.serrer{
width: 100%;
}
#snippet_comment_devenir_prod /*p8*/{
.uk-grid{
background: none;
}
}
}
@media (max-width: @bp-medium-max) {
#snippet_presse{
......
......@@ -140,7 +140,7 @@ function add_contentpieces_after_lereaseau() { ?>
<?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<p class="edit-link">', '</p>' ); ?>
<?php endwhile;
wp_reset_postdata();?>
<a class="uk-button uk-button-success" href="mailto:coordination@gasap.be"><?php esc_html_e( 'Dévenir bénévole', 'beans_gasap' ); ?></a>
<a class="uk-button uk-button-success" href="mailto:benevoles@gasap.be"><?php esc_html_e( 'Dévenir bénévole', 'beans_gasap' ); ?></a>
</div></div>
</article>
......
......@@ -111,7 +111,7 @@ function add_contentpieces_after_les_producteurs() {
$engagement = new WP_Query( array( 'post_type' => 'contentpiece','p' => 108) ); //FIX db entry
while($engagement->have_posts()) : $engagement->the_post(); ?>
<h3><?php the_title(); ?></h3>
<div class="largeur2"><?php the_content(); ?></div><?php
<div><?php the_content(); ?></div><?php
endwhile;
wp_reset_postdata();
$argslesengagements = array(
......@@ -139,7 +139,39 @@ function add_contentpieces_after_les_producteurs() {
wp_reset_postdata();?>
</div>
</div></article>
Comment devenir producteur pour les GASAP ?
<article id="snippet_comment_devenir_prod"><div class="largeur1 uk-text-center"><?php
$engagement = new WP_Query( array( 'post_type' => 'contentpiece','p' => 1022) ); //FIX db entry
while($engagement->have_posts()) : $engagement->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div><?php the_content(); ?></div><?php
endwhile;
wp_reset_postdata();
$argscommentdevenirprod = array(
'post_type' => 'contentpiece',
'orderby'=> 'date',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'contentpiecetype',
'field' => 'term_id',
'terms' => 96 //FIX db entry
)
)
);
$commentdevenirprod = new WP_Query( $argscommentdevenirprod );
?><div class="uk-grid"> <?php
while ( $commentdevenirprod->have_posts() ) : $commentdevenirprod->the_post();
?><div class="uk-width-medium-1-3">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail('thumbnail'); } ?>
<div class="content"><?php the_content(); ?></div>
<?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<span class="edit-link">', '</span>' );?>
</div><?php
endwhile;
wp_reset_postdata();?>
</div>
</div></article>
<?php
include (get_stylesheet_directory() . '/assets/template_parts/map_prod.php');
//include (get_stylesheet_directory() . '/assets/template_parts/three_producers.php');
......
<?php
/**
* RSS2 Feed Template for displaying RSS2 Posts feed.
*
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
/**
* Fires between the xml and rss tags in a feed.
*
* @since 4.0.0
*
* @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments',
* 'rdf', 'atom', and 'atom-comments'.
*/
do_action( 'rss_tag_pre', 'rss2' );
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
<?php
/**
* Fires at the end of the RSS root to add namespaces.
*
* @since 2.0.0
*/
do_action( 'rss2_ns' );
?>
>
<channel>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php bloginfo_rss('url') ?></link>
<?php while ( have_posts() ) : the_post();
$content = get_the_content();
$content = apply_filters('the_content', $content);?>
<title><?php the_title(); ?></title>
<description><?php echo $content; ?></description>
<?php endwhile; ?>
<lastBuildDate><?php
$date = get_lastpostmodified( 'GMT' );
echo $date ? mysql2date( 'D, d M Y H:i:s +0000', $date, false ) : date( 'D, d M Y H:i:s +0000' );
?></lastBuildDate>
<language><?php bloginfo_rss( 'language' ); ?></language>
<sy:updatePeriod><?php
$duration = 'hourly';
/**
* Filters how often to update the RSS feed.
*
* @since 2.1.0
*
* @param string $duration The update period. Accepts 'hourly', 'daily', 'weekly', 'monthly',
* 'yearly'. Default 'hourly'.
*/
echo apply_filters( 'rss_update_period', $duration );
?></sy:updatePeriod>
<sy:updateFrequency><?php
$frequency = '1';
/**
* Filters the RSS update frequency.
*
* @since 2.1.0
*
* @param string $frequency An integer passed as a string representing the frequency
* of RSS updates within the update period. Default '1'.
*/
echo apply_filters( 'rss_update_frequency', $frequency );
?></sy:updateFrequency>
<?php
/**
* Fires at the end of the RSS2 Feed Header.
*
* @since 2.0.0
*/
do_action( 'rss2_head');
$args = array ( 'post_type' => 'gasap', 'posts_per_page'=>-1 );
query_posts( $args );
function get_gasap_details($id){
global $wpdb;
$table_name = $wpdb->prefix . 'places_locator';
$sql = "
SELECT long,street_number,city,street
FROM {$table_name}
WHERE post_ID = $id
";
$items = $wpdb->get_results($sql);
$prepared_statement = $wpdb->prepare( "SELECT %f,long,lat FROM {$table_name} WHERE post_ID = %d", $id );
$values = $wpdb->get_col( $prepared_statement );
foreach ($items as $item) {
$test = absint( $item->street_number );
$long = absint( $item->long );?>
<gasapcity><?php echo $item->city; ?></gasapcity>
<gasaplat><?php echo $item->street; ?></gasaplat>
<gasaptest><?php echo $test; ?></gasaptest>
<gasaplong><?php // echo $long; ?></gasaplong>
<?php
}
}
while( have_posts()) : the_post();
$terms = wp_get_post_terms( $post->ID, 'gasapstatus' ); ?>
<item>
<gasap id="<?php echo $post->ID; ?>">
<gasapname><?php the_title_rss() ?></gasapname>
<gasapurl><?php the_permalink_rss() ?></gasapurl>
<gasapstatus><?php echo $terms[0]->name; ?></gasapstatus>
<?php get_gasap_details($post->ID); ?>
</gasap>
</item>
<?php endwhile; ?>
</channel>
</rss>
......@@ -14,7 +14,7 @@ function add_atend_gasapsingle($content) {
elseif ($terms[0]->slug == 'complet') {
echo '<div><b>'.esc_html__( 'Ce GASAP est complet et ne peux pas être contacté via notre site.', 'beans_gasap' ).'</b></div>';
}
echo '<hr /><h4><a href="/les-mangeurs#snippet_la_carte">'.esc_html__( 'Tous les GASAP', 'beans_gasap' ).'</a></h4>';
echo '<hr /><h4><a href="/les-mangeurs#snippet_la_carte">'.esc_html__( 'Vers tous les GASAP', 'beans_gasap' ).'</a></h4>';
}
add_action( 'beans_post_after_markup', 'add_after_gasapsingle' );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment