Commit bf842802 authored by Kevin Cristiano's avatar Kevin Cristiano 🌎

Merge branch 'cau' into 'master'

Cau

See merge request !20
parents b468c52b e2bd0a77
......@@ -5,9 +5,9 @@ This includes a templates directory to override selectors where they are lacking
This extension complements the core CiviCRM CSS file with its own.
This extension supports 4.7.
This extension supports CiviCRM versions 5.8+.
Version 4.7 is based on the /civicrm/css/civicrm.css from the 4.7 release.
This extension will respect the style settings in [CiviCRM Admin Utilities](https://github.com/christianwach/civicrm-admin-utilities)
# Overrides
You can now replace this extension's CSS file with a custom one from your theme. This makes use of the tc_civicss_override filter.
......
......@@ -47,7 +47,7 @@ function csshelper_civicrm_uninstall() {
*/
function csshelper_civicrm_enable() {
_csshelper_civix_civicrm_enable();
civicrm_api3('Setting', 'create', array('disable_core_css' => 1,));
//civicrm_api3('Setting', 'create', array('disable_core_css' => 1,));
}
/**
......@@ -57,7 +57,7 @@ function csshelper_civicrm_enable() {
*/
function csshelper_civicrm_disable() {
_csshelper_civix_civicrm_disable();
civicrm_api3('Setting', 'create', array('disable_core_css' => 0,));
//civicrm_api3('Setting', 'create', array('disable_core_css' => 0,));
}
/**
......@@ -140,43 +140,116 @@ function csshelper_civicrm_preProcess($formName, &$form) {
*/
/*Enqueue default CiviCRM CSS in admin. Create a filter to allow themes and other plugins to overrride */
if ( ! function_exists( 'civi_wp' ) ) {
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 );
}
else {
add_action('admin_enqueue_scripts', 'csshelper_register_admin_civicrm_styles');
};
function csshelper_register_admin_civicrm_styles() {
$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' ) ) {
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 );
}
/*Enqueue default CiviCRM CSS on Front End. Do this so we can use wp_enqueue_style as opposed to the way civicrm forces its styles to load the Drupal way in WP*/
if ( ! function_exists( 'civi_wp' ) ) {
if ( function_exists( 'civi_wp' ) ) {
add_action( 'admin_enqueue_scripts', 'csshelper_register_admin_civicrm_styles' );
}
else {
add_action('wp_print_styles', 'csshelper_register_default_civicrm_styles', 100);
};
/**
* Disable CiviCRM's default CSS on front end.
*/
function csshelper_deregister_civicrm_default_styles() {
// Bail if admin.
if ( is_admin() ) return;
// Bail if CAU has disabled public CSS.
if ( csshelper_cau_has_disabled_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( 'wp_head', 'csshelper_deregister_civicrm_default_styles', 9 );
}
/**
* Enqueue scripts & styles.
*/
function csshelper_register_default_civicrm_styles() {
$tc_civi_css_default = (plugin_dir_url('civicrm') . 'civicrm/civicrm/css/civicrm.css');
// Bail if CAU has disabled public CSS.
if ( csshelper_cau_has_disabled_css() ) return;
// Start by enqueuing default CSS.
$tc_civi_css_default = CRM_Core_Resources::singleton()->getUrl( 'civicrm', 'css/civicrm.css', TRUE );
$tc_civi_css_default = apply_filters('tc_civicss_override_default', $tc_civi_css_default);
wp_enqueue_style ('tad_default_civicrm', $tc_civi_css_default );
wp_enqueue_style( 'tad_default_civicrm', $tc_civi_css_default );
// Next enqueue custom ones.
$tc_ext_url = CRM_Core_Resources::singleton()->getUrl('cc.tadpole.csshelper');
$tc_civi_css = ( $tc_ext_url . 'css/tad-civicrm.css') ;
$tc_civi_css = apply_filters( 'tc_civicss_override', $tc_civi_css );
wp_enqueue_style( 'tad_civicrm', $tc_civi_css, array('tad_default_civicrm') );
}
if ( function_exists( 'civi_wp' ) ) {
add_action('wp_enqueue_scripts', 'csshelper_register_default_civicrm_styles', 100);
}
/*Enqueue custom CiviCRM CSS in front end of site. Create a filter to allow themes and other plugins to overrride */
if ( ! function_exists( 'civi_wp' ) ) {
/**
* Check if CAU has disabled Default CSS on front end.
*/
function csshelper_cau_has_disabled_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_default', '0' );
return ($disabled == '1') ? true : false;
}
else {
add_action('wp_print_styles', 'csshelper_register_civicrm_styles', 110);
};
function csshelper_register_civicrm_styles() {
$tc_ext_url = CRM_Core_Resources::singleton()->getUrl('cc.tadpole.csshelper');
$tc_civi_css = ( $tc_ext_url . 'css/tad-civicrm.css') ;
$tc_civi_css = apply_filters ( 'tc_civicss_override' , $tc_civi_css ) ;
wp_enqueue_style ('tad_civicrm', $tc_civi_css );
/**
* 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
......@@ -15,12 +15,12 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2015-11-17</releaseDate>
<version>4.7</version>
<version>5.0</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
<ver>5.8</ver>
</compatibility>
<comments>Extension to help Front End Developer swith CiviCRM styling in WordPress</comments>
<comments>Extension to help Front End Developer switch CiviCRM styling in WordPress</comments>
<civix>
<namespace>CRM/Csshelper</namespace>
</civix>
......
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