add_filter( 'plugin_icon', 'fs_custom_optin_icon__premium_only' );
}
// Get all ASE options, default to empty array in case it's not been created yet
$options = get_option( ASENHA_SLUG_U, array() );
// Add style="display:[something];" to the safe CSS attributes.
// Ref: https://github.com/WordPress/wordpress-develop/blob/6.4/src/wp-includes/kses.php#L2329
// Ref: https://wordpress.stackexchange.com/a/195433
add_filter( 'safe_style_css', function ( $styles ) {
$styles[] = 'display';
return $styles;
} );
// ===== Activate modules based on settings =====
// Ensure SVG admin menu icons render with the correct admin color scheme on first paint.
// Modules can register SVG data URI icons with this helper and then use a Dashicon placeholder.
if ( is_admin() ) {
add_action( 'admin_enqueue_scripts', array('ASENHA\\Classes\\Admin_Menu_Svg_Icon_Mask', 'enqueue_mask_css'), 99 );
}
// Content Duplication
if ( array_key_exists( 'enable_duplication', $options ) && $options['enable_duplication'] ) {
$content_duplication = new ASENHA\Classes\Content_Duplication();
add_action( 'admin_action_duplicate_content', [$content_duplication, 'duplicate_content'] );
add_filter(
'page_row_actions',
[$content_duplication, 'add_duplication_action_link'],
20,
2
);
add_filter(
'post_row_actions',
[$content_duplication, 'add_duplication_action_link'],
20,
2
);
add_action( 'admin_bar_menu', [$content_duplication, 'add_admin_bar_duplication_link'], 100 );
add_filter(
'pre_http_request',
[$content_duplication, 'skip_elementor_placeholder_http_import'],
10,
3
);
add_filter( 'wp_handle_sideload_prefilter', [$content_duplication, 'skip_elementor_placeholder_sideload'] );
}
// Content Order
if ( array_key_exists( 'content_order', $options ) && $options['content_order'] ) {
if ( array_key_exists( 'content_order_for', $options ) && !empty( $options['content_order_for'] ) || array_key_exists( 'content_order_for_other_post_types', $options ) && !empty( $options['content_order_for_other_post_types'] ) ) {
$content_order = new ASENHA\Classes\Content_Order();
add_action( 'admin_menu', [$content_order, 'add_content_order_submenu'] );
add_action( 'admin_init', [$content_order, 'maybe_perform_menu_link_redirects'] );
add_action( 'admin_footer', [$content_order, 'add_additional_elements'] );
add_filter( 'admin_enqueue_scripts', [$content_order, 'add_list_tables_scripts'] );
add_action( 'wp_ajax_save_custom_order', [$content_order, 'save_custom_content_order'] );
add_filter( 'pre_get_posts', [$content_order, 'orderby_menu_order'], PHP_INT_MAX );
add_action( 'update_option_' . ASENHA_SLUG_U, [$content_order, 'reset_orderby_menu_order_settings'] );
// TODO: https://developer.wordpress.org/reference/hooks/ajax_query_attachments_args/ (for grid view of media library)
add_filter(
'save_post',
[$content_order, 'set_menu_order_for_new_posts'],
10,
3
);
}
}
// Media Library Access Control
if ( array_key_exists( 'media_files_visibility_control', $options ) && $options['media_files_visibility_control'] ) {
$media_files_visibility_control = new ASENHA\Classes\Media_Files_Visibility_Control();
add_filter( 'ajax_query_attachments_args', [$media_files_visibility_control, 'filter_attachments_grid'] );
add_action( 'pre_get_posts', [$media_files_visibility_control, 'filter_attachments_list'] );
}
// Media Replacement
if ( array_key_exists( 'enable_media_replacement', $options ) && $options['enable_media_replacement'] ) {
$media_replacement = new ASENHA\Classes\Media_Replacement();
$disable_media_replacement_cache_busting = ( isset( $options['disable_media_replacement_cache_busting'] ) ? $options['disable_media_replacement_cache_busting'] : false );
add_filter(
'media_row_actions',
[$media_replacement, 'modify_media_list_table_edit_link'],
10,
2
);
add_action( 'admin_init', [$media_replacement, 'register_attachment_fields_filter'] );
add_action( 'edit_attachment', [$media_replacement, 'replace_media'] );
add_filter( 'post_updated_messages', [$media_replacement, 'attachment_updated_custom_message'] );
// Mayve bust browser cache of old/replaced images by appending a time stamp URL parameter
if ( !$disable_media_replacement_cache_busting ) {
add_filter(
'wp_calculate_image_srcset',
[$media_replacement, 'append_cache_busting_param_to_image_srcset'],
10,
5
);
add_filter(
'wp_get_attachment_image_src',
[$media_replacement, 'append_cache_busting_param_to_attachment_image_src'],
10,
2
);
add_filter(
'wp_prepare_attachment_for_js',
[$media_replacement, 'append_cache_busting_param_to_attachment_for_js'],
10,
2
);
add_filter(
'wp_get_attachment_url',
[$media_replacement, 'append_cache_busting_param_to_attachment_url'],
20,
2
);
}
}
// Media Library Infinite Scrolling
if ( array_key_exists( 'media_library_infinite_scrolling', $options ) && $options['media_library_infinite_scrolling'] ) {
add_filter( 'media_library_infinite_scrolling', '__return_true' );
}
// SVG Upload
if ( array_key_exists( 'enable_svg_upload', $options ) && $options['enable_svg_upload'] && array_key_exists( 'enable_svg_upload_for', $options ) && isset( $options['enable_svg_upload_for'] ) ) {
global $roles_svg_upload_enabled;
$enable_svg_upload = $options['enable_svg_upload'];
$for_roles = $options['enable_svg_upload_for'];
// User has role(s). Do further checks.
if ( isset( $for_roles ) && count( $for_roles ) > 0 ) {
// Assemble single-dimensional array of roles for which SVG upload would be enabled
$roles_svg_upload_enabled = array();
foreach ( $for_roles as $role_slug => $svg_upload_enabled ) {
if ( $svg_upload_enabled ) {
$roles_svg_upload_enabled[] = $role_slug;
}
}
}
$svg_upload = new ASENHA\Classes\SVG_Upload();
add_filter( 'upload_mimes', [$svg_upload, 'add_svg_mime'] );
add_filter(
'wp_check_filetype_and_ext',
[$svg_upload, 'confirm_file_type_is_svg'],
10,
4
);
add_filter( 'wp_handle_sideload_prefilter', [$svg_upload, 'sanitize_and_maybe_allow_svg_upload'] );
add_filter( 'wp_handle_upload_prefilter', [$svg_upload, 'sanitize_and_maybe_allow_svg_upload'] );
add_filter(
'wp_handle_upload',
[$svg_upload, 'sanitize_svg_on_handle_upload'],
10,
2
);
add_filter(
'xmlrpc_prepare_media_item',
[$svg_upload, 'sanitize_xmlrpc_svg_upload'],
10,
2
);
add_action(
'rest_insert_attachment',
[$svg_upload, 'sanitize_after_upload'],
10,
3
);
add_filter(
'wp_generate_attachment_metadata',
[$svg_upload, 'generate_svg_metadata'],
10,
3
);
add_filter( 'wp_calculate_image_srcset', [$svg_upload, 'disable_svg_srcset'] );
if ( !in_array( 'auto-sizes/auto-sizes.php', get_option( 'active_plugins', array() ) ) ) {
// Only add this filter when https://wordpress.org/plugins/auto-sizes/ is not active to prevent PHP deprecation notice
add_filter(
'wp_calculate_image_sizes',
[$svg_upload, 'remove_svg_responsive_image_attr'],
10,
3
);
}
add_action( 'wp_ajax_svg_get_attachment_url', [$svg_upload, 'get_svg_attachment_url'] );
add_filter( 'wp_prepare_attachment_for_js', [$svg_upload, 'get_svg_url_in_media_library'] );
}
// AVIF Upload
if ( array_key_exists( 'enable_avif_upload', $options ) && $options['enable_avif_upload'] ) {
$avif_upload = new ASENHA\Classes\AVIF_Upload();
add_filter( 'mime_types', [$avif_upload, 'add_avif_mime_type'] );
add_filter( 'upload_mimes', [$avif_upload, 'allow_avif_mime_type_upload'] );
add_filter( 'getimagesize_mimes_to_exts', [$avif_upload, 'add_avif_mime_type_to_exts'] );
add_filter(
'wp_generate_attachment_metadata',
[$avif_upload, 'add_avif_image_dimension'],
10,
3
);
add_filter(
'file_is_displayable_image',
[$avif_upload, 'make_avif_displayable'],
10,
2
);
add_filter(
'wp_check_filetype_and_ext',
[$avif_upload, 'handle_exif_and_fileinfo_fail'],
10,
5
);
// WP 6.8+/7.1: allow AVIF uploads when the server cannot generate sub-sizes.
add_filter(
'wp_prevent_unsupported_mime_type_uploads',
[$avif_upload, 'allow_avif_without_editor_support'],
10,
2
);
add_filter( 'plupload_default_settings', [$avif_upload, 'allow_avif_in_plupload'] );
add_filter( 'plupload_init', [$avif_upload, 'allow_avif_in_plupload'] );
}
// External Permalinks
if ( array_key_exists( 'enable_external_permalinks', $options ) && $options['enable_external_permalinks'] ) {
if ( array_key_exists( 'enable_external_permalinks_for', $options ) && !empty( $options['enable_external_permalinks_for'] ) ) {
$external_permalinks = new ASENHA\Classes\External_Permalinks();
add_action(
'add_meta_boxes',
[$external_permalinks, 'add_external_permalink_meta_box'],
10,
2
);
add_action( 'save_post', [$external_permalinks, 'save_external_permalink'] );
// Filter the permalink for use by get_permalink()
add_filter(
'page_link',
[$external_permalinks, 'use_external_permalink_for_pages'],
20,
2
);
add_filter(
'post_link',
[$external_permalinks, 'use_external_permalink_for_posts'],
20,
2
);
add_filter(
'post_type_link',
[$external_permalinks, 'use_external_permalink_for_posts'],
20,
2
);
// Enable redirection to external permalink when page/post is opened directly via it's WP permalink
add_action( 'wp', [$external_permalinks, 'redirect_to_external_permalink'] );
}
}
// Open All External Links in New Tab
if ( array_key_exists( 'external_links_new_tab', $options ) && $options['external_links_new_tab'] ) {
$open_external_links_in_new_tab = new ASENHA\Classes\Open_External_Links_In_New_Tab();
add_filter( 'the_content', [$open_external_links_in_new_tab, 'add_target_and_rel_atts_to_content_links'] );
if ( in_array( 'elementor/elementor.php', get_option( 'active_plugins', array() ) ) ) {
add_filter( 'elementor/frontend/the_content', [$open_external_links_in_new_tab, 'add_target_and_rel_atts_to_content_links'] );
}
}
// Allow Custom Menu Links to Open in New Tab
if ( array_key_exists( 'custom_nav_menu_items_new_tab', $options ) && $options['custom_nav_menu_items_new_tab'] ) {
$custom_nav_menu_items_in_new_tab = new ASENHA\Classes\Custom_Nav_Menu_Items_In_New_Tab();
add_filter(
'wp_nav_menu_item_custom_fields',
[$custom_nav_menu_items_in_new_tab, 'add_custom_nav_menu_open_in_new_tab_field'],
10,
4
);
add_action(
'wp_update_nav_menu_item',
[$custom_nav_menu_items_in_new_tab, 'save_custom_nav_menu_open_in_new_tab_status'],
10,
3
);
add_action(
'nav_menu_link_attributes',
[$custom_nav_menu_items_in_new_tab, 'add_attributes_to_custom_nav_menu_item'],
10,
3
);
}
// Auto-Publishing of Posts with Missed Schedules
if ( array_key_exists( 'enable_missed_schedule_posts_auto_publish', $options ) && $options['enable_missed_schedule_posts_auto_publish'] ) {
$auto_publish_posts_with_missed_schedule = new ASENHA\Classes\Auto_Publish_Posts_With_Missed_Schedule();
add_action( 'wp_head', [$auto_publish_posts_with_missed_schedule, 'publish_missed_schedule_posts'] );
add_action( 'admin_head', [$auto_publish_posts_with_missed_schedule, 'publish_missed_schedule_posts'] );
}
// Hide or Modify Elements / Clean Up Admin Bar
if ( array_key_exists( 'hide_modify_elements', $options ) && $options['hide_modify_elements'] ) {
$cleanup_admin_bar = new ASENHA\Classes\Cleanup_Admin_Bar();
// Priority 5 to execute earlier than the normal 10. This is for removing default items.
add_filter( 'admin_bar_menu', [$cleanup_admin_bar, 'modify_admin_bar_menu'], 5 );
// Priority 100: after third-party Howdy removers on this hook (e.g. Divi Assistant at 10).
add_action( 'wp_before_admin_bar_render', [$cleanup_admin_bar, 'remove_howdy'], 100 );
if ( array_key_exists( 'hide_help_drawer', $options ) && $options['hide_help_drawer'] ) {
add_action( 'admin_head', [$cleanup_admin_bar, 'hide_help_drawer'] );
}
}
// Hide Admin Notices
if ( array_key_exists( 'hide_admin_notices', $options ) && $options['hide_admin_notices'] ) {
$hide_admin_notices = new ASENHA\Classes\Hide_Admin_Notices();
add_action( 'admin_footer', [$hide_admin_notices, 'admin_notices_wrapper'], 9 );
// add_action( 'all_admin_notices', [ $hide_admin_notices, 'admin_notices_wrapper' ] );
// add_action( 'admin_notices', [ $hide_admin_notices, 'show_test_admin_notice_for_all_user_roles' ] );
add_action( 'admin_bar_menu', [$hide_admin_notices, 'admin_notices_menu'] );
add_action( 'admin_print_styles', [$hide_admin_notices, 'admin_notices_menu_inline_css'] );
}
// Disable Dashboard Widgets
if ( array_key_exists( 'disable_dashboard_widgets', $options ) && $options['disable_dashboard_widgets'] ) {
$disable_dashboard_widgets = new ASENHA\Classes\Disable_Dashboard_Widgets();
add_action( 'wp_dashboard_setup', [$disable_dashboard_widgets, 'disable_dashboard_widgets'], PHP_INT_MAX );
add_action( 'admin_init', [$disable_dashboard_widgets, 'maybe_remove_welcome_panel'] );
}
// Hide Admin Bar
if ( array_key_exists( 'hide_admin_bar', $options ) && $options['hide_admin_bar'] ) {
$hide_admin_bar = new ASENHA\Classes\Hide_Admin_Bar();
}
// On the frontend
if ( array_key_exists( 'hide_admin_bar', $options ) && $options['hide_admin_bar'] && array_key_exists( 'hide_admin_bar_for', $options ) && isset( $options['hide_admin_bar_for'] ) ) {
add_filter( 'show_admin_bar', [$hide_admin_bar, 'hide_admin_bar_for_roles_on_frontend'] );
}
// Wider Admin Menu
if ( array_key_exists( 'wider_admin_menu', $options ) && $options['wider_admin_menu'] ) {
$wider_admin_menu = new ASENHA\Classes\Wider_Admin_Menu();
add_action( 'admin_head', [$wider_admin_menu, 'set_custom_menu_width'], 99 );
}
// Admin Menu Organizer
if ( array_key_exists( 'customize_admin_menu', $options ) && $options['customize_admin_menu'] ) {
$options_extra = get_option( ASENHA_SLUG_U . '_extra', array() );
$admin_menu_options = ( isset( $options_extra['admin_menu'] ) ? $options_extra['admin_menu'] : array() );
$admin_menu_organizer = new ASENHA\Classes\Admin_Menu_Organizer();
if ( array_key_exists( 'admin_menu_organizer_sticky_collapse_menu', $options ) && $options['admin_menu_organizer_sticky_collapse_menu'] ) {
add_action( 'admin_head', [$admin_menu_organizer, 'make_collapse_menu_item_sticky'] );
}
add_action( 'admin_menu', [$admin_menu_organizer, 'add_menu_item'] );
// add_action( 'wp_ajax_save_custom_menu_order', [ $admin_menu_organizer, 'save_custom_menu_order' ] );
// add_action( 'wp_ajax_save_hidden_menu_items', [ $admin_menu_organizer, 'save_hidden_menu_items' ] );
if ( array_key_exists( 'custom_menu_order', $admin_menu_options ) ) {
add_filter( 'custom_menu_order', '__return_true', PHP_INT_MAX );
add_filter( 'menu_order', [$admin_menu_organizer, 'render_custom_menu_order'], PHP_INT_MAX );
}
if ( array_key_exists( 'custom_menu_titles', $admin_menu_options ) ) {
add_action( 'admin_menu', [$admin_menu_organizer, 'apply_custom_menu_item_titles'], 10000000001 );
add_action( 'init', [$admin_menu_organizer, 'apply_custom_title_for_posts_menu'] );
}
if ( array_key_exists( 'custom_menu_hidden', $admin_menu_options ) || array_key_exists( 'custom_menu_always_hidden', $admin_menu_options ) ) {
add_action( 'admin_menu', [$admin_menu_organizer, 'hide_menu_items'], 9999999996 );
add_action( 'admin_menu', [$admin_menu_organizer, 'add_hidden_menu_toggle'], 9999999997 );
add_action( 'admin_enqueue_scripts', [$admin_menu_organizer, 'enqueue_toggle_hidden_menu_script'] );
}
add_action( 'wp_ajax_save_admin_menu', [$admin_menu_organizer, 'save_admin_menu'] );
add_action( 'wp_ajax_reset_admin_menu', [$admin_menu_organizer, 'reset_admin_menu'] );
}
// Navigation Menu Duplicator
if ( array_key_exists( 'enable_navigation_menu_duplicator', $options ) && $options['enable_navigation_menu_duplicator'] ) {
$navigation_menu_duplicator = new ASENHA\Classes\Navigation_Menu_Duplicator();
add_action( 'admin_enqueue_scripts', [$navigation_menu_duplicator, 'enqueue_scripts'] );
add_action( 'admin_init', [$navigation_menu_duplicator, 'maybe_handle_duplicate_request'] );
}
// Show Custom Taxonomy Filters
if ( array_key_exists( 'show_custom_taxonomy_filters', $options ) && $options['show_custom_taxonomy_filters'] ) {
$show_custom_taxonomy_filters = new ASENHA\Classes\Show_Custom_Taxonomy_Filters();
add_action( 'restrict_manage_posts', [$show_custom_taxonomy_filters, 'show_custom_taxonomy_filters'] );
add_action( 'pre_get_posts', [$show_custom_taxonomy_filters, 'filter_admin_list_by_taxonomy'] );
}
// Enhance List Tables
if ( array_key_exists( 'enhance_list_tables', $options ) && $options['enhance_list_tables'] ) {
$enhance_list_tables = new ASENHA\Classes\Enhance_List_Tables();
// Show Featured Image Column
if ( array_key_exists( 'show_featured_image_column', $options ) && $options['show_featured_image_column'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'show_featured_image_column'] );
}
// Show Excerpt Column
if ( array_key_exists( 'show_excerpt_column', $options ) && $options['show_excerpt_column'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'show_excerpt_column'] );
}
// Show Last Modified Column
if ( array_key_exists( 'show_last_modified_column', $options ) && $options['show_last_modified_column'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'show_last_modified_column'] );
}
// Show ID Column
if ( array_key_exists( 'show_id_column', $options ) && $options['show_id_column'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'show_id_column'] );
}
// Show File Size Column in Media Library
if ( array_key_exists( 'show_file_size_column', $options ) && $options['show_file_size_column'] ) {
add_filter( 'manage_upload_columns', [$enhance_list_tables, 'add_column_file_size'] );
add_action(
'manage_media_custom_column',
[$enhance_list_tables, 'display_file_size'],
10,
2
);
add_action( 'admin_head', [$enhance_list_tables, 'add_media_styles'] );
}
// Show ID in Action Row
if ( array_key_exists( 'show_id_in_action_row', $options ) && $options['show_id_in_action_row'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'show_id_in_action_row'] );
}
// Hide Date Column
if ( array_key_exists( 'hide_date_column', $options ) && $options['hide_date_column'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'hide_date_column'] );
}
// Hide Comments Column
if ( array_key_exists( 'hide_comments_column', $options ) && $options['hide_comments_column'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'hide_comments_column'] );
}
// Hide Post Tags Column
if ( array_key_exists( 'hide_post_tags_column', $options ) && $options['hide_post_tags_column'] ) {
add_action( 'admin_init', [$enhance_list_tables, 'hide_post_tags_column'] );
}
}
// Various Admin UI Enhancements
if ( array_key_exists( 'various_admin_ui_enhancements', $options ) && $options['various_admin_ui_enhancements'] ) {
$various_admin_ui_enhancements = new ASENHA\Classes\Various_Admin_Ui_Enhancements();
// Display Active Plugins First
if ( array_key_exists( 'display_active_plugins_first', $options ) && $options['display_active_plugins_first'] ) {
add_action( 'admin_head-plugins.php', [$various_admin_ui_enhancements, 'show_active_plugins_first'] );
}
}
// Custom Admin Footer Text
if ( array_key_exists( 'custom_admin_footer_text', $options ) && $options['custom_admin_footer_text'] ) {
$custom_admin_footer_text = new ASENHA\Classes\Custom_Admin_Footer_Text();
// Update footer text
if ( is_asenha() ) {
add_filter( 'admin_footer_text', 'asenha_footer_text', 20 );
} else {
add_filter( 'admin_footer_text', [$custom_admin_footer_text, 'custom_admin_footer_text_left'], 20 );
}
// Update footer version text
if ( is_asenha() ) {
add_filter( 'update_footer', 'asenha_footer_version_text', 20 );
} else {
add_filter( 'update_footer', [$custom_admin_footer_text, 'custom_admin_footer_text_right'], 20 );
}
} else {
// Update footer text
if ( is_asenha() ) {
add_filter( 'admin_footer_text', 'asenha_footer_text', 20 );
}
// Update footer version text
if ( is_asenha() ) {
add_filter( 'update_footer', 'asenha_footer_version_text', 20 );
}
}
// =================================================================
// LOG IN | LOG OUT
// =================================================================
// Change Login URL
if ( array_key_exists( 'change_login_url', $options ) && $options['change_login_url'] ) {
if ( array_key_exists( 'custom_login_slug', $options ) && !empty( $options['custom_login_slug'] ) ) {
$change_login_url = new ASENHA\Classes\Change_Login_URL();
add_action( 'init', [$change_login_url, 'redirect_on_custom_login_url'] );
if ( in_array( 'gravityforms/gravityforms.php', get_option( 'active_plugins', array() ) ) ) {
// Load earlier than Gravity Forms process_exterior_pages()
add_action( 'wp', [$change_login_url, 'prevent_redirect_to_custom_login_url'], 0 );
}
add_filter(
'login_url',
[$change_login_url, 'customize_login_url'],
10,
3
);
add_filter( 'lostpassword_url', [$change_login_url, 'customize_lost_password_url'] );
add_filter( 'register_url', [$change_login_url, 'customize_register_url'] );
add_action( 'wp_loaded', [$change_login_url, 'redirect_on_default_login_urls'] );
add_action( 'wp_login_failed', [$change_login_url, 'redirect_to_custom_login_url_on_login_fail'] );
add_filter( 'login_message', [$change_login_url, 'add_failed_login_message'] );
// No need to modify logout_url or perform redirect on logout
// The customized login URL is already being returned after logout
// add_action( 'wp_logout', [ $change_login_url, 'redirect_to_custom_login_url_on_logout_success' ] );
// add_filter( 'logout_url', [ $change_login_url, 'customize_logout_url' ], 10, 2 );
}
}
// Login ID Type
if ( array_key_exists( 'login_id_type_restriction', $options ) && $options['login_id_type_restriction'] ) {
if ( array_key_exists( 'login_id_type', $options ) && !empty( $options['login_id_type'] ) ) {
$login_id_type = new ASENHA\Classes\Login_ID_Type();
switch ( $options['login_id_type'] ) {
case 'username':
remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );
add_filter( 'login_form_defaults', [$login_id_type, 'change_login_form_defaults'] );
add_filter(
'gettext',
[$login_id_type, 'gettext_login_id_username'],
20,
3
);
break;
case 'email':
add_filter(
'authenticate',
[$login_id_type, 'authenticate_email'],
20,
3
);
add_filter(
'gettext',
[$login_id_type, 'gettext_login_id_email'],
20,
3
);
break;
}
}
}
// Use Site Identity on the Login Page
if ( array_key_exists( 'site_identity_on_login', $options ) && $options['site_identity_on_login'] ) {
$site_identity_on_login_page = new ASENHA\Classes\Site_Identity_On_Login_Page();
add_action( 'login_head', [$site_identity_on_login_page, 'use_site_icon_on_login'] );
add_filter( 'login_headerurl', [$site_identity_on_login_page, 'use_site_url_on_login'] );
}
// Login Logout Menu
if ( array_key_exists( 'enable_login_logout_menu', $options ) && $options['enable_login_logout_menu'] ) {
$login_logout_menu = new ASENHA\Classes\Login_Logout_Menu();
add_action( 'admin_head-nav-menus.php', [$login_logout_menu, 'add_login_logout_metabox'] );
add_filter( 'wp_setup_nav_menu_item', [$login_logout_menu, 'set_login_logout_menu_item_dynamic_url'] );
add_filter( 'wp_nav_menu_objects', [$login_logout_menu, 'maybe_remove_login_or_logout_menu_item'] );
}
// Last Login Column
if ( array_key_exists( 'enable_last_login_column', $options ) && $options['enable_last_login_column'] ) {
$last_login_column = new ASENHA\Classes\Last_Login_Column();
add_action(
'wp_login',
[$last_login_column, 'log_login_datetime'],
3,
1
);
// Earlier than Redirect After Login
add_filter( 'manage_users_columns', [$last_login_column, 'add_last_login_column'] );
add_filter(
'manage_users_custom_column',
[$last_login_column, 'show_last_login_info'],
10,
3
);
add_action( 'admin_print_styles-users.php', [$last_login_column, 'add_column_style'] );
}
// Registration Date Column
if ( array_key_exists( 'registration_date_column', $options ) && $options['registration_date_column'] ) {
$registration_date_column = new ASENHA\Classes\Registration_Date_Column();
add_filter( 'manage_users_columns', [$registration_date_column, 'add_registration_date_column'] );
add_filter(
'manage_users_custom_column',
[$registration_date_column, 'display_registration_date'],
10,
3
);
}
// Redirect After Login
if ( array_key_exists( 'redirect_after_login', $options ) && $options['redirect_after_login'] ) {
if ( array_key_exists( 'redirect_after_login_for', $options ) && !empty( $options['redirect_after_login_for'] ) ) {
$redirect_after_login = new ASENHA\Classes\Redirect_After_Login();
add_filter(
'wp_login',
[$redirect_after_login, 'redirect_after_login'],
5,
2
);
add_filter(
'login_redirect',
[$redirect_after_login, 'filter_login_redirect'],
10,
3
);
}
}
// Redirect After Logout
if ( array_key_exists( 'redirect_after_logout', $options ) && $options['redirect_after_logout'] ) {
if ( array_key_exists( 'redirect_after_logout_for', $options ) && !empty( $options['redirect_after_logout_for'] ) ) {
$redirect_after_logout = new ASENHA\Classes\Redirect_After_Logout();
add_action(
'wp_logout',
[$redirect_after_logout, 'redirect_after_logout'],
5,
1
);
// load earlier than Change Login URL add_action
// add_filter( 'logout_redirect', [ $redirect_after_logout, 'apply_custom_logout_redirect' ], PHP_INT_MAX, 3 );
// add_filter( 'logout_url', [ $redirect_after_logout, 'add_redirect_to_in_logout_url' ], PHP_INT_MAX, 2 );
}
}
// Disable User Account
if ( array_key_exists( 'disable_user_account', $options ) && $options['disable_user_account'] ) {
$disable_user_account = new ASENHA\Classes\Disable_User_Account();
$disable_user_account->register_hooks();
}
// Enable Custom Admin / Frontend CSS
if ( array_key_exists( 'enable_custom_admin_css', $options ) && $options['enable_custom_admin_css'] || array_key_exists( 'enable_custom_frontend_css', $options ) && $options['enable_custom_frontend_css'] ) {
$custom_css = new ASENHA\Classes\Custom_Css();
}
if ( array_key_exists( 'enable_custom_admin_css', $options ) && $options['enable_custom_admin_css'] ) {
// add_filter( 'admin_enqueue_scripts', [ $custom_css, 'custom_admin_css' ] );
add_filter( 'admin_print_footer_scripts', [$custom_css, 'custom_admin_css'] );
}
if ( array_key_exists( 'enable_custom_frontend_css', $options ) && $options['enable_custom_frontend_css'] ) {
add_filter( 'wp_head', [$custom_css, 'custom_frontend_css'] );
}
// Insert
, and