This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a collection of my most used or most useful PHP and JS snippets | |
**Disclaimer, I didn't write most of these - I just curated them over the years** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Don't copy this line... | |
/* | |
* BNE Testimonials Settings API | |
* | |
* Add new settings to the settings page. | |
* | |
*/ | |
function custom_testimoinals_add_settings() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { | |
... | |
# redirect map in http block - remove fbclid argument from the end | |
map $request_uri $redirect_fbclid { | |
"~^(.*?)([?&]fbclid=[a-zA-Z0-9_-]+)$" $1; | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
*----------------------------------------------------------- | |
* Add publisher logo/image schema for Beaver Builder plugin | |
*----------------------------------------------------------- | |
* | |
* Filter: 'fl_schema_meta_publisher_image_url' | |
* Defined in: bb-plugin/modules/post-grid/post-grid.php | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //<~ don't add me in | |
add_shortcode( 'tl_related_lights', 'tl_related_lights_relationship' ); // Add your shortcode here | |
// Add Relationship field between same CPT | |
function tl_related_lights_relationship() { | |
ob_start(); | |
$posts = get_field('relationship_field_name'); // Add your ACF field in here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Beaver Builder Cache Helper | |
* Description: This plugin will clear various caches when layouts and templates are saved. It also clears the cache when WordPress finishes updating plugins and themes. The plugin also defines the DONOTCACHEPAGE constant when the builder is active, this is respected by most cache plugins. | |
* Version: 1.0 | |
* License: GNU General Public License v2.0 | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
class FL_Cache_Buster { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
/** | |
* Create a new MediaLibraryTaxonomyFilter we later will instantiate | |
*/ | |
var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({ | |
id: 'media-attachment-taxonomy-filter', | |
createFilters: function() { | |
var filters = {}; | |
// Formats the 'terms' we've included via wp_localize_script() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Don't copy this line | |
/* | |
* Custom Flyout Restrictions (With Example Conditional Logic) | |
* | |
* Requires BNE Flyouts v1.3 | |
* | |
* With Flyouts v1.3+, you can restrict pages, post and user roles from | |
* the Flyout settings tab. To further extend this, you can use the filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Gulp Sitemap Generator | |
* Plugin URI: https://gladdy.uk/blog/2014/04/13/using-uncss-and-grunt-uncss-with-wordpress/ | |
* Description: Generate a JSON list of every page on a site so it can be used with Gulp and uncss. | |
* Author: Liam Gladdy | |
* Author URI: http://gladdy.co.uk | |
* Version: 1.0 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Pull apart OEmbed video link to get thumbnails out*/ | |
function get_video_thumbnail_uri( $video_uri ) { | |
$thumbnail_uri = ''; | |
// determine the type of video and the video id | |
$video = parse_video_uri( $video_uri ); | |
// get youtube thumbnail |
NewerOlder