Skip to content

Instantly share code, notes, and snippets.

@csalzano
csalzano / phpcs.xml
Last active April 19, 2024 15:08
WordPressNotWordPress coding standard for PHP CodeSniffer. I love the WP coding standard, but I don't want to to be told to use WP functions and APIs in PHP projects that aren't WordPress.
<?xml version="1.0"?>
<!-- WordPressNotWordPress coding standard for PHP CodeSniffer. https://gist.github.com/csalzano/0642ac242d72acb2fbe118482ae593e2 -->
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPressNotWordPress">
<!-- Include the whole WordPress standard -->
<rule ref="WordPress">
<exclude name="WordPress.DB.RestrictedFunctions.mysql_mysqli_connect"/>
<exclude name="WordPress.DB.RestrictedFunctions.mysql_mysqli_error"/>
<exclude name="WordPress.DB.RestrictedFunctions.mysql_mysqli_fetch_assoc"/>
<exclude name="WordPress.DB.RestrictedFunctions.mysql_mysqli_num_rows"/>
<exclude name="WordPress.DB.RestrictedFunctions.mysql_mysqli_query"/>
@csalzano
csalzano / theme.json
Created April 9, 2024 02:50
How to make a Twenty Twenty Four child theme with wider content areas
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"layout": {
"contentSize": "1180px",
"wideSize": "1280px"
}
}
}
@csalzano
csalzano / elementor-form-additional-webhook.php
Last active March 27, 2024 15:26
Elementor Form additional webhook example
<?php
/**
* Plugin Name: Elementor Form Additional Webhook
* Plugin URI: https://gist.github.com/csalzano/dfd754e0fe8b6ac10731fad8f257c0bf
* Description: Adds a second Webhook to an Elementor form
* Version: 1.0.1
* Author: Corey Salzano
* Author URI: https://breakfastco.xyz/
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
@csalzano
csalzano / TextTable.php
Last active December 20, 2023 20:51 — forked from dapepe/TextTable.php
Class to generate a Markdown-style table from a PHP array
<?php
/**
* Creates a markdown document based on the parsed documentation
*
* @author Peter-Christoph Haider <peter.haider@zeyon.net>
* @package Apidoc
* @version 1.00 (2014-04-04)
* @license GNU Lesser Public License
*/
@csalzano
csalzano / use-mailhog.php
Last active December 5, 2023 15:16 — forked from bishless/wp-mailhog.php
Configure WordPress on Valet to use MailHog
<?php
/**
* @link
* @since 1.0.0
* @package TODO
*
* @wordpress-plugin
* Plugin Name: Use MailHog
* Description: Configure WordPress on Valet to use MailHog
* Version: 1.0.0
@csalzano
csalzano / plugin-zipper.bat
Created December 3, 2020 15:52
Zips a directory while excluding .git, node_modules, and .gitingore
::plugin-zipper.bat
::Zips a directory while excluding .git, node_modules, and .gitingore
@echo off
set /p slug=Please enter a directory name/plugin slug:
If /I "%slug%"=="" goto earlyexit
tar -a -c -f "%slug%".zip --exclude ".git" --exclude ".gitignore" --exclude "node_modules" "%slug%"
:earlyexit
@csalzano
csalzano / password-protection-admin-bypass.php
Created June 23, 2022 02:27
WordPress plugin. Allows logged-in administrators to bypass password protection on pages and posts.
<?php
defined( 'ABSPATH' ) or exit;
/**
* Plugin Name: Password Protection Admin Bypass
* Description: Allows logged-in administrators to bypass password protection on pages and posts.
* Version: 1.0.0
* Author: Corey Salzano
* Author URI: https://github.com/csalzano
* Plugin URI: https://gist.github.com/csalzano/f10727dfff7614decbe663912d9c86d9
@csalzano
csalzano / acf-hide-field-front-end.php
Created January 9, 2022 17:42
Hide an ACF field from front-end forms
<?php
/**
* hide_group_id_field
*
* Hides a field when a field group is rendered as a front-end form.
*
* @param array $wrapper
* @param array $field
* @return array
@csalzano
csalzano / wporg-developer-get-template-part.php
Last active March 16, 2021 18:40
Change which template is served in a Twenty Twenty-One child theme to incorporate wporg-developer
<?php
//In single.php of twentytwentyone theme, find this line
get_template_part( 'template-parts/content/content-single' );
//and replace it with this condition to blend the code reference features of the wporg-developer theme
if( DevHub\is_parsed_post_type() )
{
@csalzano
csalzano / thickbox-allow-percent-size.js
Last active September 18, 2019 01:19
Allow the sizes of a thickbox.js modal to be specified as percentages of the viewport instead of pixels
Object.defineProperty(Number.prototype, 'percentOfViewportToPixels', {
enumerable: false,
value: function( heightOrWidth ) {
var viewport_size = 'height' == heightOrWidth
? Math.max( document.documentElement.clientHeight, window.innerHeight || 0 )
: Math.max( document.documentElement.clientWidth, window.innerWidth || 0 );
return Math.round( viewport_size * ( this / 100 ) );
}
});