Answers.Body: <p>It might be simpler to just tweak the css to apply only to the admin pages using body.wp-admin (there may be more specific CiviCRM or WP classes you can use).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-12T23:29:12.537Z
Answers.Text: Thanks. I've already done that now, but it being a large project I'm keen to cut down on the nmber of resources files loaded, and as I'm copying most of the civi front end pages I need and styling them from my main wp stylesheet I really would like to prevent my custom css from being loaded
Answers.UserDisplayName: redactuk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-13T21:45:23.420Z
Answers.Text: Ah, I get you. I'm not on a computer at the moment, so can't try this out, but I think the handle for de-enqueuing the custom css is just civicrm_custom_css
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-14T14:06:02.150Z
Answers.Text: I've tried again with various combinations of both wp_dequeue_style and wp_dequeue_script but nothing seems to work. My custom css is located at /wp-content/plugins/files/civicrm/custom/css/custom.css, but I'm not sure what exact dequeue should be i.e. by a handle(?) or path to that file, or even if dequue works at all. If you have 5 mins to test this sometime and post code I would be grateful.
Answers.UserDisplayName: redactuk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-18T15:40:54.507Z
Answers.Text: Hm - I'm not having any joy with either dequeueing or trying to find the equivalent method for disabling it as you've disabled the default stylesheet... I will have a further look at how CiviCRM is hooked into wp_head :/
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-18T15:45:42.123Z
Answers.Text: How do you feel about disabling all the css in CiviCRM and running the CiviCRM css through your WP theme (or a WP plugin)?
Answers.UserDisplayName: liblogger
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T10:26:56.550Z
Answers.Text: That's a possible workaround i.e. enqueuing my own custom css for civi just in admin area. I'll give that a try, although this non urgen now in that I've amended my wordpress.tpl to class="crm-container{if $urlIsPublic} crm-public{else} crm-admin{/if}" i.e. defining unique top level id via which to separate css.
Answers.UserDisplayName: redactuk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-12T13:09:42.823Z
Answers.LastActivityDate: 2016-01-12T13:09:42.823Z
Answers.UserDisplayName: liblogger
Answers.Body: <p><a href="https://wordpress.org/plugins/civicrm-admin-utilities/" rel="nofollow noreferrer">CiviCRM Admin Utilities</a> version 0.4.1 introduces options on the plugin's Settings screen to disable (on the front-end of your website):</p>
  
  <ul>
  <li>the default CiviCRM stylesheet</li>
  <li>the CiviCRM menu stylesheet</li>
  </ul>
  
  <p>And, when the Shoreditch extension is enabled, you can also disable:</p>
  
  <ul>
  <li>the Shoreditch custom stylesheet</li>
  <li>the Shoreditch Bootstrap stylesheet</li>
  </ul>
  
  <p>For reference, the following code will disable <em>any</em> custom stylesheet defined in CiviCRM when not in WordPress admin:</p>
  
  <pre><code>add_action( 'wp_head', 'my_disable_resources', 9 );
  function my_disable_resources() {
  
      // front-end only please
      if ( is_admin() ) return;
  
      // bail if CiviCRM isn't present and inited
      if ( ! function_exists( 'civi_wp' ) ) return;
      if ( ! civi_wp()-&gt;initialize() ) return;
  
      // get CiviCRM config
      $config = CRM_Core_Config::singleton();
  
      // bail if there's no custom CSS file
      if ( empty( $config-&gt;customCSSURL ) ) return;
  
      // get registered URL
      $url = CRM_Core_Resources::singleton()-&gt;addCacheCode( $config-&gt;customCSSURL );
  
      // get registration data from region
      $registration = CRM_Core_Region::instance('html-header')-&gt;get( $url );
  
      // bail if not registered
      if ( empty ( $registration ) ) return;
  
      // set to disabled
      CRM_Core_Region::instance('html-header')-&gt;update( $url, array( 'disabled' =&gt; TRUE ) );
  
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-26T12:48:59.303Z
Answers.LastActivityDate: 2018-09-26T12:48:59.303Z
Answers.UserDisplayName: Christian Wach
Answers.Body: <p>Just to clarify, the block of code to drop into your functions.php to disable civiCRM CSS on the front-end only looks like this:</p>
  
  <pre><code>// Remove the CiviCRM styles from front-end displays.
  function my_remove_civicrm_styles() {
      if (!is_admin()) {
          global $civicrm_root;
          if (empty($civicrm_root)) {
              return;
          }
          $civicrm_css = CRM_Core_Resources::singleton()-&gt;getUrl('civicrm', 'css/civicrm.css', TRUE); CRM_Core_Region::instance('html-header')-&gt;update($civicrm_css, array('disabled' =&gt; TRUE));
      }
  }
  add_action( 'wp_print_styles', 'my_remove_civicrm_styles', 100 );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-30T00:43:10.403Z
Answers.LastActivityDate: 2016-01-30T00:43:10.403Z
Answers.UserDisplayName: Jeff van Loben Sels
Answers.Body: <p>Just an improvement for @<a href="https://civicrm.stackexchange.com/users/2708/jeff-van-loben-sels">jeff-van-loben-sels</a>'s answer (which saved my day). I've just added a condition on <code>CRM_Core_Resources</code> to prevent a fatal error.</p>
  
  <pre><code>function my_remove_civi_style() {
    if (!is_admin()) {
      global $civicrm_root;
      if (!class_exists('CRM_Core_Resources') || empty($civicrm_root)){
          return;
      }
      $civicrm_css = CRM_Core_Resources::singleton()-&gt;getUrl('civicrm', 'css/civicrm.css', TRUE); CRM_Core_Region::instance('html-header')-&gt;update($civicrm_css, array('disabled' =&gt; TRUE));
    }
  }
  add_action( 'wp_print_styles', 'my_remove_civi_style', 100 );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-29T09:15:43.533Z
Answers.LastActivityDate: 2018-03-29T09:15:43.533Z
Answers.UserDisplayName: Bastien Ho
Body: <p>I currently have a custom CSS file specified in Settings > Resource URLS. In this CSS file I override some civicrm.css styles to make the CiviCRM admin screens look a little more like the Wordpress admin area. However, I would like to disable this file when viewing frontend pages e.g. contribution pages.</p>
  
  <p>I've tried the basic usage of the Wordpress wp_dequeue_script option but I can't find what the handle is for this file, so this doesn't work.</p>
  
  <p>Note: I have successfully disabled the standard civicrm.css on my front end pages with this code in functions.php suggested by another user:</p>
  
  <pre><code>function rs_remove_civicrm_styles() {
  
    global $civicrm_root;
  
    if (empty($civicrm_root)) {
     return; 
    }
  
    $civicrm_css = CRM_Core_Resources::singleton()-&gt;getUrl('civicrm', 'css/civicrm.css', TRUE);
    CRM_Core_Region::instance('html-header')-&gt;update($civicrm_css, array('disabled' =&gt; TRUE));
  
  }
  </code></pre>
  
  <p>But I'm not sure same method can be used for the custom css file?</p>
  
Tags: <wordpress><css>
Title: How do I disable custom css on frontend with Wordpress?
ThreadText: # How do I disable custom css on frontend with Wordpress?
  
  (Asked by: username_0 on 2016-01-09)
  
  I currently have a custom CSS file specified in Settings > Resource URLS. In this CSS file I override some civicrm.css styles to make the CiviCRM admin screens look a little more like the Wordpress admin area. However, I would like to disable this file when viewing frontend pages e.g. contribution pages.
  
  I've tried the basic usage of the Wordpress wp\_dequeue\_script option but I can't find what the handle is for this file, so this doesn't work.
  
  Note: I have successfully disabled the standard civicrm.css on my front end pages with this code in functions.php suggested by another user:
  
  ```
  function rs_remove_civicrm_styles() {
  
    global $civicrm_root;
  
    if (empty($civicrm_root)) {
     return; 
    }
  
    $civicrm_css = CRM_Core_Resources::singleton()->getUrl('civicrm', 'css/civicrm.css', TRUE);
    CRM_Core_Region::instance('html-header')->update($civicrm_css, array('disabled' => TRUE));
  
  }
  
  ```
  
  But I'm not sure same method can be used for the custom css file?
  
  **Tags:** wordpress, css
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2016-01-12. Score: 2
  
  It might be simpler to just tweak the css to apply only to the admin pages using body.wp-admin (there may be more specific CiviCRM or WP classes you can use).
  
  > **Comments:**
  > **username_0**: Thanks. I've already done that now, but it being a large project I'm keen to cut down on the nmber of resources files loaded, and as I'm copying most of the civi front end pages I need and styling them from my main wp stylesheet I really would like to prevent my custom css from being loaded  
  > **username_1**: Ah, I get you. I'm not on a computer at the moment, so can't try this out, but I think the handle for de-enqueuing the custom css is just civicrm_custom_css  
  > **username_0**: I've tried again with various combinations of both wp_dequeue_style and wp_dequeue_script but nothing seems to work. My custom css is located at /wp-content/plugins/files/civicrm/custom/css/custom.css, but I'm not sure what exact dequeue should be i.e. by a handle(?) or path to that file, or even if dequue works at all. If you have 5 mins to test this sometime and post code I would be grateful.  
  > **username_1**: Hm - I'm not having any joy with either dequeueing or trying to find the equivalent method for disabling it as you've disabled the default stylesheet... I will have a further look at how CiviCRM is hooked into wp_head :/  
  > **username_1**: How do you feel about disabling all the css in CiviCRM and running the CiviCRM css through your WP theme (or a WP plugin)?  
  > **username_0**: That's a possible workaround i.e. enqueuing my own custom css for civi just in admin area. I'll give that a try, although this non urgen now in that I've amended my wordpress.tpl to class="crm-container{if $urlIsPublic} crm-public{else} crm-admin{/if}" i.e. defining unique top level id via which to separate css.  
  
  ---
  
  ### Answer by username_2 on 2018-09-26. Score: 1
  
  [CiviCRM Admin Utilities](https://wordpress.org/plugins/civicrm-admin-utilities/) version 0.4.1 introduces options on the plugin's Settings screen to disable (on the front-end of your website):
  
  * the default CiviCRM stylesheet
  * the CiviCRM menu stylesheet
  
  And, when the Shoreditch extension is enabled, you can also disable:
  
  * the Shoreditch custom stylesheet
  * the Shoreditch Bootstrap stylesheet
  
  For reference, the following code will disable *any* custom stylesheet defined in CiviCRM when not in WordPress admin:
  
  ```
  add_action( 'wp_head', 'my_disable_resources', 9 );
  function my_disable_resources() {
  
      // front-end only please
      if ( is_admin() ) return;
  
      // bail if CiviCRM isn't present and inited
      if ( ! function_exists( 'civi_wp' ) ) return;
      if ( ! civi_wp()->initialize() ) return;
  
      // get CiviCRM config
      $config = CRM_Core_Config::singleton();
  
      // bail if there's no custom CSS file
      if ( empty( $config->customCSSURL ) ) return;
  
      // get registered URL
      $url = CRM_Core_Resources::singleton()->addCacheCode( $config->customCSSURL );
  
      // get registration data from region
      $registration = CRM_Core_Region::instance('html-header')->get( $url );
  
      // bail if not registered
      if ( empty ( $registration ) ) return;
  
      // set to disabled
      CRM_Core_Region::instance('html-header')->update( $url, array( 'disabled' => TRUE ) );
  
  }
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2016-01-30. Score: 1
  
  Just to clarify, the block of code to drop into your functions.php to disable civiCRM CSS on the front-end only looks like this:
  
  ```
  // Remove the CiviCRM styles from front-end displays.
  function my_remove_civicrm_styles() {
      if (!is_admin()) {
          global $civicrm_root;
          if (empty($civicrm_root)) {
              return;
          }
          $civicrm_css = CRM_Core_Resources::singleton()->getUrl('civicrm', 'css/civicrm.css', TRUE); CRM_Core_Region::instance('html-header')->update($civicrm_css, array('disabled' => TRUE));
      }
  }
  add_action( 'wp_print_styles', 'my_remove_civicrm_styles', 100 );
  
  ```
  
  
  ---
  
  ### Answer by username_4 on 2018-03-29. Score: 0
  
  Just an improvement for @[username_3-van-loben-username_3](https://civicrm.stackexchange.com/users/2708/username_3-van-loben-username_3)'s answer (which saved my day). I've just added a condition on `CRM_Core_Resources` to prevent a fatal error.
  
  ```
  function my_remove_civi_style() {
    if (!is_admin()) {
      global $civicrm_root;
      if (!class_exists('CRM_Core_Resources') || empty($civicrm_root)){
          return;
      }
      $civicrm_css = CRM_Core_Resources::singleton()->getUrl('civicrm', 'css/civicrm.css', TRUE); CRM_Core_Region::instance('html-header')->update($civicrm_css, array('disabled' => TRUE));
    }
  }
  add_action( 'wp_print_styles', 'my_remove_civi_style', 100 );
  
  ```
  
  
  ---
  
  