Skip to content

Instantly share code, notes, and snippets.

View alexanderdejong's full-sized avatar

Alexander de Jong alexanderdejong

View GitHub Profile
@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;
@alexanderdejong
alexanderdejong / test.php
Last active May 1, 2019 14:24
My first Gistpen
echo 'dafdsagmdagafas fda ga fadfs das f';
/**
** 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']);
}
function ajax_add_to_cart(e) {
if (jQuery(this).hasClass('disabled')) {
// do nothibng
} else {
e.preventDefault();
e.stopPropagation();
@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
@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.
*