daily pastebin goal
42%
SHARE
TWEET

Supprimer les commentaires de Yoast SEO dans le code source

s2prod Mar 18th, 2017 (edited) 194 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //A ajouter dans le fichier functions.php de votre thème
  2. //Add this to your theme functions.php file
  3.  
  4. /* Supprime les commentaires de Yoast SEO dans le code source */
  5. /* Remove Yoast SEO comments in source code */
  6.  
  7.  
  8. if ( ! defined( 'ABSPATH' ) ) { exit; }
  9.  
  10. function rysc_bundle() {
  11.     if(defined( 'WPSEO_VERSION' ) && class_exists('WPSEO_Frontend')) {
  12.         remove_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), 'debug_mark' ) , 2);
  13.         remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ) , 1);
  14.         add_action( 'wp_head', 'rysc_rewrite' , 1);
  15.     }
  16. }
  17. add_action( 'init', 'rysc_bundle' );
  18.  
  19. function rysc_rewrite() {
  20.     $rewrite = new ReflectionMethod( 'WPSEO_Frontend', 'head' );
  21.  
  22.     $filename = $rewrite->getFileName();
  23.     $start_line = $rewrite->getStartLine();
  24.     $end_line = $rewrite->getEndLine()-1;
  25.    
  26.     $length = $end_line - $start_line;
  27.     $source = file($filename);
  28.     $body = implode("", array_slice($source, $start_line, $length));
  29.     $body = preg_replace( '/echo \'\<\!(.*?)\n/', '', $body);
  30.    
  31.     eval($body);
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top