Advertisement
Guest User

ajouter function

a guest
Aug 8th, 2015
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.54 KB | None | 0 0
  1. //supprimer le W dans la barre d'administration
  2. function remove_wp_logo( $wp_admin_bar ) {
  3.     $wp_admin_bar->remove_node( 'wp-logo' );
  4. }
  5. add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );
  6.  
  7.  
  8. // bloquer la barre d'administration affiché
  9. function my_function_admin_bar(){
  10.     return true;
  11. }
  12. add_filter( 'show_admin_bar' , 'my_function_admin_bar');
  13.  
  14.  
  15. // bbcode dans les commentaires
  16. function bweb_comment_editor_quicktags() {
  17.     $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
  18.     wp_editor( '', 'comment', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
  19. }
  20. add_filter( 'comment_form_field_comment', 'bweb_comment_editor_quicktags' );
  21.  
  22.  
  23. //securisations
  24.     // Masquer le numéro de version de votre site WordPress
  25.     remove_action('wp_head', 'wp_generator');
  26.  
  27.     // supprime le numéro de version dans le flux RSS
  28.     if (!function_exists('juiz_no_generator')){
  29.         function juiz_no_generator() { return ''; }
  30.     }
  31.     add_filter('the_generator', 'juiz_no_generator');
  32.  
  33.     // supprimer informations dans le lien http
  34.     if( !function_exists("delete_script_version")) {
  35.         function delete_script_version( $src ){
  36.             $parts = explode( '?', $src );
  37.             return $parts[0];
  38.         }
  39.     }
  40.     add_filter( 'script_loader_src', 'delete_script_version', 15, 1 );
  41.     add_filter( 'style_loader_src', 'delete_script_version', 15, 1 );
  42.  
  43.     // bloque edition theme et plugin
  44.     //define('DISALLOW_FILE_EDIT',true);
  45.    
  46.     // Désactiver l’Installation d'Extensions et de Thèmes
  47.     //define('DISALLOW_FILE_MODS',true);
  48.    
  49.    
  50. // Ajouter du texte dans le profil:
  51. // Ajouter la licence dans le profil
  52.     function my_new_contactmethods( $contactmethods ) {
  53.         $contactmethods['licence'] = 'Licence:';
  54.         $contactmethods['date_naissance'] = 'Anniversaire:';
  55.         return $contactmethods;
  56.     }
  57.     add_filter('user_contactmethods','my_new_contactmethods',10,1);
  58.  
  59.     function extra_user_profile_fields( $user ) { ?>
  60.      
  61.         <h3>Réseaux sociaux</h3>
  62.         <table class="form-table">
  63.             <tbody>
  64.                 <tr>
  65.                     <th>Facebook</th>
  66.                     <td><input class="regular-text" placeholder="Votre pseudo FB" id="facebook" type="text" name="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" /></td>
  67.                 </tr>
  68.                 <tr>
  69.                     <th>Twitter</th>
  70.                     <td><input class="regular-text" placeholder="Votre pseudo Twitter" id="twitter" type="text" name="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" /></td>
  71.                 </tr>
  72.                 <tr>
  73.                     <th>Google+</th>
  74.                     <td><input class="regular-text" placeholder="/.../ que les chiffres" id="google_plus" type="text" name="google_plus" value="<?php echo esc_attr( get_the_author_meta( 'google_plus', $user->ID ) ); ?>" /></td>
  75.                 </tr>
  76.             </tbody>
  77.         </table>
  78.        
  79.     <?php }
  80.     add_action( 'show_user_profile', 'extra_user_profile_fields' );
  81.     add_action( 'edit_user_profile', 'extra_user_profile_fields' );
  82.      
  83.     function save_extra_user_profile_fields( $user_id ) {
  84.    
  85.         if ( !current_user_can( 'edit_user', $user_id ) ) {
  86.             return false;
  87.         }
  88.         update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
  89.         update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
  90.         update_user_meta( $user_id, 'google_plus', $_POST['google_plus'] );
  91.        
  92.     }
  93.     add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
  94.     add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
  95.  
  96.  
  97. // Ajouter un avatar par défaut
  98. add_filter( 'avatar_defaults', 'gravatar_perso' );
  99. function gravatar_perso ($avatar_defaults) {
  100.     $myavatar = get_bloginfo('template_directory') . '/core/images/volant2.jpg';
  101.     $avatar_defaults[$myavatar] = "Volant badminton";
  102.     return $avatar_defaults;
  103. }
  104.  
  105.  
  106. // change le salutation de la barre admin + le lien du profil
  107. function good_bye_howdy( $wp_admin_bar ) {
  108.    
  109.     global $current_user;
  110.     if ( is_user_logged_in() )
  111.         {
  112.     $my_account=$wp_admin_bar->get_node('my-account');
  113.     $howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name );
  114.    
  115.     date_default_timezone_set('Europe/Paris');
  116.     $date = new DateTime();
  117.     //echo $time->format('H');
  118.    
  119.     switch( $time = date_format($date, 'H') ) :
  120.     case ( $time == 12 || $time == 20 ) : $time = __( 'Bon appétit', 'montheme' ); break;
  121.     case ( $time >= 7 && $time <= 17 ) : $time = __( 'Bonjour', 'montheme' ); break;
  122.     case ( $time >= 18 && $time <= 23 ) : $time = __( 'Bonsoir', 'montheme' ); break;
  123.     default : $time = __( 'Bonne nuit', 'montheme' ); break;
  124.     endswitch;
  125. $title = str_replace( $howdy, sprintf( __( '%1$s %2$s !', 'montheme' ), $time, $current_user->display_name ), $my_account->title );
  126.     $wp_admin_bar->add_node( array(
  127.     'id' => 'my-account',
  128.     'title' => $title,
  129.     'href' => ('/forums/membre/'. $current_user->user_login),
  130.     'meta' => $my_account->meta
  131.     ) );
  132.         }  
  133. }
  134. add_filter( 'admin_bar_menu', 'good_bye_howdy' );
  135.  
  136. //Change les liens profil et edit-profil par bbpress
  137. function edit_url_profil_bar_admin( $wp_admin_bar ) {
  138.    
  139.     global $current_user;
  140.  
  141.         if ( is_user_logged_in() )
  142.         {
  143.         $wp_admin_bar->add_node( array(
  144.         'id' => 'user-info',
  145.         'href' => ('/forums/membre/'. $current_user->user_login),
  146.         ) );
  147.        
  148.         $wp_admin_bar->add_node( array(
  149.         'id' => 'edit-profile',
  150.         'href' => ('/forums/membre/'. $current_user->user_login .'/edit/'),
  151.         ) );
  152.         }
  153. }
  154.     add_filter( 'admin_bar_menu', 'edit_url_profil_bar_admin' );
  155.    
  156. // supprimer titre MBC bar admin pour les non admin
  157. function my_admin_bar_render() {
  158.     if (! is_super_admin() )
  159.     {
  160.     global $wp_admin_bar;
  161.     $wp_admin_bar->remove_menu('site-name');
  162. }
  163. }
  164. add_action( 'wp_before_admin_bar_render', 'my_admin_bar_render' );
  165.  
  166.  
  167. //ajouter info utilisateur topic/reply
  168. function bbp_profile_information ()
  169. {
  170.     $user_id = bbp_get_reply_author_id( $reply_id );
  171.     $usermeta = get_userdata($user_id);
  172.    
  173.     if(!empty($usermeta->licence)){
  174.     echo "Licence: $usermeta->licence" ;}
  175.     echo "<br>";
  176.    
  177.     if(!empty($usermeta->facebook)){
  178.     echo "<a href=\"http://www.facebook.com/".$usermeta->facebook."/\"> <img src=\"/wp-content/themes/responsivepro/core/icons/facebook-icon.png\" /></a>";  }
  179.  
  180.     if(!empty($usermeta->twitter)){
  181.     echo "<a href=\"http://www.twitter.com/".$usermeta->twitter."/\"> <img src=\"/wp-content/themes/responsivepro/core/icons/twitter-icon.png\" /></a>";  }
  182.  
  183.     if(!empty($usermeta->google_plus)){
  184.     echo "<a href=\"https://plus.google.com/u/0/".$usermeta->google_plus."/\"> <img src=\"/wp-content/themes/responsivepro/core/icons/googleplus-icon.png\" /></a>";  }
  185. }
  186. add_action ('bbp_theme_after_reply_author_details', 'bbp_profile_information') ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement