Skip to content

Instantly share code, notes, and snippets.

View kpirnie's full-sized avatar
:bowtie:
I may be slow to respond.

Kevin Pirnie kpirnie

:bowtie:
I may be slow to respond.
View GitHub Profile
@kpirnie
kpirnie / clp-renew-certs.py
Created September 5, 2025 13:10
CloudPanel.io Renew LE Certificates if the lets-encrypt:renew:certificates does not exist for you.
#!/usr/bin/env python3
import os
import re
import subprocess
import glob
from datetime import datetime, timedelta
from pathlib import Path
VHOSTS_DIR = "/etc/nginx/sites-enabled"
@kpirnie
kpirnie / functions.php
Last active August 13, 2025 18:20
WordPress - Are We Really in Admin?
/**
* is_in_admin
*
* Check and see if we are indeed in the admin area of the site
*
* @since 7.4
* @access public
* @static
* @author Kevin Pirnie <[email protected]>
* @package Kevin's Framework
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:19
WordPress - Attachment Path from URL
/**
* attachment_url_to_path
*
* Static method for getting the physical server path to an image/attachment/file
* based on it's URL
*
* @since 7.3
* @access public
* @author Kevin Pirnie <[email protected]>
* @package Kevin's Framework
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:19
WordPress - Get All Publilc Post Type URLs
/**
* get_urls
*
* Public method pull to gather all public URLs
*
* @since 7.3
* @access public
* @author Kevin Pirnie <[email protected]>
* @package Kevin's Framework
*
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:18
WordPress - Get ID from Slug
/**
* get_id_from_slug
*
* This method is utilized for returning the post id from the slug
*
* @since 7.3
* @access public
* @author Kevin Pirnie <[email protected]>
* @package Kevin's Framework
*
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:18
WordPress - Get Current Post
/**
* get_current_post
*
* Static method for getting the current post
*
* @since 7.3
* @access public
* @author Kevin Pirnie <[email protected]>
* @package Kevin's Framework
*
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:17
WordPress - REST Request?
/**
* is_rest_request
*
* this method attempts to determine if the current request is for the REST API or not
* based on a fiew factors
*
* @since 7.4
* @access public
* @author Kevin Pirnie <[email protected]>
* @package Protect Your REmote
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:17
WordPress - Pluginless Breadcrumbs
/**
* get_base_breadcrumbs
*
* Public method to return a html string of breadcrumb navigation
* checks for a couple plugins, then attempts to build one manually
*
* @since 7.4
* @access public
* @static
* @author Kevin Pirnie <[email protected]>
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:15
WordPress - Add Basic Auth to Remote Requests
/**
* function to filter the remote request arguments to ensure we are passing
* http auth headers when remotely calling from staging or dev environments
* only used if HOST of requested URL matches the site's home HOST and if the auth
* exists
*
* @param array $_the_args The existing arguments passed with the request.
* @param string $_the_url The URL being requested.
*
*/
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:14
PHP - Mask Email Address
/**
* mask_email_address
*
* Mask an email address from bots
*
* @since 7.3
* @access public
* @static
* @author Kevin Pirnie <[email protected]>
* @package Kevin's CRM and Support