123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
- <?php
- function gwp24_styles() {
- wp_enqueue_style(
- 'gwp-style',
- get_stylesheet_uri(),
- [],
- wp_get_theme()->get( 'Version' )
- );
- }
- add_action( 'wp_enqueue_scripts', 'gwp24_styles' );
- /***********************************************************
- ######################## GForms ############################
- ************************************************************/
- function gwp24_add_gf_capabilities(){
- $role = get_role( 'editor' );
- $role->add_cap( 'gform_full_access' );
- }
- add_action( 'admin_init', 'gwp24_add_gf_capabilities' );
- add_filter( 'gform_upload_path', 'gwp24_change_upload_path', 10, 2 );
- function gwp24_change_upload_path( $path_info, $form_id ) {
- $path_info['path'] = '/var/www/greenwoodpromise.com/html/wp-content/uploads/_apps/';
- $path_info['url'] = 'https://greenwoodpromise.com/wp-content/uploads/_apps/';
- return $path_info;
- }
- /***********************************************************
- ###################### BrowserSync #########################
- ************************************************************/
- function add_cors_http_header(){
- header('Access-Control-Allow-Origin: https://gwp.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 gwp24_browsersync_save() {
- $args = [
- 'blocking' => false,
- 'sslverify' => false
- ];
- $request = wp_remote_get('https://gwp.ovid:333/__browser_sync__?method=reload', $args);
- }
- add_action('rest_after_insert_page', 'gwp24_browsersync_save', 10, 3);
- add_action('rest_after_insert_post', 'gwp24_browsersync_save', 10, 3);
- add_action('save_post', 'gwp24_browsersync_save', 10, 3);
- add_action('customize_save_after', 'gwp24_browsersync_save', 10, 3);
- add_action('wp_update_nav_menu', 'gwp24_browsersync_save', 10, 3);
- add_action('updated_option', 'gwp24_browsersync_save', 10, 3);
- /***********************************************************
- ######################## Old Site ##########################
- ************************************************************/
- function gwp24_enqueue_assets() {
- wp_enqueue_script ( 'site-js', get_template_directory_uri() . '/js/site.js' );
- wp_enqueue_style( 'site-css', get_template_directory_uri() . '/css/site.css');
- }
- add_action( 'wp_enqueue_scripts', 'gwp24_enqueue_assets' );
- //remove_theme_support( 'block-templates' );
- add_theme_support( 'block-template-parts' );
- //remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
- //remove_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
- 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' );
- }
- /***********************************************************
- ######################## Editor ############################
- ************************************************************/
- add_theme_support('disable-custom-colors');
- //add_action( 'enqueue_block_assets', 'gwp24_block_styles', 5 );
- function gwp24_block_styles(){
- wp_enqueue_style('gwp24-css', get_stylesheet_directory_uri() . '/css/site.css');
- }
- add_action( 'admin_enqueue_scripts', 'gwp24_admin_styles' );
- function gwp24_admin_styles() {
- wp_enqueue_style( 'style-editor', get_template_directory_uri().'/style-editor.css' );
- }
- remove_theme_support( 'core-block-patterns' );
- add_filter( 'should_load_remote_block_patterns', 'gwp24_disable_remote_patterns' );
- function gwp24_disable_remote_patterns() {
- return false;
- }
- add_filter(
- 'block_editor_settings_all',
- function( $settings ) {
- $settings['enableOpenverseMediaCategory'] = false;
- return $settings;
- },
- 10
- );
- //add_filter( 'allowed_block_types_all', 'gwp24_allowed_block_types', 25, 2 );
- function gwp24_allowed_block_types( $allowed_blocks, $editor_context ) {
- return array(
- 'core/paragraph',
- 'core/heading',
- 'core/list',
- 'core/list-item',
- 'core/table',
- 'core/columns',
- 'core/column',
- 'core/image',
- 'core/gallery',
- 'core/cover',
- 'core/quote',
- 'core/file',
- 'core/video',
- 'core/audio',
- 'core/separator',
- 'core/spacer',
- 'core/shortcode',
- 'core/html',
- 'core/freeform',
- 'core/verse',
- 'core/code',
- 'core/preformatted',
- 'core/pullquote',
- 'core/button',
- 'core/buttons',
- 'core/media-text',
- 'core/more',
- 'core/nextpage',
- 'core/group',
- 'core/heading',
- 'core/subhead',
- 'core/text-columns',
- 'core/row',
- 'core/post-list',
- );
- }
- /***********************************************************
- ######################## Blocks ############################
- ************************************************************/
- function gwp24_restrict_locking_ui( $settings, $context ) {
- $settings[ 'canLockBlocks' ] = current_user_can( 'activate_plugins' );
- return $settings;
- }
- add_filter( 'block_editor_settings_all', 'gwp24_restrict_locking_ui', 10, 2 );
- /***********************************************************
- ######################### Admin ############################
- ************************************************************/
- add_filter('admin_title', 'gwp24_admin_title', 10, 2);
- function gwp24_admin_title($admin_title, $title) {
- return $title .' - '. get_bloginfo('name');
- }
- add_filter ('update_footer', 'gwp24_footer_ver', 999);
- function gwp24_footer_ver ($default) {
- return ''. get_bloginfo( 'version' );
- }
- add_filter ('admin_footer_text', 'gwp24_footer_filter');
- function gwp24_footer_filter ($default) {
- return '';
- }
- add_action('admin_head', 'mytheme_remove_help_tabs');
- function mytheme_remove_help_tabs() {
- $screen = get_current_screen();
- $screen->remove_help_tabs();
- }
- add_action( 'admin_head-profile.php', 'gwp24_remove_admin_color' );
- function gwp24_remove_admin_color() {
- remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
- }
- add_action( 'init', 'gwp24_admin_post_labels' );
- function gwp24_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';
- }
- /***********************************************************
- ####################### Admin Bar ##########################
- ************************************************************/
- add_filter( 'show_admin_bar', '__return_false' );
- add_action( 'admin_bar_menu', 'gwp24_remove_adminbar', 999 );
- function gwp24_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( 'gettext', 'gwp24_change_howdy_text', 10, 2 );
- function gwp24_change_howdy_text( $translation, $original ) {
- if( 'Howdy, %1$s' == $original )
- $translation = '%1$s';
- return $translation;
- }
- /* for email */
- add_filter( 'gettext', 'gwp24_change_howdy_text', 10, 2 );
- function gwp24_change_howdy_text( $translation, $original ) {
- if( 'Howdy, %1$s' == $original )
- $translation = '%1$s';
- return $translation;
- }
- /***********************************************************
- #################### Admin Menus ###########################
- ************************************************************/
- add_action('admin_menu', function () {
- remove_menu_page('edit-comments.php');
- });
- add_filter( 'custom_menu_order', 'gwp24_menu_order' );
- add_filter( 'menu_order', 'gwp24_menu_order' );
- function gwp24_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_filter( 'gform_menu_position', 'gwp23_gform_menu_position', 10, 1 );
- function gwp23_gform_menu_position( $position ) {
- return 15;
- }
- //add_action('wp_dashboard_setup', 'gwp24_remove_dashboard_widgets' );
- function gwp24_remove_dashboard_widgets() {
- remove_meta_box( 'rg_forms_dashboard', 'dashboard', 'side' );
- }
- add_filter('screen_options_show_screen', '__return_false');
- add_action( 'admin_menu', 'gwp24_remove_admin_pages', 99 );
- function gwp24_remove_admin_pages() {
- global $current_user;
- $user_id = get_current_user_id();
- if($user_id != '1') {
- 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');
- }
- }
- /***********************************************************
- ###################### Dashboard ###########################
- ************************************************************/
- add_action( 'wp_dashboard_setup', 'gwp24_disable_dashboard_items' );
- function gwp24_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_quick_press', 'dashboard', 'side');
- remove_meta_box('dashboard_site_health', 'dashboard', 'normal');
- remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
- }
- //add_filter( 'screen_options_show_screen', '__return_false' );
- /***********************************************************
- ###################### Last Login ##########################
- ************************************************************/
- add_action( 'wp_login', 'gwp24_login_timestamp', 20, 2 );
- function gwp24_login_timestamp( $user_login, $user ) {
- update_user_meta( $user->ID, 'last_login', time() );
- }
- add_filter( 'manage_users_columns', 'gwp24_user_last_login_column' );
- function gwp24_user_last_login_column( $columns ) {
- $columns['last_login'] = 'Last Login'; // column ID / column Title
- return $columns;
- }
- add_filter( 'manage_users_custom_column', 'gwp24_last_login_column', 10, 3 );
- function gwp24_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', 'gwp24_sortable_columns' );
- function gwp24_sortable_columns( $columns ) {
- return wp_parse_args( array(
- 'last_login' => 'last_login'
- ), $columns );
- }
- add_action( 'pre_get_users', 'gwp24_sort_last_login_column' );
- function gwp24_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;
- }
- /***********************************************************
- ###################### Log in/out ##########################
- ************************************************************/
- add_filter( 'wp_nav_menu_items', 'gwp24_loginout_menu_link', 10, 2 );
- function gwp24_loginout_menu_link( $items, $args ) {
- if ($args->theme_location == 'bottom') {
- if (is_user_logged_in()) {
- $items .= '<li class="nav-item"><a class="navbar-brand" href="'. wp_logout_url() .'"><i class="bi bi-person-circle fs-5"></i></a></li>';
- } else {
- $items .= '<li class="nav-item"><a class="navbar-brand" href="'. wp_login_url() .'"><i class="bi bi-person-circle fs-5"></i></a></li>';
- }
- }
- return $items;
- }
- add_action( 'login_enqueue_scripts', 'gwp24_login_logo' );
- function gwp24_login_logo() {
- $logo_image = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
- ?>
- <style type="text/css">
- #login h1 a, .login h1 a {
- background-image: url(<?php echo esc_url( $logo_image[0] ); ?>);
- }
- body.login {
- background-color: #006837 !important;
- }
- .login #nav a {
- color: #E9E4DC !important;
- }
- .login #backtoblog a {
- display: none !important;
- }
- </style>
- <?php }
- add_filter( 'login_headerurl', 'gwp24_login_url' );
- function gwp24_login_url() { return home_url(); }
- add_filter( 'login_headertext', 'gwp24_login_title' );
- function gwp24_login_title() { return get_option( 'blogname' ); }
- /***********************************************************
- ######################## Header ############################
- ************************************************************/
- add_action( 'init', 'gwp24_cleaner_header' );
- function gwp24_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 );
- }
- add_action( 'wp_head', 'gwp24_favicon', 100 );
- function gwp24_favicon() {
- echo '<link rel="icon" href="' . esc_url( get_stylesheet_directory_uri() . '/img/_gwp_icon.svg' ) . '" type="image/svg+xml">';
- }
- add_action('wp_head', 'gwp24_add_analytics');
- function gwp24_add_analytics() { ?>
- <script async src="https://www.googletagmanager.com/gtag/js?id=G-53FCS3FYTN"></script>
- <script>
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
- gtag('config', 'G-53FCS3FYTN');
- </script>
- <?php }
- /***********************************************************
- ####################### Comments ###########################
- ************************************************************/
- add_filter('comments_open', '__return_false', 20, 2);
- add_filter('pings_open', '__return_false', 20, 2);
- add_action('admin_init','gwp24_disable_comments');
- function gwp24_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');
- }
- }
- }
- /***********************************************************
- ##################### SVG ##########################
- ************************************************************/
- // Allow SVG
- add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
- global $wp_version;
- if ( $wp_version !== '4.7.1' ) {
- return $data;
- }
- $filetype = wp_check_filetype( $filename, $mimes );
- return [
- 'ext' => $filetype['ext'],
- 'type' => $filetype['type'],
- 'proper_filename' => $data['proper_filename']
- ];
- }, 10, 4 );
- function cc_mime_types( $mimes ){
- $mimes['svg'] = 'image/svg+xml';
- return $mimes;
- }
- add_filter( 'upload_mimes', 'cc_mime_types' );
- function fix_svg() {
- echo '<style type="text/css">
- .attachment-266x266, .thumbnail img {
- width: 100% !important;
- height: auto !important;
- }
- </style>';
- }
- add_action( 'admin_head', 'fix_svg' );
|