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 / 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 <me@kpirnie.com>
* @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 <me@kpirnie.com>
* @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 <me@kpirnie.com>
* @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 <me@kpirnie.com>
* @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 <me@kpirnie.com>
* @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 <me@kpirnie.com>
* @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 <me@kpirnie.com>
@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 <me@kpirnie.com>
* @package Kevin's CRM and Support
@kpirnie
kpirnie / functions.php
Created August 13, 2025 18:14
WordPress - Create Admin
<?php
// include the wp-config.php file
include "/CHANGE_THIS_PATH/wp-config.php";
// set a username
$username = 'CHANGE_THIS';
// set a password
$password = 'CHANGE_THIS';