Verified Commit f543f3cd authored by Kevin Cristiano's avatar Kevin Cristiano 🌎

check for CAU admin settings. Disable and enqueue CiviCRM style sheet in...

check for CAU admin settings.   Disable and enqueue CiviCRM style sheet in admin only if CAU setting is not to pretiffy.  If CAU admin style is enabled allow CAU to handle all admin styles
parent 5df96a33
...@@ -139,7 +139,45 @@ function csshelper_civicrm_preProcess($formName, &$form) { ...@@ -139,7 +139,45 @@ function csshelper_civicrm_preProcess($formName, &$form) {
*/ */
/*Enqueue default CiviCRM CSS in admin. Create a filter to allow themes and other plugins to overrride */
function csshelper_deregister_civicrm_admin_styles() {
//Bail if not in Admin
if ( ! is_admin() ) return;
// Bail if admin css is disabled by CAU
if ( csshelper_cau_has_disabled_admin_css() ) return;
// Disable natively.
$url = CRM_Core_Resources::singleton()->getUrl( 'civicrm', 'css/civicrm.css', true );
$registration = CRM_Core_Region::instance( 'html-header' )->get( $url );
if ( ! empty( $registration ) ) {
CRM_Core_Region::instance( 'html-header' )->update( $url, array( 'disabled' => true ) );
}
}
if ( function_exists( 'civi_wp' ) ) {
add_action( 'admin_head', 'csshelper_deregister_civicrm_admin_styles', 9 );
}
function csshelper_register_admin_civicrm_styles() {
if ( ! function_exists( 'civi_wp' ) ) {
return;
}
// Bail if admin css is disabled by CAU
if ( csshelper_cau_has_disabled_admin_css() ) {
return;
}
$tc_civi_css_admin = ( plugin_dir_url( 'civicrm' ) . 'civicrm/civicrm/css/civicrm.css' );
$tc_civi_css_admin = apply_filters( 'tc_civicss_override_admin', $tc_civi_css_admin );
wp_enqueue_style( 'tad_admin_civicrm', $tc_civi_css_admin );
}
if ( function_exists( 'civi_wp' ) ) {
add_action( 'admin_enqueue_scripts', 'csshelper_register_admin_civicrm_styles' );
}
/** /**
* Disable CiviCRM's default CSS on front end. * Disable CiviCRM's default CSS on front end.
...@@ -197,7 +235,21 @@ function csshelper_cau_has_disabled_css() { ...@@ -197,7 +235,21 @@ function csshelper_cau_has_disabled_css() {
if ( ! function_exists('civicrm_au') ) return false; if ( ! function_exists('civicrm_au') ) return false;
// Get setting and return as boolean. // Get setting and return as boolean.
$disabled = civicrm_au()->single->setting_get( 'css_admin', '0' ); $disabled = civicrm_au()->single->setting_get( 'css_default', '0' );
return ($disabled == '1') ? true : false; return ($disabled == '1') ? true : false;
}
/**
* Check if CAU has disabled Default CSS in admnin.
*/
function csshelper_cau_has_disabled_admin_css() {
// If there's no CAU, it can't have done so.
if ( ! function_exists('civicrm_au') ) return false;
// Get setting and return as boolean.
$disabled = civicrm_au()->single->setting_get( 'css_admin', '0' );
return ($disabled == '1') ? true : false;
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment