Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cc.tadpole.csshelper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
extensions
cc.tadpole.csshelper
Commits
bf842802
Commit
bf842802
authored
Dec 17, 2018
by
Kevin Cristiano
🌎
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cau' into 'master'
Cau See merge request
!20
parents
b468c52b
e2bd0a77
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
31 deletions
+104
-31
README.md
README.md
+2
-2
csshelper.php
csshelper.php
+99
-26
info.xml
info.xml
+3
-3
No files found.
README.md
View file @
bf842802
...
...
@@ -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.
...
...
csshelper.php
View file @
bf842802
...
...
@@ -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
info.xml
View file @
bf842802
...
...
@@ -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 swit
c
h CiviCRM styling in WordPress
</comments>
<civix>
<namespace>
CRM/Csshelper
</namespace>
</civix>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment