Skip to content

Instantly share code, notes, and snippets.

@shazdeh
shazdeh / gist:7812930
Created December 5, 2013 20:06
Trigger window resize event on page load
<?php
function custom_footer_scripts() { ?>
<script>
jQuery(window).load(function(){ jQuery(window).resize(); });
</script>
<?php }
add_action( 'wp_footer', 'custom_footer_scripts', 99999 );
@shazdeh
shazdeh / gist:7801290
Created December 5, 2013 07:03
Builder: display modules above the post content
<?php
function custom_builder_frontend_display_setup() {
global $ThemifyBuilder;
remove_filter( 'the_content', array( $ThemifyBuilder, 'builder_show_on_front' ), 11 );
add_filter( 'the_content', 'custom_builder_frontend_display', 11 );
}
add_action( 'template_redirect', 'custom_builder_frontend_display_setup' );
@shazdeh
shazdeh / gist:7797982
Created December 5, 2013 00:11
Flatshop: display content in the product lightbox instead of the product description text
<?php
function product_lightbox_full_text() {
if( themify_theme_is_product_lightbox() ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'the_content', 20 );
}
}
add_action( 'init', 'product_lightbox_full_text' );
@shazdeh
shazdeh / gist:7767860
Last active December 30, 2015 03:09
Attachment page redirect with a custom field. Useful when you want to link your images in a [gallery] shortcode.
<?php
function media_custom_field_support() {
add_post_type_support( 'attachment', 'custom-fields' );
}
add_action( 'init', 'media_custom_field_support' );
function do_attachment_redirect() {
if( is_attachment() && $redirect = get_post_meta( $GLOBALS['post']->ID, 'redirect', true ) ) {
wp_redirect( $redirect );
@shazdeh
shazdeh / gist:7663068
Last active December 29, 2015 11:19
Custom theme scripts
<?php
function custom_theme_enqueue_scripts() {
wp_dequeue_script( 'theme-script' );
wp_enqueue_script( 'theme-script', THEME_URI . '/js/themify.custom.script.js', array('jquery'), false, true );
}
add_action( 'wp_enqueue_scripts', 'custom_theme_enqueue_scripts', 12 );
@shazdeh
shazdeh / gist:7631477
Last active December 29, 2015 06:49
Accordion shortcode. It uses Builder's default output. Example: [accordion][accordion_item title="Title 1"]Panel 1 content[/accordion_item][accordion_item title="Title 2"]Panel 2 content[/accordion_item][/accordion]
<?php
function custom_themify_accordion_shortcode( $atts, $content = '' ) {
$class = isset( $atts['style'] ) ? $atts['style'] : '';
$output = '<div class="module module-accordion"><ul class="ui module-accordion '. $class .'">';
$output .= do_shortcode( $content );
$output .= '</ul></div>';
return $output;
}
add_shortcode( 'accordion', 'custom_themify_accordion_shortcode' );
@shazdeh
shazdeh / gist:7580292
Last active December 28, 2015 23:39
logo between top two menus (Magazine)
#headerwrap {
background: none;
}
#header {
background: #0e88be;
width: auto;
margin-top: 180px; /* equal to the height of the logo */
}
@media (min-width: 781px) {
#sidr {
@shazdeh
shazdeh / gist:7546005
Created November 19, 2013 14:15
Custom tile sizes (Metro)
<?php
function register_custom_tile_size( $args ) {
$args[4]['options'][0]['meta'][] = array( 'value' => 'custom', 'img' => 'images/layout-icons/tile-custom.png', 'title' => __( 'Custom', 'themify' ) );
return $args;
}
add_filter( 'themify_do_metaboxes', 'register_custom_tile_size' );
@shazdeh
shazdeh / gist:7534976
Created November 18, 2013 20:44
Enable the right sidebar on single portfolio pages (Parallax)
<?php
function custom_body_classes( $classes ) {
if( is_singular( 'portfolio' ) ) {
$id = array_search( 'sidebar-none', $classes );
unset( $classes[$id] );
$classes[] = 'sidebar1';
}
return $classes;
@shazdeh
shazdeh / gist:7533822
Created November 18, 2013 19:29
Move meta info to the bottom of the post in Elemin
.list-post .post-meta {
top: 100%;
width: 100%;
text-align: left;
}
.list-post .post-meta span,
.post-meta .post-date {
display: inline-block;
margin-right: 10px;
}