Skip to content

Instantly share code, notes, and snippets.

View dlxsnippets's full-sized avatar

DLX Snippets dlxsnippets

View GitHub Profile
@dlxsnippets
dlxsnippets / gf-edd-license-helper.php
Created July 3, 2022 04:31
Gravity Forms and Easy Digital Downloads Licensing: Sample licensing class that you can use to set up licenses with a Gravity Forms add-on.
<?php
// don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die();
}
/**
* Gravity Forms ClickUp Add-On.
*
* @since 1.0.0
@dlxsnippets
dlxsnippets / has-posts-only.php
Created July 11, 2022 13:37
Show Highlight and Share on Posts only
<?php
/**
* Show Highlight and Share on posts only.
*
* @package highlight-and-share
*/
// Hide on all excerpts.
add_filter( 'has_enable_excerpt', '__return_false' );
@dlxsnippets
dlxsnippets / enable-breadcrumbs-in-rankmath.php
Last active August 7, 2022 06:13
Enable Breadcrumbs in Rankmath
<?php
// I'm not sure which version, but Rankmath started requiring opt-in for themes.
// I think that's stupid. So I wrote this.
// Place as an mu-plugin or include via Code Snippets: https://wordpress.org/plugins/code-snippets/
add_action( 'after_setup_theme', function() {
add_theme_support( 'rank-math-breadcrumbs' );
} );
@dlxsnippets
dlxsnippets / is_multisite-perform-tasks.php
Last active September 12, 2022 00:50
WordPress Function: is multisite. Check whether to perform multisite related tasks.
<?php
/**
* Checks if the plugin is installed and activated on a multisite install.
*
* @since 1.0.0
*
* @param bool $network_admin Check if in network admin.
* @param string $slug Plugin slug.
*
* @return true if multisite, false if not.
@dlxsnippets
dlxsnippets / check-plugin-active-site.php
Created September 12, 2022 05:05
Check if a plugin is active for a site
<?php
/**
* Checks to see if an asset is activated or not.
*
* @since 1.0.0
*
* @param string $path Path to the asset.
* @param string $type Type to check if it is activated or not.
*
* @return bool true if activated, false if not.
@dlxsnippets
dlxsnippets / sanitize-block-attributes.php
Created September 12, 2022 05:12
Sanitize Block Attributes When They Are Passed
<?php
/**
* Sanitize an attribute based on type.
*
* @param array $attributes Array of attributes.
* @param string $attribute The attribute to sanitize.
* @param string $type The type of sanitization you need (values can be integer, text, float, boolean, url).
*
* @return mixed Sanitized attribute. wp_error on failure.
*/
@dlxsnippets
dlxsnippets / kses-allowed-html-svgs.php
Created September 12, 2022 05:21
Get KSES Allowed HTML with SVGs
<?php
/**
* Returns appropriate html for KSES.
*
* @param bool $svg Whether to add SVG data to KSES.
*/
public static function get_kses_allowed_html( $svg = true ) {
$allowed_tags = wp_kses_allowed_html();
$allowed_tags['nav'] = array(
@dlxsnippets
dlxsnippets / plugins-url-abspath-asset.php
Created September 12, 2022 05:25
Get Plugin Asset URL or Full DIR Path
<?php
/**
* Get the plugin directory for a path.
*
* @param string $path The path to the file.
*
* @return string The new path.
*/
public static function get_plugin_dir( $path = '' ) {
$dir = rtrim( plugin_dir_path( __FILE__ ), '/' );
@dlxsnippets
dlxsnippets / bootstra-chakra-material-colors.scss
Created September 12, 2022 20:08
Bootstrap, Chakra UI, and MaterialUI colors
// Material colors.
$material-success-color: #1e4620;
$material-success-color-accent: #295e2c;
$material-success-color-alt: #2e7d32;
$material-success-color-bold: #4caf50;
$material-success-color-light: #edf7ed;
$material-info-color: #014361;
$material-info-color-accent: #035e88;
$material-info-color-alt: #0277bd;
$material-info-color-bold: #03a9f4;
@dlxsnippets
dlxsnippets / dlx-remove-core-and-third-party-block-patterns.php
Created January 25, 2023 07:53
Remove Core and Third-party Block Patterns
<?php
/**
* Plugin Name: DLX Remove Block Patterns
* Plugin URI: https://dlxplugins.com/plugins/alertsdlx/
* Description: Remove Block Patterns and third-party patterns.
* Version: 1.1.0
* Requires at least: 6.0
* Requires PHP: 7.2
* Author: DLX Plugins
* Author URI: https://dlxplugins.com