Skip to content

Instantly share code, notes, and snippets.

View ThierryA's full-sized avatar

Thierry Muller ThierryA

View GitHub Profile
@ThierryA
ThierryA / functions.php
Last active January 4, 2016 06:19
WordPress: count actions.
<?php
// Do not include the opening php tag if it is already included in your file.
function your_prefix_count_actions( $tag ) {
global $wp_filter;
if ( !isset( $wp_filter[$tag] ) )
return 0;
@ThierryA
ThierryA / functions.php
Last active October 4, 2015 14:14
Beans: replace WooCommerce pagination with Beans pagination.
<?php
// Do not include the opening php tag if it is already included in your file.
// Replace WooCommerce pagination with Beans pagination..
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
add_action( 'woocommerce_after_shop_loop', 'beans_posts_pagination' );
@ThierryA
ThierryA / functions.php
Last active October 4, 2015 14:14
Beans: add Google Analytics tracking code.
<?php
// Do not include the opening php tag if it is already included in your file.
// Add Google Analytics tracking code to your website's head. Replace UA-0000000-0 with your own Analytics ID.
add_action( 'wp_head', 'beans_child_google_analytics' );
function beans_child_google_analytics() {
?><script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@ThierryA
ThierryA / functions.php
Last active October 8, 2015 07:44
Beans: add ajax UIkit autocomplete.
<?php
// Do not include the opening php tag if it is already included in your file.
add_action( 'beans_uikit_enqueue_scripts', 'beans_child_enqueue_uikit_assets' );
function beans_child_enqueue_uikit_assets() {
// Add the UIkit autocomplete component.
beans_uikit_enqueue_components( 'autocomplete', 'add-ons' );
@ThierryA
ThierryA / functions.php
Last active October 6, 2015 07:53
Beans: change fixed to fluid layout.
<?php
// Do not include the opening php tag if it is already included in your file.
add_action( 'wp', 'beans_child_setup_document' );
function beans_child_setup_document() {
beans_remove_attribute( 'beans_fixed_wrap', 'class', 'uk-container uk-container-center' );
}
@ThierryA
ThierryA / functions.php
Created October 28, 2015 08:44
Beans: disable post image resizing.
<?php
// Do not include the opening php tag if it is already included in your file.
add_filter( 'beans_edit_post_image_args', '__return_false' );
add_filter( 'beans_edit_post_image_small_args', '__return_false' );
@ThierryA
ThierryA / functions.php
Last active November 2, 2015 06:50
Beans: force full width layout on front page.
<?php
// Do not include the opening php tag if it is already included in your file.
add_filter( 'beans_layout', 'beans_child_layout' );
function beans_child_layout( $layout ) {
// Return full width layout of front page.
if ( is_front_page() )
return 'c';
@ThierryA
ThierryA / functions.php
Created November 15, 2015 15:42
Beans: set post default image.
<?php
// Do not include the opening php tag if it is already included in your file.
add_action( 'beans_post_body', 'beans_child_default_post_image', 5 );
function beans_child_default_post_image() {
// Stop here if the post has an image set.
if ( has_post_thumbnail() )
return;
@ThierryA
ThierryA / functions.php
Last active November 19, 2015 17:32
Beans: display excerpt on home/front page.
<?php
// Do not include the opening php tag if it is already included in your file.
add_filter( 'the_content', 'beans_child_modify_post_content' );
function beans_child_modify_post_content( $content ) {
// Return the excerpt() if it exists and if it is the home/fron page.
if ( has_excerpt() && ( is_home() || is_front_page() ) )
return '<p>' . get_the_excerpt() . '</p><p>' . beans_post_more_link() . '</p>';
@ThierryA
ThierryA / functions.php
Created November 20, 2015 06:29
Beans: simple responsive images example.
<?php
// Do not include the opening php tag if it is already included in your file.
add_action( 'beans_post_body_prepend_markup', 'beans_child_reponsive_image_sample' );
function beans_child_reponsive_image_sample() {
$src = 'http://images.apple.com/euro/ipad-mini-4/a/screens_alt/images/overview/hero_large.png';
$small = beans_edit_image( $src, array(
'resize' => array( 465, false ),