Verified Commit 3a2e1ab1 authored by Kevin Cristiano's avatar Kevin Cristiano 🌎

Move nadoi custom csshelper to v5 and allow for CAU Theme

parent 08d8df1b
......@@ -138,31 +138,117 @@ 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 custom CiviCRM CSS in front end of site. Create a filter to allow themes and other plugins to overrride */
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_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/civicrm.css') ;
$tc_civi_css = apply_filters ( 'tc_civicss_override' , $tc_civi_css ) ;
wp_enqueue_style ('tad_civicrm', $tc_civi_css );
/**
* 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() {
// 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 );
// 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);
}
/**
* 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;
}
/**
* 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,10 +15,10 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2015-11-17</releaseDate>
<version>4.6</version>
<version>5</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.6</ver>
<ver>5.0</ver>
</compatibility>
<comments>Extension to help Front End Developerswith CiviCRM styling in WordPress</comments>
<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