Skip to content

Instantly share code, notes, and snippets.

View bobbydank's full-sized avatar
💭
Always working

Bobby Danklefsen bobbydank

💭
Always working
View GitHub Profile
@bobbydank
bobbydank / url-get-var.js
Last active January 19, 2023 21:35
How to get GET vars in url with js
/*
Simple script that gets GET vars from the url in javascript
*/
function _getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
@bobbydank
bobbydank / remove_excess_menus.php
Last active January 31, 2022 17:29
Remove excess plugin menus from Wordpress
/*
Simple function you can use to remove excess menus from them Wordpress Admin menu.
Copy to functions.php in your theme.
You can find NAME by going to the menu item and looking at the link:
https://YOUR.URL.COM/wp-admin/admin.php?page=NAME <-- that part.
*/
function THEME_PREFIX_remove_excess_menus() {
remove_menu_page( 'NAME' );
@bobbydank
bobbydank / elementor-schema-fix.php
Created April 24, 2022 22:50
Elementor - Fix deprecated schema errors
<?php
/**
* Plugin Name: Elementor Scheme Class Issue
*
* 1) Create wp-content/mu-plugins folder
* 2) Create php file (name doesn't matter)
* 3) Copy/Paste
**/
namespace Elementor;
@bobbydank
bobbydank / useful-math-functions.php
Last active July 27, 2022 02:54
Some useful php functions for receiving and returning various values from various inputs. Going from numbers to words and visa versa.
<?php
/*
* This function turns a number into the ordinal word for the number
*
* Parameter : integer
* Returns : string
*/
function numToOrdinalWord($num) {
$first_word = array('eth','first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth','eleventh','twelfth','thirteenth','fourteenth','fifteenth','sixteenth','seventeenth','eighteenth','nineteenth','twentieth');
@bobbydank
bobbydank / wp-breadcrumb.php
Created July 27, 2022 02:33
Wordpress shortcode function for creating a breadcrumb
<?php
/**
* Get breadcrumb from current page
*
* usage : [my_breadcrumb]
* returns : HTML String
*/
function my_breadcrumb_func() {
global $post;
@bobbydank
bobbydank / wp-ancestor-functions.php
Created July 27, 2022 02:52
Some random functions for getting the top page in a hierarchy.
<?php
/**
* returns the top most ancestor post id for the current post
*/
function catchylabs_get_top_parent_page_id() {
global $post;
$ancestors = $post->ancestors;
// Check if page is a child page (any level)
if ($ancestors) {
@bobbydank
bobbydank / wp-robotstxt.php
Last active July 27, 2022 03:29
simple function for adding extra stuff to your Wordpress site's robots.txt
<?php
/**
* author: Robert Danklefsen
* website: https://www.catchylabs.com/
*
* simple function for adding extra stuff to your Wordpress site's robots.txt
* add to functions.php
*/
@bobbydank
bobbydank / simple-twitter-function.php
Last active July 27, 2022 03:28
This simple widget returns a simple twitter feed using standard OAuth now
<?php
/*
* Author: Robert Danklefsen
* Website: http://www.catchylabs.com
*
* This simple widget returns a simple twitter feed using standard OAuth now
* required by Twitter's 1.1 API.
*
* To use this, you must first set up an app in the developer tools at http://dev.twitter.com/apps
@bobbydank
bobbydank / number-to-ordinal.php
Created July 27, 2022 03:12
Simple function for turning a number into an ordinal string.
<?php
/**
* Simple function for turning a number into an ordinal string.
* source: https://catswhocode.com/php-sanitize-input/
*/
function ordinal($cdnl){
$test_c = abs($cdnl) % 10;
$ext = ((abs($cdnl) %100 < 21 && abs($cdnl) %100 > 4) ? 'th'
: (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1)
@bobbydank
bobbydank / wp-simple-subnav.php
Last active August 1, 2022 15:45
Simple function for creating a subnav in your Wordpress theme
<?php
/**
* author: Robert Danklefsen
* website: https://www.catchylabs.com/
*
* Simple function for creating a subnav in your Wordpress theme
*/
function catchylabs_get_top_parent_page_id() {
global $post;