Forked from BFTrick/woocommerce-add-css-to-emails.php
Last active
August 29, 2015 14:08
-
-
Save whatthefork/4040463537ff35549c0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Add CSS to Emails | |
* Plugin URI: https://gist.github.com/BFTrick/01cc414ee56ce93715ec | |
* 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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment