Skip to content

Instantly share code, notes, and snippets.

@codex73
codex73 / fe-prevent-slug-conflict.php
Created April 25, 2023 12:54 — forked from salcode/fe-prevent-slug-conflict.php
WordPress code to reserve some top level Permalink slugs.
<?php
/**
* Prevent top level permalink slugs that will cause conflicts.
*
* New rewrite slugs are introduced when CPTs or Custom Taxonomies are created.
* This code adds a check when Pages or Posts are created, that their Permalink
* does not conflict with one of the reserved top level slugs you define.
*
* In the case of a bad (i.e conflicting slug), WordPress appends a "-2" to
* the permalink.
@codex73
codex73 / insertTermsFront
Created August 9, 2021 18:04 — forked from jongamble/insertTermsFront
Wordpress insert terms function
<?php
$terms = array(
'Birmingham - AL',
'Dothan - AL',
'Huntsville - AL',
'Montgomery - AL',
'Mobile - AL',
'Anchorage - AK',
'Fairbanks - AK',
'Juneau - AK',
/**
* A bookmarklet for viewing the largest contentful paint in a page.
* Will show each LCP after the bookmarklet is clicked.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
javascript:(function(){
try {
@codex73
codex73 / DownloadCloudwaysLocalBackups.sh
Created March 15, 2021 18:24 — forked from jonom/DownloadCloudwaysLocalBackups.sh
CloudWays - bash script to download local backups for all applications on a server
#!/bin/bash
# CloudWays - Download local backups for all applications
# =======================================================
# * Local backups must be enabled and available. See https://support.cloudways.com/how-to-download-a-full-backup/
# * Add your machine's SSH key to your server so this script needs no input.
# * Backups will be saved inside a new folder with today's date within your nominated backup directory. (This might not be the date the backup was taken.)
# * Only tested on Digital Ocean VPS so far.
# Configuration
@codex73
codex73 / gist:709f3bc5b16c3baf0ee2fd330db21664
Created March 10, 2021 02:24
PHP, EXEC(), WKHTMLTOPDF, CMD LINE: How to use exec() command in PHP to generate pdf by pointing to a html page
// THE BELOW WORKS FOR LOCAL WINDOWS MACHINE FROM A WAMP HOSTED CODEIGNITER SITE - CALL MADE FROM CODEIGNITER CONTROLLER
$myCmd = "C://wamp//bin//wkhtmltopdf//wkhtmltopdf.exe http://proofofconcept.proximitystage.com/email-media-queries C://Users//mosley.j//Desktop//jonnny.pdf";
$result = exec($myCmd,$output,$var);
var_dump($output);
var_dump($var);
// BELOW IS THE CMD LINE CODE/STEPS YOU NEED IN ORDER TO RUN THE SAME THING FROM PURE CMD LINE
@codex73
codex73 / form-content.html
Created September 11, 2020 15:19 — forked from alexmustin/form-content.html
WordPress AJAX Live Search of Post Title
<!-- // The HTML (could be part of page content) // -->
<input type="text" name="keyword" id="keyword" onkeyup="fetch()"></input>
<div id="datafetch">Search results will appear here</div>
@codex73
codex73 / test-php-basic-auth.php
Created June 30, 2020 19:03 — forked from rchrd2/test-php-basic-auth.php
PHP basic auth example
<?php
function require_auth() {
$AUTH_USER = 'admin';
$AUTH_PASS = 'admin';
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
@codex73
codex73 / .gitignore
Created December 21, 2019 22:42 — forked from salcode/.gitignore
See https://salferrarello.com/wordpress-gitignore/ for the latest version of my WordPress .gitignore file
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@codex73
codex73 / varnish-cheatcheet.md
Created October 12, 2019 19:49 — forked from VMBindraban/varnish-cheatcheet.md
Varnish 3 cheatsheet

###Some don't work yet.

Get the top request methods

varnishtop -i RxRequest

Top urls that missed the cache.

varnishtop -i TxURL

@codex73
codex73 / ajax.js
Created June 7, 2019 02:49 — forked from franz-josef-kaiser/ajax.js
AJAX in WordPress. Class based example.
( function( $, plugin ) {
"use strict";
// Working with promises to bubble event later than core.
$.when( someObjectWithEvents ).done( function() {
console.log( 'AJAX request done.' );
} )
.then( function() {
setTimeout( function() {
console.log( 'AJAX requests resolved.' );