Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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
$taxonomy_name = 'venue';
//Only include venues from the current year in REST API responses
add_filter( "rest_" . $taxonomy_name . "_collection_params", 'hide_old_venues', 10, 2 );
function hide_old_venues( $prepared_args, $request ) {
//Populate the default value of the include argument to only include terms with specific IDs in the meta box
$prepared_args['include']['default'] = get_terms( array(
'taxonomy' => $taxonomy_name,
@csalzano
csalzano / a-provide-licenses.php
Last active March 11, 2019 15:54
A plugin that provides license keys to the EDD SL Updates on Multisite plugin for Inventory Presser add-ons
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: Make Licenses Available for Updates on Multisite
* Plugin URI: https://gist.github.com/csalzano/621deacc33f2482da205f294b445485a
* Description: A plugin that provides license keys to the EDD SL Updates on Multisite plugin for Inventory Presser add-ons
* Version: 1.0.0
* Author: Corey Salzano
* Author URI: https://coreysalzano.com/
* Text Domain: invp-make-licenses-available