123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- <?php
- /***********************************************************
- #################### Setup WordPress #######################
- ************************************************************/
- require get_theme_file_path( '/inc/smtp.php' );
- //require get_template_directory() . '/inc/smtp.php';
- function wpmu_list_sites() {
- $subsites = get_sites();
- if ( ! empty ( $subsites ) ) {
- echo '<ul class="subsites">';
- foreach( $subsites as $subsite ) {
- $subsite_id = get_object_vars( $subsite )["blog_id"];
- $subsite_name = get_blog_details( $subsite_id )->blogname;
- $subsite_link = get_blog_details( $subsite_id )->siteurl;
- echo '<li class="site-' . $subsite_id . '"><a href="' . $subsite_link . '">' . $subsite_name . '</a></li>';
- }
- echo '</ul>';
- }
- }
- function hbr_global_menu() {
- if (!in_array(get_current_blog_id(), array(2))){ //display on these subsites only
- switch_to_blog( '1' );
- if (is_nav_menu(8)){
- wp_nav_menu( ['menu' => '8', 'menu_class' => 'hbr-global-menu',]);
- }
- restore_current_blog();
- }
- }
- /*************************************************
- // ######### Child Theme (& Editor) ############ //
- **************************************************/
- function twentytwentyone_styles() {
- wp_enqueue_style( 'child-style', get_stylesheet_uri(),
- array( 'twenty-twenty-one-style' ), wp_get_theme()->get('Version') );
- }
- add_action( 'wp_enqueue_scripts', 'twentytwentyone_styles');
- function hbr_add_editor_styles() {
- add_editor_style( 'style-editor.css' );
- }
- add_action( 'admin_init', 'hbr_add_editor_styles' );
- function hbr_theme_setup() {
- add_theme_support( 'align-wide' );
- add_theme_support( 'editor-color-palette', array (
- array(
- 'name' => esc_attr__( 'black', 'hbr' ),
- 'slug' => 'black',
- 'color' => '#000000',
- ),
- array(
- 'name' => esc_attr__( 'white', 'hbr' ),
- 'slug' => 'white',
- 'color' => '#ffffff',
- ),
- array(
- 'name' => esc_attr__( 'dark grey', 'hbr' ),
- 'slug' => 'darkgrey',
- 'color' => '#8F887B',
- ),
- array(
- 'name' => esc_attr__( 'blue grey', 'hbr' ),
- 'slug' => 'bluegrey',
- 'color' => '#303740',
- ),
- array(
- 'name' => esc_attr__( 'brown grey', 'hbr' ),
- 'slug' => 'browngrey',
- 'color' => '#3d3d3d',
- ),
- array(
- 'name' => esc_attr__( 'brown', 'hbr' ),
- 'slug' => 'brown',
- 'color' => '#5C584F',
- ),
- array(
- 'name' => esc_attr__( 'dark brown', 'hbr' ),
- 'slug' => 'darkbrown',
- 'color' => '#4F4E4C',
- ),
- array(
- 'name' => esc_attr__( 'paper', 'hbr' ),
- 'slug' => 'paper',
- 'color' => '#DBD8D3',
- ),
- array(
- 'name' => esc_attr__( 'tan', 'hbr' ),
- 'slug' => 'tan',
- 'color' => '#BDB3A2',
- ),
- array(
- 'name' => esc_attr__( 'med grey', 'hbr' ),
- 'slug' => 'medgrey',
- 'color' => '#7A7A7A',
- ),
- array(
- 'name' => esc_attr__( 'light blue', 'hbr' ),
- 'slug' => 'lightblue',
- 'color' => '#6D7F8F',
- ),
- array(
- 'name' => esc_attr__( 'grey', 'hbr' ),
- 'slug' => 'grey',
- 'color' => '#B8BCBF',
- ),
- ));
- }
- add_action( 'after_setup_theme', 'hbr_theme_setup', 30 );
- /*************************************************
- // ############### wp_head ################## //
- **************************************************/
- remove_action('wp_head', 'index_rel_link' );
- remove_action('wp_head', 'rel_canonical');
- remove_action('wp_head', 'start_post_rel_link', 10);
- remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);
- remove_action('wp_head', 'wp_shortlink_wp_head', 10);
- remove_action('wp_head', 'parent_post_rel_link', 10);
- remove_action('wp_head', 'rsd_link');
- remove_action('wp_head', 'wlwmanifest_link');
- remove_action('wp_head', 'wp_generator');
- remove_action('wp_head', 'feed_links_extra', 3 );
- remove_action('wp_head', 'feed_links', 2 );
- //remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
- //remove_action('wp_head', 'wp_oembed_add_host_js', 10);
- //remove_action('wp_head', 'rest_output_link_wp_head', 10);
- //remove_action('template_redirect', 'rest_output_link_header', 11, 0);
- add_filter( 'style_loader_src', 'hbr_remove_wp_ver_css_js', 9999 );
- function hbr_remove_wp_ver_css_js( $src ) {
- if ( strpos( $src, 'ver=' ) )
- $src = remove_query_arg( 'ver', $src );
- return $src;
- }
- add_filter( 'xmlrpc_enabled', '__return_false' );
- add_filter( 'wp_headers', 'hbr_disable_x_pingback' );
- function hbr_disable_x_pingback( $headers ) {
- unset( $headers['X-Pingback'] );
- return $headers;
- }
- /*************************************************
- // ############ Dashboard items ################ //
- **************************************************/
- remove_action('welcome_panel', 'wp_welcome_panel');
- //add_filter('screen_options_show_screen', '__return_false');
- add_action('admin_head', 'hbr_remove_help_tabs');
- function hbr_remove_help_tabs() {
- $screen = get_current_screen();
- $screen->remove_help_tabs();
- }
- add_action( 'admin_init', 'hbr_remove_dashboard_meta' );
- function hbr_remove_dashboard_meta() {
- remove_meta_box( 'wp_mail_smtp_reports_widget_lite', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_site_health', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
- }
- /*************************************************
- // ############## Admin pages ################ //
- **************************************************/
- add_action( 'admin_menu', 'hbr_remove_admin_pages', 99 );
- function hbr_remove_admin_pages() {
- remove_menu_page( 'edit-comments.php' );
- //remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
- //remove_menu_page( 'themes.php' );
- //remove_menu_page( 'plugins.php' );
- //remove_menu_page( 'tools.php' );
- //remove_menu_page( 'options-general.php' );
- //remove_menu_page( 'wp-mail-smtp' );
- }
- /*************************************************
- // ############# Admin Bar ################## //
- **************************************************/
- add_filter('show_admin_bar', '__return_false');
- add_filter('show_recent_comments_widget_style', function() { return false; });
- add_action( 'admin_bar_menu', 'hbr_remove_adminbar', 999 );
- function hbr_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_menu( 'comments' );
- $wp_admin_bar->remove_node( 'view-site' );
- $wp_admin_bar->remove_menu( 'edit-profile' );
- }
- /*************************************************
- // ############ Admin footer ############## //
- **************************************************/
- add_filter('admin_footer_text', '__return_empty_string', 1000);
- add_filter('update_footer', '__return_empty_string', 1000);
- /*************************************************
- // ########## Howdy email/adminbar ############# //
- **************************************************/
- add_filter( 'gettext', 'hbr_change_howdy_text', 10, 2 );
- function hbr_change_howdy_text( $translation, $original ) {
- if( 'Howdy, %1$s' == $original )
- $translation = '%1$s';
- return $translation;
- }
- add_filter( 'admin_bar_menu', 'hbr_replace_howdy', 25 );
- function hbr_replace_howdy( $wp_admin_bar ) {
- $my_account = $wp_admin_bar->get_node('my-account');
- $newtext = str_replace( 'Howdy,', '', $my_account->title );
- $wp_admin_bar->add_node( array(
- 'id' => 'my-account',
- 'title' => $newtext,
- ) );
- }
- /***********************************************************
- ###################### Last Login ##########################
- ************************************************************/
- add_action( 'wp_login', 'hbr_login_timestamp', 20, 2 );
- function hbr_login_timestamp( $user_login, $user ) {
- update_user_meta( $user->ID, 'last_login', time() );
- }
- add_filter( 'manage_users_columns', 'hbr_user_last_login_column' );
- function hbr_user_last_login_column( $columns ) {
- $columns['last_login'] = 'Last Login'; // column ID / column Title
- return $columns;
- }
- add_filter( 'manage_users_custom_column', 'hbr_last_login_column', 10, 3 );
- function hbr_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', 'hbr_sortable_columns' );
- function hbr_sortable_columns( $columns ) {
- return wp_parse_args( array(
- 'last_login' => 'last_login'
- ), $columns );
- }
- add_action( 'pre_get_users', 'hbr_sort_last_login_column' );
- function hbr_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;
- }
- add_filter( 'wpmu_users_columns', 'hbr_user_last_login_column' );
|