Advertisement
MertcanGokgoz

Wordpress Security Patch

Dec 20th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. <?php
  2. /* Custom Wordpress Functions
  3. /*------------------------------*/
  4. function _remove_script_version( $src ){
  5.     $parts = explode( '?ver', $src );
  6.         return $parts[0];
  7. }
  8. add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
  9. add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
  10. function wptao_disable_version_info() { return ''; }
  11. add_filter('the_generator', 'wptao_disable_version_info');
  12. add_filter('login_errors',create_function('$a',"return null;"));
  13.  
  14. remove_action('wp_head', 'wlwmanifest_link');
  15. remove_action('wp_head', 'rsd_link');
  16. remove_action('wp_head', 'wp_generator');
  17. /*E-mail Remove*/
  18. function security_remove_emails($content) {
  19.     $pattern = '/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})/i';
  20.     $fix = preg_replace_callback($pattern,"security_remove_emails_logic", $content);
  21.  
  22.     return $fix;
  23. }
  24. function security_remove_emails_logic($result) {
  25.     return antispambot($result[1]);
  26. }
  27. add_filter( 'the_content', 'security_remove_emails', 20 );
  28. add_filter( 'widget_text', 'security_remove_emails', 20 );
  29.  
  30. /* Admin Bar özelliğini iptal et */
  31. add_filter( 'show_admin_bar', '__return_false' );
  32.  
  33. /* Admin Bar seçeneklerini kullanıcı profilinden kaldır */
  34. remove_action( 'personal_options', '_admin_bar_preferences' );
  35.  
  36. /*Css and JS Versiyon Remove*/
  37. function vc_remove_wp_ver_css_js( $src ) {
  38.     if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) )
  39.         $src = remove_query_arg( 'ver', $src );
  40.     return $src;
  41. }
  42. add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
  43. add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
  44.  
  45. /*Hide admin notifications for non admins*/
  46. function hide_update_notice_to_all_but_admin_users()
  47. {
  48.     if (!current_user_can('update_core')) {
  49.         remove_action( 'admin_notices', 'update_nag', 3 );
  50.     }
  51. }
  52. add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );
  53. /*Costum Avatar*/
  54. add_filter( 'avatar_defaults', 'newgravatar' );
  55.  
  56. function newgravatar ($avatar_defaults)
  57. {
  58.     $myavatar = "avatarlink";
  59.     $avatar_defaults[$myavatar] = "avatarNick";
  60.     return $avatar_defaults;
  61. }
  62.  
  63. function disable_wp_emojicons() {
  64.  
  65.   // all actions related to emojis
  66.   remove_action( 'admin_print_styles', 'print_emoji_styles' );
  67.   remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  68.   remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  69.   remove_action( 'wp_print_styles', 'print_emoji_styles' );
  70.   remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  71.   remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
  72.   remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
  73.  
  74.   // filter to remove TinyMCE emojis
  75.   add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' );
  76. }
  77. add_action( 'init', 'disable_wp_emojicons' );
  78.  
  79. function disable_emojicons_tinymce( $plugins ) {
  80.   if ( is_array( $plugins ) ) {
  81.     return array_diff( $plugins, array( 'wpemoji' ) );
  82.   } else {
  83.     return array();
  84.   }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement