Skip to content

Instantly share code, notes, and snippets.

View theperfectwill's full-sized avatar
💭
Coding... Working on The WPOnion Framework with Varun

The Perfect Will theperfectwill

💭
Coding... Working on The WPOnion Framework with Varun
View GitHub Profile
@theperfectwill
theperfectwill / breakdance-disable-google-fonts-in-editor.php
Last active October 2, 2023 13:11
Breakdance Builder - Disable google Fonts from Loading or Being Selected in The Breakdance Editor
<?php
// Disable google Fonts from Loading or Being Selected in The Breakdance Editor
// Then you can upload your custom fonts, and they will be the only fonts to select from in the editor
add_filter('breakdance_register_font', function($font) {
$isGoogleFont = !!$font['dependencies']['googleFonts'];
if ($isGoogleFont) return false;
return $font;
}, PHP_INT_MAX, 1);
@theperfectwill
theperfectwill / breakdance-custom-editor-css.php
Last active April 11, 2023 08:25
Load custom styles for the Breakdance editing screen
<?php
// @version->1.1
// Added the 'id' query arg,
// because the Breakdance editor is dependant on 'id' (post_id, numeric value)
// in conjunction with the 'breakdance' query (=='builder') to run
// id: breakdance=builder&id=82829 (as in Bible->Romans 8:28-29)
// @reference->https://www.biblegateway.com/passage/?search=Romans%208%3A28-29&version=AMPC,NKJV
// This just more precisely targets only when the Breakdance editor would load
@theperfectwill
theperfectwill / bricks-element-heading-filter.php
Last active December 1, 2022 21:23
bricks-element-heading-filter.php
<?php
// Plugin Name: Bricks Element - Heading Filter
// Description: Filters the settings of the heading element in Bricks Builder
// Version: 1.0
// Author:
// Author URI:
// Reference: https://academy.bricksbuilder.io/article/filter-bricks-elements-element_name-controls/
<?php
/**
* For a list of all actions, see wp-nested-pages/app/Entities/PostType/PostTypeRepository, line 97
*/
// Hide/Show the "WPML" link if installed
add_filter('nestedpages_row_action_wpml', 'nestedPagesWpmlLink', 10, 2);
function nestedPagesWpmlLink($include, $post_type)
{
return true;
@theperfectwill
theperfectwill / How to load a wordpress plugin at very last.php
Created October 12, 2022 09:28 — forked from bappi-d-great/How to load a wordpress plugin at very last.php
How to load a wordpress plugin at very last - change plugin order to load last
<?php
/*
*
* Use the code at the beginning of a plugin that you want to be laoded at last
*
*/
function this_plugin_last() {
$wp_path_to_this_file = preg_replace('/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__);
$this_plugin = plugin_basename(trim($wp_path_to_this_file));
$active_plugins = get_option('active_plugins');
@theperfectwill
theperfectwill / customizer-links.php
Created September 6, 2022 13:38 — forked from slushman/customizer-links.php
How to link into the WordPress Customizer
@theperfectwill
theperfectwill / register_post_type() - WordPress
Created March 21, 2022 08:24 — forked from jamestrevorlees/register_post_type() - WordPress
register_post_type() example - WordPress
// Create Post Type for the In Person Assessment Logging
function psgp_in_person_assessments_create_post_type() {
/* Set up the arguments for the post type. */
$args = array(
/**
* A short description of what your post type is. As far as I know, this isn't used anywhere
* in core WordPress. However, themes may choose to display this on post type archives.
@theperfectwill
theperfectwill / php-style-guide.md
Created January 16, 2022 14:55 — forked from heiswayi/php-style-guide.md
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@theperfectwill
theperfectwill / is-meta-box-registered.php
Created January 9, 2022 05:11 — forked from natebot/is-meta-box-registered.php
Test if a WordPress meta box has been registered.
<?php
/**
* Check if a meta box has been registered.
* Returns true if the supplied meta box id has been registered. false if not.
* Note that this does not check what page type
* @param String $meta_box_id An id for the meta box.
* @param String $post_type The post type the box is registered to (optional)
* @return mixed Returns boolean or a WP_Error if $wp_meta_boxes is not yet set.
*/
@theperfectwill
theperfectwill / wp-config.php
Created November 6, 2021 13:01 — forked from aydinjavadly/wp-config.php
WordPress - Enable WP_DEBUG only for specific IP address.
<?php
/**
* File: wp-config.php
*
* Enable WordPress debug only for your IP address
*
* Once you know your IP address you can edit your wp-config.php file and edit the WP_DEBUG constant and replace it with this function and your IP address.
*
* NOTE: If you re-boot your router and have a dynamic IP address you will need to update your IP address in wp-config.php
*/