Commit cb7f94b5 authored by agnez's avatar agnez

partenaires url to be added p6

parent c1134245
......@@ -6,7 +6,7 @@
/*
Plugin Name: GASAP post types
Description: Plugin for the GASAP network, custom post types
Author: Lore Mipsum
Author: gggLore Mipsum
Text Domain: gasap-posttypes
Domain Path: /languages
Version: 1.0
......@@ -41,7 +41,7 @@ function create_post_types() {
'show_ui' => true,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'supports' => array( 'title', 'editor', 'excerpt', 'author' ),
'capability_type' => 'post',
'query_var' => true,
'menu_position' => 7,
......@@ -398,50 +398,71 @@ function gasap_add_usage_taxonomy() {
/**
* METABOXES
*/
// ----- GASAP-details field
add_action( 'add_meta_boxes', 'gasap_details' );
function gasap_details() {
/** Add metabox URL-partenaire. */
add_action( 'add_meta_boxes', 'partenaire_url_add_metabox' );
function partenaire_url_add_metabox() {
add_meta_box(
'gasap_details',
__( 'GASAP details', 'gasap-posttypes' ),
'gasap_details_content',
'gasap',
'url_partenaire',
__( 'URL site', 'gasap-posttypes' ),
'partenaire_url_metabox_callback',
'partner',
'normal',
'high'
);
}
// Outputs GASAP-details meta box
function gasap_details_content( $post ) {
wp_nonce_field( plugin_basename( __FILE__ ), 'gasap_details_nonce' );
$gasap_details_stored_meta = get_post_meta( $post->ID );
/** Print the metabox content. */
function partenaire_url_metabox_callback( $post ) {
// Create a nonce field.
wp_nonce_field( 'partenaire_url_metabox', 'partenaire_url_metabox_nonce' );
// Retrieve a previously saved value, if available.
$url = get_post_meta( $post->ID, '_partenaire_url', true );
// Create the metabox field mark-up.
?>
</p>
<label for="gasap_mailreferent"><?php _e( 'Email referent:', 'gasap-posttypes' ) ?></label>
<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%" />
<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' );
function gasap_details_meta_save( $post_id ) {
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[ 'gasap_details_nonce' ] ) && wp_verify_nonce( $_POST[ 'gasap_details_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) )
/** Save the metabox. */
add_action( 'save_post', 'partenaire_url_save_metabox' );
function partenaire_url_save_metabox( $post_id ) {
// Check if our nonce is set.
if ( ! isset( $_POST['partenaire_url_metabox_nonce'] ) ) {
return;
} else {
if ( !current_user_can( 'edit_post', $post_id ) )
}
$nonce = $_POST['partenaire_url_metabox_nonce'];
// Verify that the nonce is valid.
if ( ! wp_verify_nonce( $nonce, 'partenaire_url_metabox' ) ) {
return;
}
if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
// 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 ) {
return;
}
if( isset( $_POST[ 'gasap_mailreferent' ] ) ) {
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
......
......@@ -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/
add_action( 'admin_init', 'gasap_remove_menu_pages' );
function gasap_remove_menu_pages() {
global $user_ID;
if ( current_user_can( 'author' ) ) {
......@@ -152,3 +151,16 @@ function remove_wp_nodes()
$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{
font-weight: bold;
}
.uk-panel.uk-panel-box{
.uk-panel.uk-panel-box.gasap-panel-box{
text-align: center;
padding:0 1em;
background-color: white;
......@@ -229,7 +229,7 @@ main .uk-container{
.largeur3{
max-width:535px;
}
.uk-panel.uk-panel-box{
.uk-panel.uk-panel-box.gasap-panel-box{
margin-bottom: 1em;
}
}
......
......@@ -7,29 +7,25 @@
'order_by' => 'title'
)); ?>
<div class="uk-grid"><?php
if($gasap->have_posts()){ ?>
<div class="uk-width-1-1 uk-width-medium-1-3">
<ul data-uk-switcher="{connect:'#les_gasap', animation: 'fade'}"> <?php
while ( $gasap->have_posts() ) : $gasap->the_post();
global $post; ?>
<li><a><?php echo get_the_title(); ?></a></li><?php
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
if($gasap->have_posts()){
while ( $gasap->have_posts() ) : $gasap->the_post();
global $post; ?>
<li id="post-<?php the_ID(); ?>">
<h3><?php echo get_the_title(); ?></h3>
<div class="uk-width-1-1 uk-width-medium-1-2">
<div class="uk-panel uk-panel-box">
<h3 class="uk-panel-title"><?php echo get_the_title(); ?></h3>
<?php the_content() ?>
<?php edit_post_link( esc_html__( 'Edit gasap', 'beans_gasap' ), '<span class="edit-link">', '</span>' ); ?>
<?php echo do_shortcode( '[contact-form-7 id="150" title="Contact form 1"]' ); ?>
</li><?php
endwhile;?>
</ul>
<!-- Contact form popup -->
<button class="uk-button" data-uk-modal="{target:'#contac-gasap-form'}">Contacter ce GASAP</button>
<div id="contac-gasap-form" class="uk-modal">
<div class="uk-modal-dialog">
<a class="uk-modal-close uk-close"></a>
<?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>
......@@ -37,4 +33,4 @@
<?php echo do_shortcode('[gmw_post_info]'); ?>
</div>
</div>
</section><?php
\ No newline at end of file
</section>
\ No newline at end of file
......@@ -28,7 +28,7 @@
?><div class="uk-grid uk-grid-match"> <?php
while ( $troisetapes->have_posts() ) : $troisetapes->the_post();
?><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
if ( has_post_thumbnail() ) { the_post_thumbnail(); }
?><div><?php the_content(); ?></div><?php
......
......@@ -17,7 +17,7 @@ function gasap_enqueue_uikit_assets() {
// Enqueue uikit overwrite theme folder
//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
beans_uikit_enqueue_components( array( 'switcher' ) );
beans_uikit_enqueue_components( array( 'switcher', 'modal' ) );
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/gasap.less', 'less' );
......@@ -66,29 +66,3 @@ function gasap_prodlink_add_custom_query_var( $vars ){
$vars[] = "choix_prod"; //pour template part three_producers
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() { ?>
$comment = new WP_Query( array( 'post_type' => 'contentpiece','p' => 65) ); //FIX db entry
$comment_images = new WP_Query( $args_comment_images );
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>
<div class="textegauche"><?php the_content(); ?></div>
<?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<p class="edit-link">', '</p>' ); ?>
......
......@@ -110,25 +110,19 @@ function add_contentpieces_after_lereaseau() { ?>
<article id="snippet_partenaires" class="uk-slidenav-position" data-uk-slider="{center:true}">
<div class="uk-slider-container">
<ul class="uk-slider uk-grid-width-medium-1-3 uk-grid-width-large-1-4">
<?php // logos défilants ?pieces? content = link title ?
$args = array(
'post_type' => 'contentpiece',
'orderby'=> 'title',
'order' => 'ASC',
'tax_query' => array(
array(
'category_name' => 'TODO'//create tag for partenaires
)
)
<ul class="uk-slider uk-grid-width-medium-1-3 uk-grid-width-large-1-4"> <?php
$argspartner = array(
'post_type' => 'partner',
'order_by' => 'rand'
);
$loop = new WP_Query( $args );
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
$looppartner = new WP_Query( $argspartner );
while ( $looppartner->have_posts() ) : $looppartner->the_post();
if ( has_post_thumbnail() ) { ?>
<li><a href="" title="<?php the_title(); ?>" target="_blank"><?php the_post_thumbnail('medium'); ?></a></li><?php
}
endwhile;
wp_reset_postdata();?>
</ul>
</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-next" data-uk-slider-item="next"></a>
......@@ -152,7 +146,7 @@ function add_contentpieces_after_lereaseau() { ?>
?><div class="uk-grid uk-grid-match"> <?php
while ( $contactprod->have_posts() ) : $contactprod->the_post();
?><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
if ( has_post_thumbnail() ) { the_post_thumbnail(); }
?><div><?php the_content(); ?></div><?php
......
......@@ -33,7 +33,7 @@ function add_contentpieces_after_les_producteurs() { ?>
$comment = new WP_Query( array( 'post_type' => 'contentpiece','p' => 65) ); //FIX db entry
$comment_images = new WP_Query( $args_comment_images );
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>
<div class="textegauche"><?php the_content(); ?></div>
<?php edit_post_link( esc_html__( 'Edit snippet', 'beans_gasap' ), '<p class="edit-link">', '</p>' ); ?>
......
......@@ -25,7 +25,7 @@ function page_contact_before() {
?><div class="uk-grid uk-grid-match"> <?php
while ( $contactprod->have_posts() ) : $contactprod->the_post();
?><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
if ( has_post_thumbnail() ) { the_post_thumbnail(); }
?><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