Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save piotroq/11a3359d93b22f641b3e3215dff872a0 to your computer and use it in GitHub Desktop.
Save piotroq/11a3359d93b22f641b3e3215dff872a0 to your computer and use it in GitHub Desktop.

Revisions

  1. @BFTrick BFTrick revised this gist Oct 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion woocommerce-add-css-to-emails.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?php
    /**
    * Plugin Name: WooCommerce Add CSS to Emails
    * Plugin URI: https://gist.github.com/BFTrick/_________
    * Plugin URI: https://gist.github.com/BFTrick/01cc414ee56ce93715ec
    * Description: Add CSS styles to WooCommerce emails
    * Author: Patrick Rauland
    * Author URI: http://speakinginbytes.com/
  2. @BFTrick BFTrick created this gist Oct 8, 2014.
    80 changes: 80 additions & 0 deletions woocommerce-add-css-to-emails.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    <?php
    /**
    * Plugin Name: WooCommerce Add CSS to Emails
    * Plugin URI: https://gist.github.com/BFTrick/_________
    * Description: Add CSS styles to WooCommerce emails
    * Author: Patrick Rauland
    * Author URI: http://speakinginbytes.com/
    * Version: 1.0
    *
    * This program is free software: you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation, either version 3 of the License, or
    * (at your option) any later version.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with this program. If not, see <http://www.gnu.org/licenses/>.
    *
    */


    if ( ! class_exists( 'WC_Add_CSS_To_Email' ) ) :

    class WC_Add_CSS_To_Email {

    protected static $instance = null;

    /**
    * Initialize the plugin.
    *
    * @since 1.0
    */
    private function __construct() {
    if ( class_exists( 'WooCommerce' ) && class_exists( 'WC_Emails' ) ) {

    // set subject
    add_filter( 'woocommerce_email_styles', array( $this, 'add_styles' ) );
    }
    }


    /**
    * Return the CSS for WooCommerce emails
    *
    * @return string css for emails
    * @since 1.0
    */
    public function add_styles( $css ) {

    $css = $css . "p {color: red}";

    return $css;
    }


    /**
    * Return an instance of this class.
    *
    * @return object A single instance of this class.
    * @since 1.0
    */
    public static function get_instance() {
    // If the single instance hasn't been set, set it now.
    if ( null == self::$instance ) {
    self::$instance = new self;
    }

    return self::$instance;
    }


    }

    add_action( 'admin_init', array( 'WC_Add_CSS_To_Email', 'get_instance' ), 0 );

    endif;