Skip to content

Instantly share code, notes, and snippets.

@waelio
waelio / get_object_type.php
Last active December 29, 2015 13:15
WP- Return the object type
<?php
/**
* @param object|int|string $object
* @return string
*/
function get_object_type($object){
$workable = false;
$object_type = gettype($object);
switch($object_type){
@waelio
waelio / Inject_Arrays.php
Last active December 29, 2015 13:14
Inject an array with another array a certainposition
<?php
/**
* @param array $needle
* @param array $haystack
* @param $position
* @return array
*/
function inject_this_array($needle=array(),$haystack=array(),$position){
$new_holder1 = array_slice($haystack, 0, $position, true);
$new_holder2 = array_slice($haystack, $position, count($haystack)-1,true);
@waelio
waelio / The_Slug.php
Last active December 29, 2015 13:14
Get part of the slug from the url
<?php
/**
* @param int $position
* @param bool|true $echo
* @return bool
*/
function the_slug($position=1,$echo=false){
$url = parse_url($_SERVER['REQUEST_URI']);
$slugs = array_filter(explode('/',$url['path']));