Skip to content

Instantly share code, notes, and snippets.

@intelliweb
intelliweb / social_sharing_links.php
Created August 3, 2013 16:24
Links for sharing posts on several social networks. Using these HTML links vs. buttons/badges provided by social networks is much better for performance (no javascript files, iframes, etc. to load)
@intelliweb
intelliweb / is_tree.php
Last active March 1, 2021 20:57
WP: is_tree() function to check if the current page is the page or a sub page of the page ID specified. Can be used as conditional tag with Widget Logic. Source: http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
<?php
// This function will return true if we are looking at the page in question or one of its sub pages
function is_tree( $pid ) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
if ( is_page($pid) )
return TRUE; // we're at the page or at a sub page
$anc = get_post_ancestors( $post->ID );
@intelliweb
intelliweb / mjml-api-invalid-json-request
Created October 22, 2019 19:33
MJML issue #1736: API sometimes returns invalid JSON
{"mjml":"<mjml><mj-head><mj-preview>%FIRSTNAME%, are you and %SPOUSE_FIRSTNAME% today's giveaway winners?<\/mj-preview><mj-attributes><mj-all font-family=\"Arial, Helvetica, sans-serif\" align=\"center\" \/><mj-button background-color=\"#55aaa4\" border=\"1px solid #499e98\" font-size=\"18px\" \/><mj-text color=\"#555555\" font-size=\"16px\" \/><mj-class name=\"footer-text\" align=\"center\" color=\"#AAAAAA\" font-size=\"11px\" line-height=\"13px\" \/><\/mj-attributes><\/mj-head> <mj-body><mj-section padding=\"0\"><mj-column><mj-image src=\"https:\/\/weddingvibe.com\/images\/email\/wv\/WV-Winner-Announced-header.jpg\" alt=\"WeddingVibe Giveaway Winner Announced\" title=\"WeddingVibe Giveaway Winner Announced\" align=\"center\" width=\"600px\" padding=\"10px 0\"><\/mj-image><\/mj-column><\/mj-section><mj-section padding-top=\"0\"><mj-column><mj-text>Check our Giveaway Winners page to see if you are the winner of...<\/mj-text><mj-text font-size=\"24px\" padding-bottom=\"5px\">Wedding Speech Help<\/mj-text><mj-
@intelliweb
intelliweb / mjml-api-invalid-json-request
Created October 22, 2019 19:33
MJML issue #1736: API sometimes returns invalid JSON
{"mjml":"<mjml><mj-head><mj-preview>%FIRSTNAME%, are you and %SPOUSE_FIRSTNAME% today's giveaway winners?<\/mj-preview><mj-attributes><mj-all font-family=\"Arial, Helvetica, sans-serif\" align=\"center\" \/><mj-button background-color=\"#55aaa4\" border=\"1px solid #499e98\" font-size=\"18px\" \/><mj-text color=\"#555555\" font-size=\"16px\" \/><mj-class name=\"footer-text\" align=\"center\" color=\"#AAAAAA\" font-size=\"11px\" line-height=\"13px\" \/><\/mj-attributes><\/mj-head> <mj-body><mj-section padding=\"0\"><mj-column><mj-image src=\"https:\/\/weddingvibe.com\/images\/email\/wv\/WV-Winner-Announced-header.jpg\" alt=\"WeddingVibe Giveaway Winner Announced\" title=\"WeddingVibe Giveaway Winner Announced\" align=\"center\" width=\"600px\" padding=\"10px 0\"><\/mj-image><\/mj-column><\/mj-section><mj-section padding-top=\"0\"><mj-column><mj-text>Check our Giveaway Winners page to see if you are the winner of...<\/mj-text><mj-text font-size=\"24px\" padding-bottom=\"5px\">Wedding Speech Help<\/mj-text><mj-
@intelliweb
intelliweb / default_wp_robots.txt
Created October 9, 2013 17:59
A good default robots.txt file for WordPress sites
User-agent: *
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content/plugins
Disallow: /wp-content/cache
Disallow: /wp-content/themes
Disallow: /wp-includes/js
Disallow: /trackback
Disallow: /category/*/*
Disallow: */trackback
@intelliweb
intelliweb / add_shortcode.php
Last active January 3, 2018 15:10
WP: add shortcode. Replace SHORTCODE_TAG with whatever text you want to use in the shortcode.
<?php
// Shortcode: [SHORTCODE_TAG]
add_shortcode('SHORTCODE_TAG', 'intw_shortcode_SHORTCODE_TAG');
function intw_shortcode_SHORTCODE_TAG($atts) {
extract( shortcode_atts( array(
'att1' => 'DEFAULT_VALUE',
'att2' => 'DEFAULT_VALUE',
), $atts ) );
ob_start(); ?>
@intelliweb
intelliweb / gf_remove_entry.php
Last active November 28, 2017 19:00
Gravity Forms: automatically delete form entries from a specific form immediately after entry is submitted. Originally: http://www.gravityhelp.com/forums/topic/purposefully-not-save-form-in-entries-database#post-15601
<?php
// Delete form entry immediately after it is processed and saved
// change '_1' to the form ID
add_action('gform_post_submission_1', 'remove_form_entry', 10, 2);
function remove_form_entry($entry, $form){
global $wpdb;
$lead_id = $entry['id'];
$lead_table = RGFormsModel::get_lead_table_name();
@intelliweb
intelliweb / bootstrap_popover_customizations.md
Created October 6, 2013 17:25
Customizing Twitter Bootstrap's popover behavior to open popovers on click, add close button, and keep popovers open until closed via close button or toggled via trigger link.
@intelliweb
intelliweb / CSS_filter_effects.md
Last active November 4, 2016 19:51
CSS Filter Effects

##Browser Compatibility

CSS filters are not currently supported in all browsers:

http://caniuse.com/#search=filters

For cross-browser compatibility, the image needs to be modified and uploaded in final form. CSS filters do, however, allow for quick testing of different filtering combos before editing an image with photo-editing software.

##Resources

@intelliweb
intelliweb / remove_wp_ver_param.php
Created April 2, 2014 19:28
WP: Remove URL version parameter from enqueued styles and scripts
<?php
// Remove WP version parameter from ALL enqueued styles and scripts
add_filter( 'style_loader_src', 'intw_remove_wp_ver_param', 9999 );
add_filter( 'script_loader_src', 'intw_remove_wp_ver_param', 9999 );
function intw_remove_wp_ver_param( $src ) {
if ( strpos( $src, 'ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}