get( 'Version' ) ); } add_action( 'wp_enqueue_scripts', 'uhp24_styles' ); /*********************************************************** ###################### BrowserSync ######################### ************************************************************/ function add_cors_http_header(){ header('Access-Control-Allow-Origin: https://uhp.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 uhp24_browsersync_save() { $args = [ 'blocking' => false, 'sslverify' => false ]; $request = wp_remote_get('https://uhp.ovid:333/__browser_sync__?method=reload', $args); } add_action('rest_after_insert_page', 'uhp24_browsersync_save', 10, 3); add_action('rest_after_insert_post', 'uhp24_browsersync_save', 10, 3); add_action('save_post', 'uhp24_browsersync_save', 10, 3); add_action('customize_save_after', 'uhp24_browsersync_save', 10, 3); add_action('wp_update_nav_menu', 'uhp24_browsersync_save', 10, 3); add_action('updated_option', 'uhp24_browsersync_save', 10, 3); /*********************************************************** ######################### Admin ############################ ************************************************************/ add_filter( 'show_admin_bar', '__return_false' ); add_action( 'login_enqueue_scripts', 'uhp24_login_logo' ); function uhp24_login_logo() { $logo_image = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ); ?> remove_help_tabs(); } add_action( 'admin_head-profile.php', 'uhp24_remove_admin_color' ); function uhp24_remove_admin_color() { remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); } add_action( 'admin_bar_menu', 'uhp24_remove_adminbar', 999 ); function uhp24_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_action( 'wp_dashboard_setup', 'uhp24_disable_dashboard_items' ); function uhp24_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( 'screen_options_show_screen', '__return_false' ); add_action('admin_menu', function () { remove_menu_page('edit-comments.php'); }); add_filter( 'custom_menu_order', 'uhp24_menu_order' ); add_filter( 'menu_order', 'uhp24_menu_order' ); function uhp24_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', 'uhp24_remove_admin_pages', 99 ); function uhp24_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' ); } } add_action( 'init', 'uhp24_admin_post_labels' ); function uhp24_admin_post_labels() { global $wp_post_types; $labels = &$wp_post_types['post']->labels; $labels->name = 'News'; $labels->singular_name = 'News'; $labels->add_new = 'Add News'; $labels->add_new_item = 'Add News'; $labels->edit_item = 'Edit News'; $labels->new_item = 'News'; $labels->view_item = 'View News'; $labels->search_items = 'Search News'; $labels->not_found = 'No News found'; $labels->not_found_in_trash = 'No News found in Trash'; $labels->all_items = 'All News'; $labels->menu_name = 'News'; $labels->name_admin_bar = 'News'; } /*********************************************************** ###################### Last Login ########################## ************************************************************/ add_action( 'wp_login', 'uhp24_login_timestamp', 20, 2 ); function uhp24_login_timestamp( $user_login, $user ) { update_user_meta( $user->ID, 'last_login', time() ); } add_filter( 'manage_users_columns', 'uhp24_user_last_login_column' ); function uhp24_user_last_login_column( $columns ) { $columns['last_login'] = 'Last Login'; // column ID / column Title return $columns; } add_filter( 'manage_users_custom_column', 'uhp24_last_login_column', 10, 3 ); function uhp24_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', 'uhp24_sortable_columns' ); function uhp24_sortable_columns( $columns ) { return wp_parse_args( array( 'last_login' => 'last_login' ), $columns ); } add_action( 'pre_get_users', 'uhp24_sort_last_login_column' ); function uhp24_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; } /*********************************************************** ######################## Editor ############################ ************************************************************/ add_filter( 'styles_inline_size_limit', '__return_zero' ); add_action( 'enqueue_block_assets', 'uhp24_block_styles', 5 ); function uhp24_block_styles(){ wp_enqueue_style('uhp24-css', get_stylesheet_directory_uri() . '/style.css'); } //add_action( 'admin_enqueue_scripts', 'uhp24_admin_styles' ); function uhp24_admin_styles() { wp_enqueue_style( 'style-editor', get_template_directory_uri().'/style-editor.css' ); } add_filter( 'should_load_remote_block_patterns', 'uhp24_disable_remote_patterns' ); function uhp24_disable_remote_patterns() { return false; } add_action( 'init', 'dwp23_disable_emojis' ); function dwp23_disable_emojis() { remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); add_filter( 'emoji_svg_url', '__return_false' ); } add_action( 'init', 'uhp24_cleaner_header' ); function uhp24_cleaner_header() { remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wp_shortlink_wp_head', 10); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'feed_links_extra', 3 ); remove_action('wp_head', 'feed_links', 2 ); } /*********************************************************** ####################### Comments ########################### ************************************************************/ add_filter('comments_open', '__return_false', 20, 2); add_filter('pings_open', '__return_false', 20, 2); add_action('admin_init','uhp24_disable_comments'); function uhp24_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'); } } }