Commit cb7f94b5 authored by agnez's avatar agnez

partenaires url to be added p6

parent c1134245
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* /*
Plugin Name: GASAP post types Plugin Name: GASAP post types
Description: Plugin for the GASAP network, custom post types Description: Plugin for the GASAP network, custom post types
Author: Lore Mipsum Author: gggLore Mipsum
Text Domain: gasap-posttypes Text Domain: gasap-posttypes
Domain Path: /languages Domain Path: /languages
Version: 1.0 Version: 1.0
...@@ -41,7 +41,7 @@ function create_post_types() { ...@@ -41,7 +41,7 @@ function create_post_types() {
'show_ui' => true, 'show_ui' => true,
'exclude_from_search' => true, 'exclude_from_search' => true,
'hierarchical' => false, 'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), 'supports' => array( 'title', 'editor', 'excerpt', 'author' ),
'capability_type' => 'post', 'capability_type' => 'post',
'query_var' => true, 'query_var' => true,
'menu_position' => 7, 'menu_position' => 7,
...@@ -398,50 +398,71 @@ function gasap_add_usage_taxonomy() { ...@@ -398,50 +398,71 @@ function gasap_add_usage_taxonomy() {
/** /**
* METABOXES * METABOXES
*/ */
// ----- GASAP-details field
add_action( 'add_meta_boxes', 'gasap_details' ); /** Add metabox URL-partenaire. */
function gasap_details() { add_action( 'add_meta_boxes', 'partenaire_url_add_metabox' );
add_meta_box( function partenaire_url_add_metabox() {
'gasap_details', add_meta_box(
__( 'GASAP details', 'gasap-posttypes' ), 'url_partenaire',
'gasap_details_content', __( 'URL site', 'gasap-posttypes' ),
'gasap', 'partenaire_url_metabox_callback',
'partner',
'normal', 'normal',
'high' 'high'
); );
} }
// Outputs GASAP-details meta box
function gasap_details_content( $post ) { /** Print the metabox content. */
wp_nonce_field( plugin_basename( __FILE__ ), 'gasap_details_nonce' ); function partenaire_url_metabox_callback( $post ) {
$gasap_details_stored_meta = get_post_meta( $post->ID ); // Create a nonce field.
?> wp_nonce_field( 'partenaire_url_metabox', 'partenaire_url_metabox_nonce' );
</p> // Retrieve a previously saved value, if available.
<label for="gasap_mailreferent"><?php _e( 'Email referent:', 'gasap-posttypes' ) ?></label> $url = get_post_meta( $post->ID, '_partenaire_url', true );
<input type="text" id="gasap_mailreferent" name="gasap_mailreferent" value="<?php if ( isset ( $gasap_details_stored_meta['gasap_mailreferent'] ) ) echo $gasap_details_stored_meta['gasap_mailreferent'][0]; ?>" size="100%" /> // Create the metabox field mark-up.
</p> ?>
<?php <p>
<label>URL site partenaire</label><input style="width: 20em;" type="text" name="partenaire_url" value="<?php echo esc_url( $url ); ?>" size="30" class="regular-text" />
</p>
<?php
} }
// Save GASAP-details meta input
add_action( 'save_post', 'gasap_details_meta_save' ); /** Save the metabox. */
function gasap_details_meta_save( $post_id ) { add_action( 'save_post', 'partenaire_url_save_metabox' );
$is_autosave = wp_is_post_autosave( $post_id ); function partenaire_url_save_metabox( $post_id ) {
$is_revision = wp_is_post_revision( $post_id ); // Check if our nonce is set.
$is_valid_nonce = ( isset( $_POST[ 'gasap_details_nonce' ] ) && wp_verify_nonce( $_POST[ 'gasap_details_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false'; if ( ! isset( $_POST['partenaire_url_metabox_nonce'] ) ) {
if ( 'page' == $_POST['post_type'] ) { return;
if ( !current_user_can( 'edit_page', $post_id ) ) }
return; $nonce = $_POST['partenaire_url_metabox_nonce'];
} else { // Verify that the nonce is valid.
if ( !current_user_can( 'edit_post', $post_id ) ) if ( ! wp_verify_nonce( $nonce, 'partenaire_url_metabox' ) ) {
return; return;
} }
if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
return; // If this is an autosave, our form has not been submitted, so we don't want to do anything.
} if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
if( isset( $_POST[ 'gasap_mailreferent' ] ) ) { return;
update_post_meta( $post_id, 'gasap_mailreferent', sanitize_text_field( $_POST[ 'gasap_mailreferent' ] ) ); }
}
// Check the user's permissions.
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
// Check for and sanitize user input.
if ( ! isset( $_POST['partenaire_url'] ) ) {
return;
}
$url = esc_url_raw( $_POST['partenaire_url'] );
// Update the meta fields in the database, or clean up after ourselves.
if ( empty( $url ) ) {
delete_post_meta( $post_id, '_partenaire_url' );
} else {
update_post_meta( $post_id, '_partenaire_url', $url );
}
} }
// ----- end GASAP-details field
/** /**
* Hide meta boxes for specific capabilities * Hide meta boxes for specific capabilities
......
...@@ -126,7 +126,6 @@ function gasap_remove_capabilities() { ...@@ -126,7 +126,6 @@ function gasap_remove_capabilities() {
// hide from admin menu http://www.wpmayor.com/how-to-remove-menu-items-in-admin-depending-on-user-role/ // hide from admin menu http://www.wpmayor.com/how-to-remove-menu-items-in-admin-depending-on-user-role/
add_action( 'admin_init', 'gasap_remove_menu_pages' ); add_action( 'admin_init', 'gasap_remove_menu_pages' );
function gasap_remove_menu_pages() { function gasap_remove_menu_pages() {
global $user_ID; global $user_ID;
if ( current_user_can( 'author' ) ) { if ( current_user_can( 'author' ) ) {
...@@ -151,4 +150,17 @@ function remove_wp_nodes() ...@@ -151,4 +150,17 @@ function remove_wp_nodes()
$wp_admin_bar->remove_node( 'new-headerimage' ); $wp_admin_bar->remove_node( 'new-headerimage' );
$wp_admin_bar->remove_node( 'new-logolink' ); $wp_admin_bar->remove_node( 'new-logolink' );
} }
}
//rename role
add_action('init', 'change_role_name');
function change_role_name() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
//You can replace "administrator" with any other role "editor", "author", "contributor" or "subscriber"...
$wp_roles->roles['author']['name'] = 'Owner';
$wp_roles->role_names['author'] = 'Owner';
} }
\ No newline at end of file
...@@ -35,7 +35,7 @@ h2{ ...@@ -35,7 +35,7 @@ h2{
font-weight: bold; font-weight: bold;
} }
.uk-panel.uk-panel-box{ .uk-panel.uk-panel-box.gasap-panel-box{
text-align: center; text-align: center;
padding:0 1em; padding:0 1em;
background-color: white; background-color: white;
...@@ -229,7 +229,7 @@ main .uk-container{ ...@@ -229,7 +229,7 @@ main .uk-container{
.largeur3{ .largeur3{
max-width:535px; max-width:535px;
} }
.uk-panel.uk-panel-box{ .uk-panel.uk-panel-box.gasap-panel-box{
margin-bottom: 1em; margin-bottom: 1em;
} }
} }
......
...@@ -7,29 +7,25 @@ ...@@ -7,29 +7,25 @@
'order_by' => 'title' 'order_by' => 'title'
)); ?> )); ?>
<div class="uk-grid"><?php <div class="uk-grid"><?php
if($gasap->have_posts()){ ?> if($gasap->have_posts()){
<div class="uk-width-1-1 uk-width-medium-1-3"> while ( $gasap->have_posts() ) : $gasap->the_post();
<ul data-uk-switcher="{connect:'#les_gasap', animation: 'fade'}"> <?php global $post; ?>
while ( $gasap->have_posts() ) : $gasap->the_post(); <div class="uk-width-1-1 uk-width-medium-1-2">
global $post; ?> <div class="uk-panel uk-panel-box">
<li><a><?php echo get_the_title(); ?></a></li><?php <h3 class="uk-panel-title"><?php echo get_the_title(); ?></h3>
endwhile; ?>
</ul>
</div> <?php
$gasap->rewind_posts(); ?>
<div class="uk-width-1-1 uk-width-medium-2-3 uk-panel">
<ul id="les_gasap" class="uk-switcher"><?php
while ( $gasap->have_posts() ) : $gasap->the_post();
global $post; ?>
<li id="post-<?php the_ID(); ?>">
<h3><?php echo get_the_title(); ?></h3>
<?php the_content() ?> <?php the_content() ?>
<?php edit_post_link( esc_html__( 'Edit gasap', 'beans_gasap' ), '<span class="edit-link">', '</span>' ); ?> <!-- Contact form popup -->
<?php echo do_shortcode( '[contact-form-7 id="150" title="Contact form 1"]' ); ?> <button class="uk-button" data-uk-modal="{target:'#contac-gasap-form'}">Contacter ce GASAP</button>
</li><?php <div id="contac-gasap-form" class="uk-modal">
endwhile;?> <div class="uk-modal-dialog">
</ul> <a class="uk-modal-close uk-close"></a>
</div><?php <?php echo do_shortcode( '[contact-form-7 id="147" title="Contact form 1"]' ); ?>
</div>
</div>
<div><?php edit_post_link( esc_html__( 'Edit gasap', 'beans_gasap' ), '<span class="edit-link">', '</span>' ); ?></div>
</div>
</div><?php
endwhile;
}?> }?>
</div> </div>
</div> </div>
...@@ -37,4 +33,4 @@ ...@@ -37,4 +33,4 @@
<?php echo do_shortcode('[gmw_post_info]'); ?> <?php echo do_shortcode('[gmw_post_info]'); ?>
</div> </div>
</div> </div>
</section><?php </section>
\ No newline at end of file \ No newline at end of file
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
?><div class="uk-grid uk-grid-match"> <?php ?><div class="uk-grid uk-grid-match"> <?php
while ( $troisetapes->have_posts() ) : $troisetapes->the_post(); while ( $troisetapes->have_posts() ) : $troisetapes->the_post();
?><div class="uk-width-1 uk-width-medium-1-2"> ?><div class="uk-width-1 uk-width-medium-1-2">
<div class="uk-panel uk-panel-box uk-panel-box-secondary uk-panel-header"> <div class="uk-panel uk-panel-box uk-panel-box-secondary gasap-panel-box uk-panel-header">
<h3 class="uk-panel-title"><?php the_title(); ?></h3><?php <h3 class="uk-panel-title"><?php the_title(); ?></h3><?php
if ( has_post_thumbnail() ) { the_post_thumbnail(); } if ( has_post_thumbnail() ) { the_post_thumbnail(); }
?><div><?php the_content(); ?></div><?php ?><div><?php the_content(); ?></div><?php
......
...@@ -17,7 +17,7 @@ function gasap_enqueue_uikit_assets() { ...@@ -17,7 +17,7 @@ function gasap_enqueue_uikit_assets() {
// Enqueue uikit overwrite theme folder // Enqueue uikit overwrite theme folder
//beans_uikit_enqueue_theme( 'beans_gasap', get_stylesheet_directory_uri() . '/assets/less/uikit' ); //beans_uikit_enqueue_theme( 'beans_gasap', get_stylesheet_directory_uri() . '/assets/less/uikit' );
// Add the theme style as a uikit fragment to have access to all the variables // Add the theme style as a uikit fragment to have access to all the variables
beans_uikit_enqueue_components( array( 'switcher' ) ); beans_uikit_enqueue_components( array( 'switcher', 'modal' ) );
beans_uikit_enqueue_components( array( 'slider', 'slideshow' ), 'add-ons' ); beans_uikit_enqueue_components( array( 'slider', 'slideshow' ), 'add-ons' );
beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/assets/less/style.less', 'less' ); beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/assets/less/style.less', 'less' );
beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/assets/less/gasap.less', 'less' ); beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/assets/less/gasap.less', 'less' );
...@@ -65,30 +65,4 @@ add_filter( 'query_vars', 'gasap_prodlink_add_custom_query_var' ); ...@@ -65,30 +65,4 @@ add_filter( 'query_vars', 'gasap_prodlink_add_custom_query_var' );
function gasap_prodlink_add_custom_query_var( $vars ){ function gasap_prodlink_add_custom_query_var( $vars ){
$vars[] = "choix_prod"; //pour template part three_producers $vars[] = "choix_prod"; //pour template part three_producers
return $vars; return $vars;
} }
\ No newline at end of file
//TEST http://wordpress.stackexchange.com/questions/46581/visitors-contacting-authors
/*
* Usage: in contact form 7 form area add [author_email unique_name]
* and in to email address add [unique_name]
*/
add_action( 'wpcf7_init', 'gasap_custom_add_shortcode_email_referent' );
function gasap_custom_add_shortcode_email_referent() {
wpcf7_add_form_tag('author_email', 'wpcf7_expert_email_shortcode_handler', true);
}
function wpcf7_expert_email_shortcode_handler($tag) {
if (!is_array($tag)) return '';
$name = $tag['name'];
if (empty($name)) return '';
global $post;
$author_mail = get_the_author_meta('user_email',$post->post_author); //get author email:
$html = '<input type="hidden" name="' . $name . '" value="' . $author_mail . '" />';
return $html;
}
...@@ -69,7 +69,7 @@ function add_contentpieces_after_les_mangeurs() { ?> ...@@ -69,7 +69,7 @@ function add_contentpieces_after_les_mangeurs() { ?>
$comment = new WP_Query( array( 'post_type' => 'contentpiece','p' => 65) ); //FIX db entry $comment = new WP_Query( array( 'post_type' => 'contentpiece','p' => 65) ); //FIX db entry
$comment_images = new WP_Query( $args_comment_images ); $comment_images = new WP_Query( $args_comment_images );
while($comment->have_posts()) : $comment->the_post(); ?> while($comment->have_posts()) : $comment->the_post(); ?>
<div class="uk-panel uk-panel-box uk-panel-box-secondary uk-panel-header"> <div class="uk-panel uk-panel-box uk-panel-box-secondary gasap-panel-box uk-panel-header">
<h2 class="uk-panel-title"><?php the_title(); ?></h2> <h2 class="uk-panel-title"><?php the_title(); ?></h2>
<div class="textegauche"><?php the_content(); ?></div> <div class="textegauche"><?php the_content(); ?></div>
<?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<p class="edit-link">', '</p>' ); ?> <?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<p class="edit-link">', '</p>' ); ?>
......
...@@ -110,25 +110,19 @@ function add_contentpieces_after_lereaseau() { ?> ...@@ -110,25 +110,19 @@ function add_contentpieces_after_lereaseau() { ?>
<article id="snippet_partenaires" class="uk-slidenav-position" data-uk-slider="{center:true}"> <article id="snippet_partenaires" class="uk-slidenav-position" data-uk-slider="{center:true}">
<div class="uk-slider-container"> <div class="uk-slider-container">
<ul class="uk-slider uk-grid-width-medium-1-3 uk-grid-width-large-1-4"> <ul class="uk-slider uk-grid-width-medium-1-3 uk-grid-width-large-1-4"> <?php
<?php // logos défilants ?pieces? content = link title ? $argspartner = array(
$args = array( 'post_type' => 'partner',
'post_type' => 'contentpiece', 'order_by' => 'rand'
'orderby'=> 'title', );
'order' => 'ASC', $looppartner = new WP_Query( $argspartner );
'tax_query' => array( while ( $looppartner->have_posts() ) : $looppartner->the_post();
array( if ( has_post_thumbnail() ) { ?>
'category_name' => 'TODO'//create tag for partenaires <li><a href="" title="<?php the_title(); ?>" target="_blank"><?php the_post_thumbnail('medium'); ?></a></li><?php
) }
) endwhile;
); wp_reset_postdata();?>
$loop = new WP_Query( $args ); </ul>
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if ( has_post_thumbnail() ) {
?><li><?php the_post_thumbnail('full'); ?></li><?php
}?>
<?php endwhile;?>
</ul>TODO les partenaires
</div> </div>
<a href="" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous" data-uk-slider-item="previous"></a> <a href="" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous" data-uk-slider-item="previous"></a>
<a href="" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next" data-uk-slider-item="next"></a> <a href="" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next" data-uk-slider-item="next"></a>
...@@ -152,7 +146,7 @@ function add_contentpieces_after_lereaseau() { ?> ...@@ -152,7 +146,7 @@ function add_contentpieces_after_lereaseau() { ?>
?><div class="uk-grid uk-grid-match"> <?php ?><div class="uk-grid uk-grid-match"> <?php
while ( $contactprod->have_posts() ) : $contactprod->the_post(); while ( $contactprod->have_posts() ) : $contactprod->the_post();
?><div class="uk-width-1 uk-width-small-1-2"> ?><div class="uk-width-1 uk-width-small-1-2">
<div class="uk-panel uk-panel-box uk-panel-header"> <div class="uk-panel uk-panel-box gasap-panel-box uk-panel-header">
<h3 class="uk-panel-title"><?php the_title(); ?></h3><?php <h3 class="uk-panel-title"><?php the_title(); ?></h3><?php
if ( has_post_thumbnail() ) { the_post_thumbnail(); } if ( has_post_thumbnail() ) { the_post_thumbnail(); }
?><div><?php the_content(); ?></div><?php ?><div><?php the_content(); ?></div><?php
......
...@@ -33,7 +33,7 @@ function add_contentpieces_after_les_producteurs() { ?> ...@@ -33,7 +33,7 @@ function add_contentpieces_after_les_producteurs() { ?>
$comment = new WP_Query( array( 'post_type' => 'contentpiece','p' => 65) ); //FIX db entry $comment = new WP_Query( array( 'post_type' => 'contentpiece','p' => 65) ); //FIX db entry
$comment_images = new WP_Query( $args_comment_images ); $comment_images = new WP_Query( $args_comment_images );
while($comment->have_posts()) : $comment->the_post(); ?> while($comment->have_posts()) : $comment->the_post(); ?>
<div class="uk-panel uk-panel-box uk-panel-header"> <div class="uk-panel uk-panel-box gasap-panel-box uk-panel-header">
<h2 class="uk-panel-title"><?php the_title(); ?></h2> <h2 class="uk-panel-title"><?php the_title(); ?></h2>
<div class="textegauche"><?php the_content(); ?></div> <div class="textegauche"><?php the_content(); ?></div>
<?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<p class="edit-link">', '</p>' ); ?> <?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<p class="edit-link">', '</p>' ); ?>
......
...@@ -25,7 +25,7 @@ function page_contact_before() { ...@@ -25,7 +25,7 @@ function page_contact_before() {
?><div class="uk-grid uk-grid-match"> <?php ?><div class="uk-grid uk-grid-match"> <?php
while ( $contactprod->have_posts() ) : $contactprod->the_post(); while ( $contactprod->have_posts() ) : $contactprod->the_post();
?><div class="uk-width-1 uk-width-small-1-2"> ?><div class="uk-width-1 uk-width-small-1-2">
<div class="uk-panel uk-panel-box uk-panel-header"> <div class="uk-panel uk-panel-box gasap-panel-box uk-panel-header">
<h3 class="uk-panel-title"><?php the_title(); ?></h3><?php <h3 class="uk-panel-title"><?php the_title(); ?></h3><?php
if ( has_post_thumbnail() ) { the_post_thumbnail(); } if ( has_post_thumbnail() ) { the_post_thumbnail(); }
?><div><?php the_content(); ?></div><?php ?><div><?php the_content(); ?></div><?php
......
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