Skip to content

Instantly share code, notes, and snippets.

@pbiron
pbiron / shc_attachment_url_to_postid_filter.php
Last active August 16, 2018 14:30
func to hook into WP's attachment_url_to_postid filter to try to resolve attachment URLs for intermediate/backup sizes
<?php
if ( version_compare( get_bloginfo( 'version' ), '4.2', '>=') ) :
/*
* WP 4.0 introduced attachment_url_to_postid(). However, it fails when the
* URL is for an intermediate sized image (e.g., `.../filename-150x150.jpg`).
*
* WP 4.2.0 introduced the attachment_url_to_postid filter. The filter func
* defined below hooks into that filter and attempts remedy that limitation.
*/
add_filter( 'attachment_url_to_postid' , 'shc_attachment_url_to_postid_filter', 10, 2 );
<?php
/*
This script will allow you to send a custom email from anywhere within wordpress
but using the woocommerce template so that your emails look the same.
Created by craig@123marbella.com on 27th of July 2017
Put the script below into a function or anywhere you want to send a custom email
*/
@mathetos
mathetos / plugin.php
Last active April 13, 2023 16:48
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
@gregrickaby
gregrickaby / infinite-scroll-masonry-imagesloaded.php
Last active June 14, 2023 13:01
Infinite Scroll + Masonry + ImagesLoaded
/**
* Be sure to include library scripts in this order. Can be placed either
* in the header or footer.
*/
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-infinitescroll/2.0b2.120519/jquery.infinitescroll.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js"></script>