Skip to content

Instantly share code, notes, and snippets.

@simonwheatley
Last active December 15, 2015 04:39
Show Gist options
  • Save simonwheatley/5202993 to your computer and use it in GitHub Desktop.
Save simonwheatley/5202993 to your computer and use it in GitHub Desktop.
WP Cycling Project Notices
<?php
/*
Plugin Name: WP Cycling Project Notices
Plugin URI: https://gist.github.com/simonwheatley/5202993
Description: Adds notices above the WooCommerce cart and checkout for WP Cycling Project
Version: 1.0
Author: Code for the People
Author URI: http://www.codeforthepeople.com/
*/
/* Copyright 2013 Code for the People Ltd
_____________
/ ____ \
_____/ \ \ \
/\ \ \___\ \
/ \ \ \
/ / / _______\
/ / / \ /
/ / / \ /
\ \ \ _____ ___\ /
\ \ /\ \ / \
\ \ / \____\/ _____\
\ \/ / / / \
\ /____/ /___\
\ /
\______________________/
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
* @package CFTP_WPCP_Notice
* @subpackage CFTP_WPCP_Notice
**/
class CFTP_WPCP_Notice {
/**
* Singleton stuff.
*
* @access @static
*
* @return CFTP_WPCP_Notice
*/
static public function init() {
static $instance = false;
if ( ! $instance ) {
$class = get_called_class();
$instance = new $class;
}
return $instance;
}
/**
* Class constructor
*
* @return null
*/
function __construct() {
add_action( 'woocommerce_before_cart_contents', array( $this, 'action_add_cart_notice' ) );
add_action( 'woocommerce_before_checkout_form', array( $this, 'action_add_checkout_notice' ) );
}
/**
* Hooks the WooCommerce woocommerce_before_cart_contents
* action to add the notice.
*
* @action woocommerce_before_cart_contents
*
* @return array An array of contact types
*/
function action_add_cart_notice() {
?>
<p class="note cftp-wpcp-notice" id="cftp-wpcp-cart-notice">Hello, I am a notice in the cart… edit me in the plugin.</p>
<?php
}
/**
* Hooks the WooCommerce action_add_checkout_notice
* action to add the notice.
*
* @action action_add_checkout_notice
*
* @return array An array of contact types
*/
function action_add_checkout_notice() {
?>
<p class="note cftp-wpcp-notice" id="cftp-wpcp-checkout-notice">Hello, I am a notice in the checkout… edit me in the plugin.</p>
<?php
}
}
// Initiate the singleton
CFTP_WPCP_Notice::init();
<?php
/*
Plugin Name: WP Cycling Project Notices
Plugin URI: https://gist.github.com/simonwheatley/5202993
Description: Adds notices above the WooCommerce cart and checkout for WP Cycling Project
Version: 1.0
Author: Code for the People
Author URI: http://www.codeforthepeople.com/
Network: true
*/
/* Copyright 2013 Code for the People Ltd
_____________
/ ____ \
_____/ \ \ \
/\ \ \___\ \
/ \ \ \
/ / / _______\
/ / / \ /
/ / / \ /
\ \ \ _____ ___\ /
\ \ /\ \ / \
\ \ / \____\/ _____\
\ \/ / / / \
\ /____/ /___\
\ /
\______________________/
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
* @package CFTP_WPCP_Notice
* @subpackage CFTP_WPCP_Notice
**/
class CFTP_WPCP_Notice {
/**
* Singleton stuff.
*
* @access @static
*
* @return CFTP_WPCP_Notice
*/
static public function init() {
static $instance = false;
if ( ! $instance ) {
$class = get_called_class();
$instance = new $class;
}
return $instance;
}
/**
* Class constructor
*
* @return null
*/
function __construct() {
add_action( 'woocommerce_before_cart_contents', array( $this, 'action_add_cart_notice' ) );
add_action( 'woocommerce_before_checkout_form', array( $this, 'action_add_checkout_notice' ) );
}
/**
* Hooks the WooCommerce woocommerce_before_cart_contents
* action to add the notice.
*
* @action woocommerce_before_cart_contents
*
* @return array An array of contact types
*/
function action_add_cart_notice() {
?>
<p class="note cftp-wpcp-notice" id="cftp-wpcp-cart-notice">Hello, I am a notice in the cart… edit me in the plugin.</p>
<?php
}
/**
* Hooks the WooCommerce action_add_checkout_notice
* action to add the notice.
*
* @action action_add_checkout_notice
*
* @return array An array of contact types
*/
function action_add_checkout_notice() {
?>
<p class="note cftp-wpcp-notice" id="cftp-wpcp-checkout-notice">Hello, I am a notice in the checkout… edit me in the plugin.</p>
<?php
}
}
// Initiate the singleton
CFTP_WPCP_Notice::init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment