Guest User

WordPress Whitelabel PHP

a guest
Jul 31st, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.77 KB | None | 0 0
  1. <?php
  2. /*-------------- Remove Features, Scripts, Etc --------------*/
  3. // Remove Unnecessary WP Head
  4.  
  5. add_action('init', 'remove_header_info');
  6.  
  7. function remove_header_info() {
  8. remove_action('wp_head', 'rsd_link'); // Removes 'Really Simple Discovery'
  9. remove_action('wp_head', 'wp_generator'); // Removes 'Wordpress Version'
  10. remove_action('wp_head', 'feed_links', 2); // Removes 'Feeds'
  11. remove_action('wp_head', 'feed_links_extra', 3); // Removes 'Comment Feed'
  12. remove_action('wp_head', 'index_rel_link'); // Removes 'Link to Index (Home) Page'
  13. remove_action('wp_head', 'wlwmanifest_link'); // Removes 'wlwmanifest.xml (Windows Live Writer Support)'
  14. remove_action('wp_head', 'start_post_rel_link', 10, 0); // Removes 'Random Post'
  15. remove_action('wp_head', 'parent_post_rel_link', 10, 0); // Removes 'Parent Post'
  16. remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // Removes 'Next and Previous Post'
  17. remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); // Removes 'Post Links'
  18. remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); // Removes 'Shortlinks'
  19. remove_action('wp_head', 'print_emoji_detection_script', 7); // Removes 'Emoji Detection Scripts'
  20. remove_action('wp_print_styles', 'print_emoji_styles'); // Removes 'Emoji Stylesheet WP'
  21. remove_action('admin_print_scripts', 'print_emoji_detection_script'); // Removes 'Emoji Script'
  22. remove_action( 'admin_menu', 'minti_add_demo_import_page' ); // Removes 'Theme Demo Import'
  23. remove_action('admin_print_styles', 'print_emoji_styles'); // Removes 'Emoji Stylesheet Admin'
  24. wp_deregister_script('comment-reply'); // Removes 'comment-reply.min.js'
  25. // add_filter('show_admin_bar', '__return_false'); // Removes 'Frontend AdminBar'
  26. add_filter( 'jetpack_implode_frontend_css', '__return_false' ); // Removes 'Jetpack CSS'
  27. add_filter( 'admin_footer_text', '__return_empty_string', 11 ); // Removes 'Footer Text'
  28. add_filter('update_footer', '__return_empty_string', 11); // Removes 'Footer Wordpress Version'
  29. remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); // Removes 'Emoji Email'
  30. remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); // Removes 'Emoji Content Feed'
  31. remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); // Removes 'Emoji RSS'
  32. add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' ); // Removes 'TinyMCE Emoji'
  33. add_filter( 'emoji_svg_url', '__return_false' ); // Removes 'Emoji SVG Urls'
  34. }
  35.  
  36. // End
  37. // Remove post and page comments
  38.  
  39. add_action('init', 'remove_comment_support', 100);
  40.  
  41. function remove_comment_support(){
  42. remove_post_type_support('post', 'comments');
  43. remove_post_type_support('page', 'comments');
  44. }
  45.  
  46. // End
  47. // Remove Feed Links
  48.  
  49. add_action('after_theme_support', 'remove_feed');
  50.  
  51. function remove_feed() {
  52. remove_theme_support('automatic-feed-links');
  53. }
  54.  
  55. // End
  56. // Remove All Meta Generators
  57.  
  58. add_action('wp_footer', function(){ ob_end_flush(); }, 100);
  59.  
  60. function remove_meta_generators($html) {
  61. $pattern = '/<meta name(.*)=(.*)"generator"(.*)>/i';
  62. $html = preg_replace($pattern, '', $html);
  63. return $html;
  64. }
  65.  
  66. add_action('get_header', 'clean_meta_generators', 100);
  67.  
  68. function clean_meta_generators($html) {
  69. ob_start('remove_meta_generators');
  70. }
  71.  
  72. // End
  73. // Dequeue Scripts Jetpack Devicepx
  74.  
  75. add_action( 'wp_enqueue_scripts', 'crunchify_enqueue_scripts_styles' );
  76.  
  77. function crunchify_enqueue_scripts_styles() {
  78. wp_dequeue_script( 'devicepx' );
  79. }
  80.  
  81. // End
  82. // Remove Plugin Notification - Replace USERNAME with your Username
  83.  
  84. add_filter('site_transient_update_plugins', 'remove_update_notifications');
  85.  
  86. function remove_update_notifications($value) {
  87. global $current_user;
  88. $user = wp_get_current_user();
  89. $username = $current_user->user_login;
  90. if (!current_user_can('update_core') || $username !== 'USERNAME') {
  91. if (isset($value) && is_object($value)) {
  92. unset($value->response['js_composer/js_composer.php']); // Removes 'Visual Composer'
  93. remove_action( 'admin_notices', 'update_nag', 3 ); // Removes 'WordPress Update'
  94. }
  95. return $value;
  96. } else {
  97. if (isset($value) && is_object($value)) {
  98. unset($value->response['js_composer/js_composer.php']); // Removes 'Visual Composer'
  99. }
  100. return $value;
  101. }
  102. }
  103.  
  104. // End
  105. // Remove Wordpress from Backend Title Tags - SEO
  106.  
  107. add_filter('admin_title', 'remove_wp_titles_seo', 10, 2);
  108.  
  109. function remove_wp_titles_seo($admin_title, $title) {
  110. return get_bloginfo('name').' - '.$title;
  111. }
  112.  
  113. // End
  114. // Contact Form Script Disable
  115. add_action( 'wp_enqueue_scripts', 'load_contactform7_on_specific_page' );
  116.  
  117. function load_contactform7_on_specific_page(){
  118. // Edit page IDs here
  119. if(! is_page(247) )
  120. {
  121. wp_dequeue_script('contact-form-7'); // Dequeue JS Script file.
  122. wp_dequeue_style('contact-form-7'); // Dequeue CSS file.
  123. }
  124. }
  125.  
  126. // End
  127. /*-------------- End Remove Features, Scripts, Etc --------------*/
  128.  
  129. /*-------------- Backend Customization --------------*/
  130. // Remove Admin Toolbar Menus
  131.  
  132. add_action('wp_before_admin_bar_render', 'admin_toolbar_remove_menu', 999);
  133.  
  134. function admin_toolbar_remove_menu() {
  135. global $wp_admin_bar;
  136. $wp_admin_bar->remove_node('wp-logo'); // Removes 'WordPress Logo'
  137. $wp_admin_bar->remove_node('comments'); // Removes 'Comments'
  138. $wp_admin_bar->remove_node('new-content'); // Removes 'New Content'
  139. $wp_admin_bar->remove_node('customize'); // Removes 'Customizer'
  140. $wp_admin_bar->remove_node('search'); // Removes 'Search'
  141. $wp_admin_bar->remove_node('site-name'); // Removes 'Site Name'
  142. $wp_admin_bar->remove_node('top-secondary'); // Removes 'Right User Menu'
  143. $wp_admin_bar->remove_node('about'); // Removes 'About WordPress'
  144. $wp_admin_bar->remove_node('wporg'); // Removes 'WordPress.org'
  145. $wp_admin_bar->remove_node('documentation'); // Removes 'Documentation'
  146. $wp_admin_bar->remove_node('support-forums'); // Removes 'Support Forums'
  147. $wp_admin_bar->remove_node('feedback'); // Removes 'Feedback'
  148. $wp_admin_bar->remove_node('view-site'); // Removes 'View Site'
  149. $wp_admin_bar->remove_node('updates'); // Removes 'Updates'
  150. $wp_admin_bar->remove_node('my-account'); // Removes 'User Details'
  151. }
  152.  
  153. // End
  154. // Remove Multisite Admin Bar Menus
  155.  
  156. add_action( 'admin_bar_menu', 'remove_toolbar_items', PHP_INT_MAX -1 );
  157. function remove_toolbar_items( $bar )
  158. {
  159. $sites = get_blogs_of_user( get_current_user_id() );
  160. foreach ( $sites as $site )
  161. {
  162. $bar->remove_node( "blog-{$site->userblog_id}-c" );
  163. $bar->remove_node( "blog-{$site->userblog_id}-n" );
  164. }
  165. }
  166.  
  167. //End
  168. // Remove Admin Menus Replace USERNAME with your Username
  169.  
  170. add_action('admin_menu', 'remove_admin_menus');
  171.  
  172. function remove_admin_menus() {
  173. global $current_user;
  174. global $submenu;
  175. $user = wp_get_current_user();
  176. $username = $current_user->user_login;
  177. if (!current_user_can('update_core') || $username !== 'USERNAME') {
  178. remove_menu_page('edit.php'); // Removes 'Posts'
  179. remove_menu_page('edit-comments.php'); // Removes 'Comments'
  180. remove_menu_page('tools.php'); // Removes 'Tools'
  181. remove_menu_page('vc-welcome'); // Removes 'Visual Composer Welcome'
  182. remove_menu_page('vc-general'); // Removes 'Visual Composer'
  183. unset($submenu['index.php'][10]); // Removes 'Updates'
  184. unset($submenu['themes.php'][5]); // Removes 'Themes'
  185. unset($submenu['themes.php'][6]); // Removes 'Customizer'
  186. unset($submenu['options-general.php'][15]); // Removes 'Writing'
  187. unset($submenu['options-general.php'][20]); // Removes 'Reading'
  188. unset($submenu['options-general.php'][25]); // Removes 'Discussion'
  189. unset($submenu['options-general.php'][30]); // Removes 'Media'
  190. unset($submenu['users.php'][15]); // Removes 'Discussion'
  191. remove_submenu_page('edit.php?post_type=popup', 'pum-extensions'); // Removes 'Popup Maker Extensions'
  192. remove_submenu_page('edit.php?post_type=popup', 'pum-tools'); // Removes 'Popup Maker Tools'
  193. remove_submenu_page('edit.php?post_type=popup', 'pum-support'); // Removes 'Popup Maker Support'
  194. remove_submenu_page('wpcf7', 'wpcf7-integration'); // Removes 'Contact Form 7 Integration'
  195. remove_submenu_page('wpseo_dashboard', 'wpseo_licenses'); // Removes 'Yoast Premium'
  196. remove_submenu_page('wpseo_dashboard', 'wpseo_tools'); // Removes 'Yoast Tools'
  197. define('DISALLOW_FILE_EDIT', true);
  198. } else {
  199. //remove_menu_page('edit.php'); // Removes 'Posts'
  200. remove_menu_page('edit-comments.php'); // Removes 'Comments'
  201. remove_menu_page('tools.php'); // Removes 'Tools'
  202. remove_menu_page('vc-general'); // Removes 'Visual Composer'
  203. unset($submenu['options-general.php'][15]); // Removes 'Writing'
  204. unset($submenu['options-general.php'][25]); // Removes 'Discussion'
  205. unset($submenu['options-general.php'][30]); // Removes 'Media'
  206. unset($submenu['users.php'][15]); // Removes 'Discussion'
  207. remove_submenu_page('edit.php?post_type=popup', 'pum-extensions'); // Removes 'Popup Maker Extensions'
  208. remove_submenu_page('edit.php?post_type=popup', 'pum-tools'); // Removes 'Popup Maker Tools'
  209. remove_submenu_page('edit.php?post_type=popup', 'pum-support'); // Removes 'Popup Maker Support'
  210. remove_submenu_page('wpcf7', 'wpcf7-integration'); // Removes 'Contact Form 7 Integration'
  211. remove_submenu_page('wpseo_dashboard', 'wpseo_licenses'); // Removes 'Yoast Premium'
  212. remove_submenu_page('wpseo_dashboard', 'wpseo_tools'); // Removes 'Yoast Tools'
  213. }
  214. }
  215.  
  216. // End
  217. // Remove WP dashboard widgets
  218.  
  219. add_action('wp_dashboard_setup', 'wp_remove_dashboard_widgets' );
  220.  
  221. function wp_remove_dashboard_widgets() {
  222. // Main Widgets
  223. remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' ); // Removes 'Activity'
  224. remove_meta_box( 'dashboard_browser_nag', 'dashboard', 'normal' ); // Removes 'Browser Nag'
  225. remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); // Removes 'Right Now'
  226. remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); // Removes 'Recent Comments'
  227. remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); // Removes 'Incoming Links'
  228. remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); // Removes 'Plugins'
  229. // Side Widgets
  230. remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); // Removes 'Plugins'
  231. remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); // Removes 'Recent Drafts'
  232. remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'side' ); // Removes 'Incoming Links'
  233. remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); // Removes 'Primary'
  234. remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); // Removes 'Secondary'
  235. remove_action('welcome_panel', 'wp_welcome_panel'); // Removes 'Welcome'
  236. // Plugin Widgets
  237. remove_meta_box( 'yoast_db_widget', 'dashboard', 'normal' ); // Removes 'Yoast'
  238. }
  239.  
  240. // End
  241.  
  242. // Custom CSS - Hide Help Menu, Pop-Ups, Etc
  243.  
  244. add_action('admin_print_styles', 'wp_custom_admin_css_hide');
  245.  
  246. function wp_custom_admin_css_hide()
  247. {
  248. ?>
  249. <style type="text/css">
  250. #menu-appearance ul li:last-child, #wpadminbar #wp-admin-bar-my-sites .blavatar, .contextual-help-link-wrap, .wp-pointer, #adminmenu li.wp-menu-separator, .updated.vc_license-activation-notice, #collapse-menu
  251. {
  252. display:none!important; visibility: hidden;
  253. }
  254. </style>
  255. <?php
  256. }
  257.  
  258. /*-------------- End Backend Customization --------------*/
  259.  
  260. /*-------------- Extra Security --------------*/
  261. // Hide Admin Account - Replace USERNAME with your username
  262.  
  263. add_action('pre_user_query','yoursite_pre_user_query');
  264.  
  265. function yoursite_pre_user_query($user_search) {
  266. global $current_user;
  267. $username = $current_user->user_login;
  268.  
  269. if ($username == 'USERNAME') {
  270. } else {
  271. global $wpdb;
  272. $user_search->query_where = str_replace('WHERE 1=1',
  273. "WHERE 1=1 AND {$wpdb->users}.user_login != 'USERNAME'",$user_search->query_where);
  274. }
  275. }
  276.  
  277. // End
  278. // Hide Number of Admins
  279.  
  280. add_action('admin_head','hide_user_count');
  281.  
  282. function hide_user_count()
  283. {
  284. ?>
  285. <style>
  286. .wp-admin.users-php span.count {
  287. display: none;
  288. }
  289. </style>
  290. <?php
  291. }
  292.  
  293. // End
  294. /*-------------- End Extra Security --------------*/
  295.  
  296. /*-------------- WP Login Customization --------------*/
  297. // Custom WP Login
  298. add_action( 'login_enqueue_scripts', 'wp_client_login' );
  299.  
  300. function wp_client_login() { ?>
  301. <style type="text/css">
  302. body, html {
  303. height:0!important;
  304. }
  305. body.login {
  306. background-color:#fbfbfb;
  307. }
  308. .inv-recaptcha-holder {
  309. margin-bottom: 16px;
  310. margin-left: 7px;
  311. }
  312. body.login div#login {
  313. padding: 0;
  314. margin-top:8%;
  315. border:1px solid #eeeeee;
  316. border-radius:2px;
  317. box-shadow: 0 1px 3px rgba(0,0,0,.13);
  318. background: #ffffff;
  319. }
  320. body.login div#login form#loginform, #lostpasswordform {
  321. box-shadow: none;
  322. padding-bottom:0;
  323. padding-top:0;
  324. }
  325. body.login div#login form#loginform input, #lostpasswordform input[type=text] {
  326. border:none;
  327. border-bottom:1px solid #dddddd!important;
  328. background:none;
  329. box-shadow:none;
  330. }
  331. body.login div#login h1 a {
  332. background-image: url('IMAGE'); /*Enter your own image url, but remember to change the sizes below*/
  333. background-size: 205px auto;
  334. height: 122px;
  335. width: 205px;
  336. margin-top: 25px;
  337. }
  338. .login #wp-submit:hover {
  339. background: #3e93ff !important;
  340. }
  341. body.login div#login form#loginform input#wp-submit, #lostpasswordform input#wp-submit {
  342. background-color: #4798ff;
  343. width: 100%;
  344. border: none;
  345. border-radius: 2px;
  346. box-shadow: none;
  347. height: 40px!important;
  348. text-shadow: none;
  349. margin-top: 20px;
  350. }
  351. .forgetmenot {
  352. padding-top: 4px;
  353. }
  354. body.login div#login form#loginform p label, #lostpasswordform p label, body.login div#login form#loginform p.forgetmenot {
  355. font-size:15px;
  356. }
  357. .login #nav a, .login #nav a:hover {
  358. color:#72777c!important;
  359. font-size:14px;
  360. }
  361. .login #backtoblog a {
  362. display:none;
  363. }
  364. .login #nav {
  365. text-align:center;
  366. margin-top:15px!important;
  367. }
  368. .login #login_error, .login .message {
  369. margin:24px!important;
  370. }
  371. .login .message {
  372. border-color:#4798ff!important;
  373. }
  374. input[type=checkbox]:checked:before {
  375. color:#4798ff!important;
  376. }
  377. .login #login_error {
  378. border-left-color:#ff4747!important;
  379. }
  380.  
  381. </style>
  382. <?php }
  383.  
  384. // End
  385. // Login Screen Logo Link Redirect
  386.  
  387. add_filter('login_headerurl', 'login_logo_url_redirect');
  388.  
  389. function login_logo_url_redirect() {
  390. return get_bloginfo('url');
  391. }
  392.  
  393. // End
  394. // Replace Login Screen Logo Alt Text
  395.  
  396. add_filter('login_headertitle', 'login_logo_alt_text');
  397.  
  398. function login_logo_alt_text() {
  399. return get_bloginfo('title');
  400. }
  401.  
  402. // End
  403. // Always Check Remember Me Box on Login Screen
  404.  
  405. function login_checked_remember_me() {
  406. add_filter('login_footer', 'rememberme_checked');
  407. }
  408. add_action('init', 'login_checked_remember_me');
  409.  
  410. function rememberme_checked() {
  411. echo "<script>document.getElementById('rememberme').checked = true;</script>";
  412. }
  413.  
  414. // End
  415. // Remove User Login Shake on Error
  416.  
  417. add_action('login_head', 'remove_login_error_shake');
  418.  
  419. function remove_login_error_shake() {
  420. remove_action('login_head', 'wp_shake_js', 12);
  421. }
  422.  
  423. // End
  424. // Replace Login Error Message - Improve Security
  425.  
  426. add_filter('login_errors', 'login_error_override');
  427.  
  428. function login_error_override() {
  429. return 'Incorrect login details.';
  430. }
  431.  
  432. // End
  433. /*-------------- End WP Login Customization --------------*/
  434. ?>
Add Comment
Please, Sign In to add comment