Advertisement
sted

Wordpress functions I.

Jul 1st, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.32 KB | None | 0 0
  1. /*  use these inside your (child!)theme functions.php   */
  2.  
  3. /*      Remove useless links from the header (Visual Composer included!)        */
  4. function removeHeadLinks() {
  5.     remove_action('wp_head', 'feed_links_extra', 3 );
  6.     remove_action('wp_head', 'feed_links', 2 );
  7.     remove_action('wp_head', 'rsd_link' );
  8.     remove_action('wp_head', 'wlwmanifest_link' );
  9.     remove_action('wp_head', 'index_rel_link' );
  10.     remove_action('wp_head', 'parent_post_rel_link', 10, 0 );
  11.     remove_action('wp_head', 'start_post_rel_link', 10, 0 );
  12.     remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0 );
  13.     remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);    
  14.     remove_action('wp_head', 'wp_generator' );
  15.  
  16. /*  Use this only if you have VC installed  */
  17.     remove_action('wp_head', array(visual_composer(), 'addMetaData'));
  18. }
  19. add_action('init', 'removeHeadLinks');
  20.  
  21.  
  22. /*      Remove version numbers after css, js files      */
  23. function removeWpVerCssJs( $src ) {
  24.     if ( strpos( $src, 'ver=' ) )
  25.         $src = remove_query_arg( 'ver', $src );
  26.     return $src;
  27. }
  28. add_filter('style_loader_src', 'removeWpVerCssJs', 9999 );
  29. add_filter('script_loader_src', 'removeWpVerCssJs', 9999 );
  30.  
  31.  
  32. /*      Remove revolution slider meta       */
  33. function removeRevsliderMeta() {
  34.     return '';
  35. }
  36. add_filter('revslider_meta_generator', 'removeRevsliderMeta');
  37.  
  38. /*      Force disable comments      */
  39. function removeCommentSupport() {
  40.     remove_post_type_support( 'post', 'comments' );
  41.     remove_post_type_support( 'page', 'comments' );
  42. }
  43. add_action('init', 'removeCommentSupport', 100);
  44.  
  45. /*      Remove the Admin Bar (you know how annoying this can be)        */
  46. show_admin_bar(false);
  47.  
  48. /*      Remove emoji junk from the header   */
  49. remove_action('wp_head', 'print_emoji_detection_script', 7 );
  50. remove_action('admin_print_scripts', 'print_emoji_detection_script' );
  51. remove_action('wp_print_styles', 'print_emoji_styles' );
  52. remove_action('admin_print_styles', 'print_emoji_styles' );  
  53.  
  54. /*      Yoast: Some extras like remove og:images from the header        */
  55. function removeOpenGraphImages($val) {
  56.     return preg_replace("/<img[^>]+\>/i", "", $val);
  57. }
  58. add_filter('wpseo_pre_analysis_post_content', 'removeOpenGraphImages');
  59. add_filter('wpseo_og_article_published_time', '__return_false' );
  60. add_filter('wpseo_og_article_modified_time', '__return_false' );
  61. add_filter('wpseo_og_og_updated_time', '__return_false' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement