123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <?php
- function lnr24_enqueue_assets() {
- wp_enqueue_style( 'style-css', get_template_directory_uri() . '/style.css');
- }
- add_action( 'wp_enqueue_scripts', 'lnr24_enqueue_assets' );
- /***********************************************************
- ###################### BrowserSync #########################
- ************************************************************/
- function add_cors_http_header(){
- header('Access-Control-Allow-Origin: https://lnr.ovid:333');
- header('Access-Control-Allow-Credentials: true');
- header('Access-Control-Allow-Headers: X-WP-Nonce', false );
- }
- add_action('init','add_cors_http_header');
- function lnr24_browsersync_save() {
- $args = [
- 'blocking' => false,
- 'sslverify' => false
- ];
- $request = wp_remote_get('https://lnr.ovid:333/__browser_sync__?method=reload', $args);
- }
- add_action('rest_after_insert_page', 'lnr24_browsersync_save', 10, 3);
- add_action('rest_after_insert_post', 'lnr24_browsersync_save', 10, 3);
- add_action('save_post', 'lnr24_browsersync_save', 10, 3);
- add_action('customize_save_after', 'lnr24_browsersync_save', 10, 3);
- add_action('wp_update_nav_menu', 'lnr24_browsersync_save', 10, 3);
- add_action('updated_option', 'lnr24_browsersync_save', 10, 3);
- /***********************************************************
- ######################### Admin ############################
- ************************************************************/
- add_filter( 'show_admin_bar', '__return_false' );
- add_action( 'admin_bar_menu', 'lnr24_remove_adminbar', 999 );
- function lnr24_remove_adminbar( $wp_admin_bar ) {
- $wp_admin_bar->remove_node('wp-logo');
- $wp_admin_bar->remove_node('updates');
- $wp_admin_bar->remove_menu('comments');
- $wp_admin_bar->remove_menu('customize');
- $wp_admin_bar->remove_menu('new-content');
- $wp_admin_bar->remove_menu('edit');
- $wp_admin_bar->remove_menu('new-user');
- $wp_admin_bar->remove_menu('new-post');
- $wp_admin_bar->remove_menu('new-page');
- $wp_admin_bar->remove_node('new-media');
- $wp_admin_bar->remove_node('view-site');
- }
- add_filter( 'custom_menu_order', 'lnr24_menu_order' );
- add_filter( 'menu_order', 'lnr24_menu_order' );
- function lnr24_menu_order( $menu_order ) {
- if (!$menu_order) return true;
- return array(
- 'index.php',
- 'separator1',
- 'edit.php?post_type=page',
- 'edit.php',
- 'edit-comments.php',
- 'separator2',
- 'upload.php',
- 'theme-settings',
- 'themes.php',
- 'plugins.php',
- 'tools.php',
- 'users.php',
- 'separator-last'
- );
- }
- add_action( 'admin_menu', 'lnr24_remove_admin_pages', 99 );
- function lnr24_remove_admin_pages() {
- global $current_user;
- $user_id = get_current_user_id();
- if($user_id != '0') {
- remove_menu_page('plugins.php');
- remove_menu_page('tools.php');
- remove_menu_page('options-general.php');
- remove_menu_page('gutenberg');
- remove_menu_page('users.php');
- remove_submenu_page('themes.php', 'themes-editor.php');
- remove_submenu_page( 'themes.php', 'customize.php?return=' . urlencode($_SERVER['SCRIPT_NAME']));
- remove_submenu_page( 'themes.php', 'themes.php' );
- remove_submenu_page( 'themes.php', 'theme-editor.php' );
- remove_submenu_page( 'themes.php', 'theme_options' );
- remove_submenu_page('gf_edit_forms', 'gf_new_form');
- remove_submenu_page('gf_edit_forms', 'gf_export');
- remove_submenu_page('gf_edit_forms', 'gf_addons');
- remove_submenu_page('gf_edit_forms', 'gf_settings');
- remove_submenu_page('gf_edit_forms', 'gf_help');
- remove_submenu_page('gf_edit_forms', 'gf_system_status');
- }
- }
- add_action( 'wp_dashboard_setup', 'lnr24_disable_dashboard_items' );
- function lnr24_disable_dashboard_items() {
- remove_action('admin_notices', 'update_nag');
- remove_action('welcome_panel', 'wp_welcome_panel');
- remove_meta_box('dashboard_primary', 'dashboard', 'side');
- remove_meta_box('dashboard_secondary', 'dashboard', 'side');
- remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
- remove_meta_box('dashboard_site_health', 'dashboard', 'normal');
- }
- add_filter('admin_title', 'lnr24_admin_title', 10, 2);
- function lnr24_admin_title($admin_title, $title) {
- return $title .' - '. get_bloginfo('name');
- }
- add_filter ('admin_footer_text', 'lnr24_footer_filter');
- function lnr24_footer_filter ($default) {
- return '';
- }
- add_filter( 'admin_bar_menu', 'lnr24_replace_wordpress_howdy', 25 );
- function lnr24_replace_wordpress_howdy( $wp_admin_bar ) {
- $account = $wp_admin_bar->get_node('my-account');
- $newtext = str_replace( 'Howdy,', '', $account->title );
- $wp_admin_bar->add_node( array(
- 'id' => 'my-account',
- 'title' => $newtext,
- ));
- }
- add_filter( 'gettext', 'lnr24_change_howdy_text', 10, 2 );
- function lnr24_change_howdy_text( $translation, $original ) {
- if( 'Howdy, %1$s' == $original )
- $translation = '%1$s';
- return $translation;
- }
- add_action( 'admin_head-profile.php', 'lnr24_remove_admin_color' );
- function lnr24_remove_admin_color() {
- remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
- }
- add_action('admin_head', 'lnr24_remove_help_tabs');
- function lnr24_remove_help_tabs() {
- $screen = get_current_screen();
- $screen->remove_help_tabs();
- }
- /***********************************************************
- ####################### Comments ###########################
- ************************************************************/
- add_action('admin_menu', function () {
- remove_menu_page('edit-comments.php');
- });
- add_filter('comments_open', '__return_false', 20, 2);
- add_filter('pings_open', '__return_false', 20, 2);
- add_action('admin_init','lnr24_disable_comments');
- function lnr24_disable_comments() {
- $post_types = get_post_types();
- foreach ($post_types as $post_type) {
- if(post_type_supports($post_type,'comments')) {
- remove_post_type_support($post_type,'comments');
- remove_post_type_support($post_type,'trackbacks');
- }
- }
- }
- /***********************************************************
- ###################### Last Login ##########################
- ************************************************************/
- add_action( 'wp_login', 'lnr24_login_timestamp', 20, 2 );
- function lnr24_login_timestamp( $user_login, $user ) {
- update_user_meta( $user->ID, 'last_login', time() );
- }
- add_filter( 'manage_users_columns', 'lnr24_user_last_login_column' );
- function lnr24_user_last_login_column( $columns ) {
- $columns['last_login'] = 'Last Login'; // column ID / column Title
- return $columns;
- }
- add_filter( 'manage_users_custom_column', 'lnr24_last_login_column', 10, 3 );
- function lnr24_last_login_column( $output, $column_id, $user_id ){
- if( $column_id == 'last_login' ) {
- $last_login = get_user_meta( $user_id, 'last_login', true );
- $date_format = 'j M, Y';
- $output = $last_login ? date( $date_format, $last_login ) : '-';
- }
- return $output;
- }
- add_filter( 'manage_users_sortable_columns', 'lnr24_sortable_columns' );
- function lnr24_sortable_columns( $columns ) {
- return wp_parse_args( array(
- 'last_login' => 'last_login'
- ), $columns );
- }
- add_action( 'pre_get_users', 'lnr24_sort_last_login_column' );
- function lnr24_sort_last_login_column( $query ) {
- if( !is_admin() ) { return; }
- $orderby = $query->get('orderby');
- if( 'last_login' == $orderby ) {
- $query->set('meta_key','last_login');
- $query->set('orderby','meta_value');
- }
- return $query;
- }
- /***********************************************************
- ######################## Blocks ############################
- ************************************************************/
- function lnr24_restrict_locking_ui( $settings, $context ) {
- $settings[ 'canLockBlocks' ] = current_user_can( 'activate_plugins' );
- return $settings;
- }
- add_filter( 'block_editor_settings_all', 'lnr24_restrict_locking_ui', 10, 2 );
- remove_theme_support( 'core-block-patterns' );
- add_filter( 'should_load_remote_block_patterns', 'lnr24_disable_remote_patterns' );
- function lnr24_disable_remote_patterns() {
- return false;
- }
- add_filter(
- 'block_editor_settings_all',
- function( $settings ) {
- $settings['enableOpenverseMediaCategory'] = false;
- return $settings;
- },
- 10
- );
|