Skip to content

Instantly share code, notes, and snippets.

View barrykooij's full-sized avatar
:shipit:
I may be slow to respond.

Barry Kooij barrykooij

:shipit:
I may be slow to respond.
View GitHub Profile
Correct:
<?php echo $name; ?>
Incorrect:
<?= $name ?>
@barrykooij
barrykooij / rp4wp-change-excerpt-length.php
Created November 16, 2014 19:26
Related Posts for WordPress Change Excerpt Length
<?php
function rp4wp_change_post_excerpt_length( $excerpt_length ) {
return '10';
}
add_filter( 'rp4wp_general_post_excerpt_length', 'rp4wp_change_post_excerpt_length' );
<?php
// Display related posts of current post
rp4wp_children();
// Display related posts of specific post
rp4wp_children( 2 );
// Return output instead of displaying it
<?php
function rp4wp_example_remove_hook() {
$hook_instance = RP4WP_Manager_Hook::get_hook_object( 'RP4WP_Hook_Frontend_Css' );
remove_action( 'wp_head', array( $hook_instance, 'run' ), $hook_instance->get_priority() );
}
add_action( 'init', 'rp4wp_example_remove_hook' );
<?php
function rp4wp_example_remove_filter() {
$filter_instance = RP4WP_Manager_Filter::get_filter_object( 'RP4WP_Filter_After_Post' );
remove_filter( 'the_content', array( $filter_instance, 'run' ), $filter_instance->get_priority() );
}
add_action( 'init', 'rp4wp_example_remove_filter' );
add_filter( 'rp4wp_append_content', '__return_false' );
<?php
function rp4wp_example_my_thumbnail_size( $thumb_size ) {
return 'my-thumbnail-size';
}
add_filter( 'rp4wp_thumbnail_size', 'rp4wp_example_my_thumbnail_size' );
@barrykooij
barrykooij / rp4wp-change-title-weight.php
Last active August 29, 2015 14:07
RP4WP Change Title Weight
<?php
function rp4wp_example_title_weight( $weight ) {
return 100;
}
add_filter( 'rp4wp_weight_title', 'rp4wp_example_title_weight' );
@barrykooij
barrykooij / class-wc-bk-settings.php
Last active October 11, 2018 17:52
WooCommerce Settings Class
<?php
if ( !defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
if ( !class_exists( 'WC_BK_Settings' ) ) {
class WC_BK_Settings {
const SETTINGS_NAMESPACE = 'YOUR_SETTINGS_NAMESPACE';
@barrykooij
barrykooij / gist:25e9aeaa92458c7c4b61
Last active August 29, 2015 14:05
alter_bacs_gateways
<?php
add_filter( 'woocommerce_payment_gateways', 'alter_bacs_gateways' );
function alter_bacs_gateways( $methods ) {
$bacs_needle = array_search( 'WC_Gateway_BACS', $methods );
if ( false !== $bacs_needle ) {
$methods[ $bacs_needle ] = 'WC_Gateway_BACS_custom';
}