Page 1 sur 1
[Astuce] Ajouter un lien vers le sujet du forum
Posté : sam. 2 juil. 2011 17:05
par Dakin Quelia
» Ajouter un lien vers le sujet du forum
Vous souhaitez que vos commentaires soient remplacés par un lien vers le sujet de votre forum? Cette documentation va vous y aider.
Dans phpMyAdmin (ou tout autre logiciel de gestion SQL), vous devez exécuter cette requête SQL:
Code : Tout sélectionner
ALTER TABLE wp_posts ADD post_forum_url VARCHAR(255) NOT NULL DEFAULT ''
Cela donnera comme résultat:
- Côté administration:

Côté utilisateur:

Re: [Astuce] Ajouter un lien vers le sujet du forum
Posté : sam. 2 juil. 2011 17:05
par Dakin Quelia
Ouvrez le fichier «
/wp-admin/includes/post.php ».
Cherchez:
Code : Tout sélectionner
$post_title = '';
if ( !empty( $_REQUEST['post_title'] ) )
$post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
Après, ajoutez:
Code : Tout sélectionner
$post_forum_url = '';
if ( !empty( $_REQUEST['post_forum_url'] ) )
$post_forum_url = esc_html( stripslashes( $_REQUEST['post_forum_url'] ));
Cherchez:
Code : Tout sélectionner
$post->post_title = apply_filters( 'default_title', $post_title, $post );
Après, ajoutez:
Code : Tout sélectionner
$post->post_forum_url = apply_filters( 'default_forum_url', $post_forum_url, $post );
Ouvrez le fichier «
/wp-admin/edit-form-advanced.php ».
Cherchez:
Code : Tout sélectionner
<div id="titlewrap">
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label>
<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
</div>
Après, ajoutez:
Code : Tout sélectionner
<div id="titlewrap">
<label for="post_forum_url"><?php _e('URL du sujet forum') ?></label></label>
<input type="text" name="post_forum_url" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_forum_url ) ); ?>" id="title" autocomplete="off" />
</div>
Re: [Astuce] Ajouter un lien vers le sujet du forum
Posté : sam. 2 juil. 2011 17:06
par Dakin Quelia
Ouvrez le fichier «
/includes/post.php ».
Cherchez:
Code : Tout sélectionner
$format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_password');
Remplacez par:
Code : Tout sélectionner
$format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_forum_url', 'post_password');
Cherchez:
Remplacez par:
Code : Tout sélectionner
'post_content' => '', 'post_title' => '', 'post_forum_url' => '');
Cherchez:
Code : Tout sélectionner
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title',
Remplacez par:
Code : Tout sélectionner
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_forum_url'
Cherchez:
Après, ajoutez:
Cherchez:
Après, ajoutez:
Re: [Astuce] Ajouter un lien vers le sujet du forum
Posté : sam. 2 juil. 2011 17:06
par Dakin Quelia
Ouvrez le fichier «
/wp-content/themes/twentyten/loo.php ».
Cherchez:
Code : Tout sélectionner
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
Remplacez par:
Code : Tout sélectionner
<span class="comments-link"><?php if (!empty($post->post_forum_url)) { _e( '<a href="'.$post->post_forum_url.'">Sujet de discussion</a>', 'twentyten' ); } else { comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); } ?></span>