Skip to content

Instantly share code, notes, and snippets.

View alexanderdejong's full-sized avatar

Alexander de Jong alexanderdejong

View GitHub Profile
add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 25 );
function woocommerce_total_product_price() {
global $woocommerce, $product;
// let's setup our divs
echo sprintf('<div id="product_total_price" style="font-size: 16px; font-weight: 200;">%s %s</div>',__('Total Price (incl Tax):','woocommerce'),'<span class="price">'. get_woocommerce_currency_symbol() .' ' .$product->get_price().'</span>');
?>
<script>
jQuery(function($){
var price = <?php echo $product->get_price(); ?>,
currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
@alexanderdejong
alexanderdejong / trim_characters
Created December 20, 2017 14:41
Trim a string in WordPress to a specified number of characters, gracefully stopping at white spaces.
/**
* Trims a string of words to a specified number of characters, gracefully stopping at white spaces.
* Also strips HTML tags, to prevent breaking in the middle of a tag.
*
* @param string $text The string of words to be trimmed.
* @param int $length Maximum number of characters; defaults to 45.
* @param string $append String to append to end, when trimmed; defaults to ellipsis.
*
* @return String of words trimmed at specified character length.
*
@alexanderdejong
alexanderdejong / image_optimize-wordpress.php
Created January 10, 2018 15:30 — forked from wycks/image_optimize-wordpress.php
Remove WordPress full size images from being inserted into a post + option to and add max size to to prevent users from inserting massive images.
<?php
/**
*
* This removes the ability to add the FULL image size into a post, it does not alter or delete the image
* Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
*
* For now we have to do it this way to make the labels translatable, see trac ref below.
*
* If your theme has $content_width GLOBAL make sure and remove it
function ajax_add_to_cart(e) {
if (jQuery(this).hasClass('disabled')) {
// do nothibng
} else {
e.preventDefault();
e.stopPropagation();
/**
** Check what else is hooking into the_content();
**
**/
add_action('template_redirect', 'wpse_44152_template_redirect');
function wpse_44152_template_redirect(){
global $wp_filter;
print_r($wp_filter['the_content']);
}
@alexanderdejong
alexanderdejong / test.php
Last active May 1, 2019 14:24
My first Gistpen
echo 'dafdsagmdagafas fda ga fadfs das f';
@alexanderdejong
alexanderdejong / Controller.php
Created May 10, 2019 09:23 — forked from gmazzap/Controller.php
WordPress plugin to ease the creation of virtual pages.
<?php
namespace GM\VirtualPages;
/**
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
class Controller implements ControllerInterface {
private $pages;
<?php
/**
* @package Smashing_plugin
* @version 1.0
*/
/*
Plugin Name: Smashing plugin
Plugin URI: https://www.smashingmagazine.com/2016/03/advanced-wordpress-search-with-wp_query/
Description: This is an example plugin for Smashing Magazine readers.
Author: Carlo Daniele
<?php
/**
* @package Smashing_plugin
* @version 1.0
*/
/*
Plugin Name: Smashing plugin
Plugin URI: https://www.smashingmagazine.com/2016/03/advanced-wordpress-search-with-wp_query/
Description: This is an example plugin for Smashing Magazine readers.
Author: Carlo Daniele
@alexanderdejong
alexanderdejong / exit-popup.js
Created May 10, 2019 09:27 — forked from rupomkhondaker/exit-popup.js
Exit Popup / exit intent popup script enabling you to display a modal before a user leaves your website
/*
* Exit Popup
* Exit Popup enabling you to display a modal before a user leaves your website
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory(require, exports, module);