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 / manage-orphan-menu-items.php
Created December 20, 2023 19:59 — forked from benhuson/manage-orphan-menu-items.php
Manage WordPress Orphan Menu Items (drop-in)
<?php
class Manage_Orphan_Menu_Items {
function Manage_Orphan_Menu_Items() {
add_action( 'admin_init', array( $this, 'process_menu_item_delete' ) );
add_action( 'admin_menu', array( $this, 'add_admin_page' ) );
}
function add_admin_page() {
@shazahm1
shazahm1 / heartbeat-api-demo.php
Created July 12, 2023 20:21 — forked from strangerstudios/heartbeat-api-demo.php
Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
<?php
/*
Plugin Name: Heartbeat API Demo
Plugin URI: http://www.strangerstudios.com/wp/heartbeat-api-demo
Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
Version: .1
Author: strangerstudios
If logged in as a user and viewing the frontend of your website,
every 15 seconds you should see the following in your Javascript console:
<?php
class GeoJSON
{
public function __construct(string $geojson)
{
$this->_struct = json_decode($geojson);
}
public static function fromString(string $geojson)

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.

Remove all HTML comments:

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

or remove all HTML comments and trailing newline if it exists:

(?s)<!--.*?-->\n?
@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 <david@gravitywiz.com>
@shazahm1
shazahm1 / grab thumb url.php
Created September 22, 2015 16:28 — forked from freekrai/grab thumb url.php
If no featured image... Grab the first image in the post content.. Or generate a thumbnail based on youtube or vimeo video if that is included instead of an image... then save the image as featured image...
<?php
/**
* Retrieves the thumbnail URL to use for a post
* @param string $text The body of the post (get_content)
* @param string $size The image size to retrieve
* @return string The image URL to use
*/
function get_thumb_url($text, $size){
global $post;
$imageurl = FALSE;
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection