Skip to content

Instantly share code, notes, and snippets.

View shazahm1's full-sized avatar
💭
I may be slow to respond.

Steven A. Zahm shazahm1

💭
I may be slow to respond.
View GitHub Profile
@shazahm1
shazahm1 / gw-gravity-forms-ajax-population.php
Created May 12, 2021 13:58 — forked from spivurno/gw-gravity-forms-ajax-population.php
Gravity Wiz // Gravity Forms // AJAX Popluation
<?php
/**
* Gravity Wiz // Gravity Forms // AJAX Population
*
* Populate one or many fields from a remote data source (only .csv files are currently supported) based on the selected value of a field on the form.
*
* Example: You have multiple brands of lumber. The lumber comes in different sizes. You can store each lumber brand and its corresponding length, width, and height in a spreadsheet (csv format) and then populate this data into separate length, width and height fields on the form when a lumber brand is selectd from a drop down field on the form.
*
* @version 1.1
* @author David Smith <[email protected]>
@leepowers
leepowers / wpseo-yoast-sitemap-post-types.php
Created February 12, 2020 05:52
WordPress Yoast SEO: Custom sitemap with data sourced from one or more post types
<?php
/**
* USAGE:
* - Configure the return value of the `CUSTOM_SITEMAP_post_types` to required post type(s) - otherwise populates sitemap with all posts and pages
* - Search and replace the `CUSTOM_SITEMAP` string with a lowercase identifier name: e.g., "myseo", "vehicles", "customer_profiles", "postspage", etc.
* - Uses heredocs for inline XML: https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
*/
/**
@leepowers
leepowers / wpseo-yoast-sitemap-custom.php
Last active March 28, 2024 05:19
WordPress Yoast SEO: Create a custom sitemap with data not sourced from a custom post type.
<?php
/**
* USAGE:
* - Search and replace the `CUSTOM_SITEMAP` string with a lowercase identifier name: e.g., "vehicles", "customer_profiles"
* - The `your_alternate_data_source()` function does not exist; it's simply a placeholder for your own function that returns some sort of data array.
* - Uses heredocs for inline XML: https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
*/
/**
@Pen-y-Fan
Pen-y-Fan / Info for PHPStorm.md
Last active July 21, 2024 12:12
PHPStorm Tips, Tricks and setup

PHPStorm

PhpStorm Tips, ticks and standard setup

  1. Tips and Tracks for PHPStorm (PHPStorm Tips and Tricks.md)
  2. Standard setup for PHP projects (Standard.md)
<?php
/*
Plugin Name: Programmatically add Gravity Forms
Plugin URI: https://daan.kortenba.ch/programmatically-add-gravity-forms/
Description: Programmatically add persistent Gravity Forms forms.
Author: Daan Kortenbach
Version: 0.1
Author URI: https://daan.kortenba.ch/
License: GPLv2 or later
*/

To quickly and easily remove all unwanted comments when using Sublime text, perform a search and replace (CMD, ALT & D) and enter the following. Make sure that regex search is enabled by clicking the small icon in the bottom left that looks like an astrix.

For example, to remove all HTML comments:

(?s)<!--.*?-->

search and replace with blank

Or to remove all CSS comments:

@chrismccoy
chrismccoy / gutenberg.txt
Last active March 13, 2025 19:11
Gutenberg Resources
Eliminate All Blocks from Editor
wp.data.dispatch( 'core/block-editor' ).resetBlocks([]);
How to disable and lock Gutenberg blocks
https://kinsta.com/blog/disable-gutenberg-blocks/
Convert group of file blocks to ACF block
https://bdwm.be/gutenberg-case-study-convert-group-of-file-blocks-to-acf-block/
Enabling Gutenberg-Based Custom Post Types and Taxonomies
@cartpauj
cartpauj / mepr-active-memberships.php
Created March 7, 2018 15:51
Get a list of the current user's active MemberPress Subscriptions
<?php
if(class_exists('MeprUtils')) {
$user = MeprUtils::get_currentuserinfo();
if($user !== false && isset($user->ID)) {
//Returns an array of Membership ID's that the current user is active on
//Can also use 'products' or 'transactions' as the argument type
$active_prodcuts = $user->active_product_subscriptions('ids');
if(!empty($active_prodcuts)) {
@ahmadawais
ahmadawais / upload-a-file.MD
Created June 18, 2017 11:07 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@fumikito
fumikito / request.php
Created March 2, 2017 08:07
A typical jQuery request to WordPress REST API
<?php
/**
* Regsiter script
*/
add_action( 'wp_enqueue_scripts', function() {
// Set dependency to wp-api, which has nonce and endpoint root.
wp_enqueue_script( 'api-handler', '/path/to/api-handler.js', [ 'jquery', 'wp-adpi' ], '1.0', true );
} );