Skip to content

Instantly share code, notes, and snippets.

View jasondmoss's full-sized avatar
😗

Jason D. Moss jasondmoss

😗
View GitHub Profile
@jasondmoss
jasondmoss / stripNamespaceFromClassName.php
Last active February 18, 2021 00:06
Strip the namespace from the class to get the actual class name
<?php
/**
* Strip the namespace from the class to get the actual class name
*
* @param string $obj Class name with full namespace
*
* @return string
* @access public
*/
@jasondmoss
jasondmoss / paginator.php
Last active August 26, 2017 12:42
Simple WordPress Paginator
<?php
/**
* Custom pagination.
*
* @param integer $total Total number of pages
* @param boolean $echo Echo or return result?
*
* @return void
* @access public
@jasondmoss
jasondmoss / getIp.php
Last active August 26, 2017 12:43
Get IP Address
<?php
/**
* Get current user's IP address
*
* @return string
* @access public
*/
function getIp()
{
@jasondmoss
jasondmoss / getPostSlug.php
Last active August 26, 2017 12:45
Get WordPress Post Slug
<?php
/**
* Get post slug
*
* @param integer $objectId (Optional) Post ID
* @param boolean $echo (Optional) Whether to echo or return value.
*
* @return string
* @access public
@jasondmoss
jasondmoss / getCurrentUrl.php
Last active August 26, 2017 12:46
Get Current URL
<?php
/**
* Get current URL
*
* @param boolean $echo (Optional) Whether to echo or return value.
*
* @return string
* @access public
*/
@jasondmoss
jasondmoss / simpleXmlToArray.php
Last active June 22, 2022 21:12
Convert a SimpleXML object to associative array
<?php
/**
* Convert a SimpleXML object to an associative array
*
* @param object $xmlObject
*
* @return array
* @access public
*/
@jasondmoss
jasondmoss / isWritable.php
Last active August 26, 2017 12:47
Is file writable? If not try to to make it so...
<?php
/**
* Check if a file/folder is writable. If not, the function tries to make
* it writable.
*
* @param string $file
* @param string $mode
*
* @return File
@jasondmoss
jasondmoss / hasChildren.php
Last active August 26, 2017 13:30
Current post has Children?
<?php
/**
* Whether current post has children
*
* @param integer $postId
*
* @return boolean
* @access public
*/
@jasondmoss
jasondmoss / isChild.php
Last active August 26, 2017 13:27
Whether a post is a child of a parent
<?php
/**
* Whether a post is a child of a parent
*
* @param mixed $parent Page ID, slug or title
*
* @return boolean
* @access public
*/
@jasondmoss
jasondmoss / newWindowAnchor.js
Last active November 22, 2019 03:35
Open external, or specified, links in new tab/window.
/**
* Securely open a new window from given anchor element.
*
* @param {NodeElement} anchor
*
* @method newWindowAnchor
*
* jshint esversion: 6
*/