Skip to content

Instantly share code, notes, and snippets.

@zackpyle
zackpyle / *Best Snippets*
Last active May 1, 2024 20:05
Best PHP/JS Snippets
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**
@bnecreative
bnecreative / bne_testimoinals_add_admin_fields.php
Created March 6, 2020 19:06
Testimonials - Add new field to Setting Page
<?php // Don't copy this line...
/*
* BNE Testimonials Settings API
*
* Add new settings to the settings page.
*
*/
function custom_testimoinals_add_settings() {
@lynt-smitka
lynt-smitka / fbclid-nginx.conf
Last active March 13, 2024 18:56
Remove fbclid argument from the URL in Nginx
http {
...
# redirect map in http block - remove fbclid argument from the end
map $request_uri $redirect_fbclid {
"~^(.*?)([?&]fbclid=[a-zA-Z0-9_-]+)$" $1;
}
...
<?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
*
@neilgee
neilgee / acf-rs2.php
Last active July 11, 2023 03:13
Relationship Field ACF as Shortcode
<?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
@Pross
Pross / cachehelper.php
Last active October 18, 2017 18:25
Please use this repo: https://github.com/Pross/beaver-cache-helper This gist will not be updated anymore.
<?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 {
@danielbachhuber
danielbachhuber / collection-filter.js
Last active June 17, 2024 17:40
Add a custom taxonomy dropdown filter to the WordPress Media Library
(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()
@bnecreative
bnecreative / functions.php
Last active April 15, 2020 15:56
Custom Flyout Restrictions for v1.3+
<?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
<?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
*/
@yratof
yratof / functions.php
Created March 10, 2015 14:37
ACF OEmbed with thumbnails
<?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