Skip to content

Instantly share code, notes, and snippets.

View 5iDS's full-sized avatar
💭
@ease with the Source

Max 5iDS

💭
@ease with the Source
View GitHub Profile
@5iDS
5iDS / WP-Top-Most-Taxonomy
Created November 28, 2013 23:50
WP determine the topmost parent of a term
function get_term_top_most_parent($term_id, $taxonomy){
// start from the current term
$parent = get_term_by( 'id', $term_id, $taxonomy);
// climb up the hierarchy until we reach a term with parent = '0'
while ($parent->parent != '0'){
$term_id = $parent->parent;
$parent = get_term_by( 'id', $term_id, $taxonomy);
}
return $parent;
@5iDS
5iDS / WP-Redirect Register
Created November 28, 2013 23:51
Redirect from Default WordPress register page to custom register page.
/**
* RedirectWPRegister()
* Redirect from Default wordpress register page to custom register page.
*/
function RedirectWPRegister(){
$request = basename($_SERVER['REQUEST_URI']);
if ($request == 'wp-login.php?action=register'):
wp_redirect(site_url('/?page_id=776'));
exit();
endif;
@5iDS
5iDS / WP-check_user_role
Created November 28, 2013 23:52
Checks if a particular user has a role.
#-----------------------------------------------------------------
# Checks if a particular user has a role.
# Returns true if a match was found.
#
# @param string $role Role name.
# @param int $user_id (Optional) The ID of a user. Defaults to the current user.
#
# @return bool
#
#-----------------------------------------------------------------
@5iDS
5iDS / android_winusb
Created December 16, 2013 14:51
HTC Wildfire ADB Drivers
;HTC Wildfire
%SingleAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C8B
%CompositeAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C8B&MI_01
%SingleBootLoaderInterface% = USB_Install, USB\VID_0BB4&PID_0C94
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
csso = require('gulp-csso'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat');
gulp.task('css', function () {
gulp.src('./_includes/css/*.scss')
@5iDS
5iDS / is_childPage
Created February 20, 2014 02:15
Check if a Page is a Child of Another Page in WordPress
#-----------------------------------------------------------------
# Check if a Page is a Child of Another Page in WordPress
# Returns true if a match was found.
#
# @param int $pageID
#
# @return bool
#
#-----------------------------------------------------------------
function is_childPage($pageID) {
@5iDS
5iDS / non_www_2_www
Created March 19, 2014 02:19
Redirecting non-www to www with .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
@5iDS
5iDS / ww_2_non_www
Created March 19, 2014 02:20
Redirecting www to non-www with .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
@5iDS
5iDS / Wordpress SSL
Created July 12, 2014 04:36
redirect to SSL
<?php
function redirectTohttps() {
if($_SERVER['HTTPS']!=”on”) {
$redirect= “https://”.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header(“Location:$redirect”);
}
}
?>
@5iDS
5iDS / .htaccess
Created July 14, 2014 04:37
HTACCESSS Template
# Apache Configuration File
# (!) Using `.htaccess` files slows down Apache, therefore, if you have access
# to the main server config file (usually called `httpd.conf`), you should add
# this logic there: http://httpd.apache.org/docs/current/howto/htaccess.html.
# ##############################################################################
# # CROSS-ORIGIN RESOURCE SHARING (CORS) #
# ##############################################################################