Skip to content

Instantly share code, notes, and snippets.

View kosinix's full-sized avatar

Kosinix kosinix

  • Philippines
View GitHub Profile
@kosinix
kosinix / get_pages_flattened_tree.php
Created February 3, 2014 11:12
Wordpress flat list
<?php
function get_pages_flattened_tree(&$flattened_list, $parent_id=0, $level=0){
$args = array(
'parent'=>$parent_id
);
$pages = get_pages( $args );
if($pages){
<?php
function get_pages_tree($parent_id=0){
$args = array(
'parent'=>$parent_id
);
$pages = get_pages( $args );
if($pages){
@kosinix
kosinix / tpl.php
Created January 30, 2014 11:42
Learn what template you are in WordPress
<?php
function template_hierarchy_detector(){
$out = array();
if ( is_404() ) {
$out[] = 'Error 404 Page';
}
if( is_search() ){
$out[] = 'Search Result Page';
}
if( is_archive() ){
@kosinix
kosinix / index.html
Created January 6, 2014 07:58
Keyboard Experiment - Detecting keys in javascript. Live demo: http://jsfiddle.net/rsyz5xn6/
<!doctype html>
<html lang="en">
<head>
<title>Keyboard Experiments</title>
<script type="text/javascript" src="keyboard.js"></script>
</head>
<body>
Press either left or right arrow keys
</body>
@kosinix
kosinix / active-element.js
Last active January 2, 2016 08:58
jQuery - Getting the currently focused element. Useful when debugging keyboard events on focused elements
jQuery(document).on('click', 'body', function( event ) {
console.log(document.activeElement);
});
@kosinix
kosinix / gist:8267252
Last active November 19, 2021 02:04
Prevent Access to Subdomain Folder from Main Domain. Note: Place this in your sub domain's .htaccess file (public_html/subdomain). Change subdomain to actual sub-domain and mysite.com to your main domain.
RedirectMatch ^/subdomain/(.*)$ http://subdomain.mysite.com/$1
@kosinix
kosinix / get-x-y.js
Created December 29, 2013 08:01
Jquery get element x and y position on screen
$('body').on('click', 'a', function(e){
$(this).offset().left; // x
$(this).offset().top; // y
});
@kosinix
kosinix / header.php
Last active October 11, 2021 08:43
WordPress basic CSS for styling nav menus with wp_page_menu taken into account. Supports sub-menus as dropdowns.
<?php
// Somewhere in your header.php add this. container_class and menu_class should match the CSS main class.
wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => 'nav-menu', 'menu_class' => 'nav-menu' ) );
@kosinix
kosinix / gist:7210201
Created October 29, 2013 07:04
php.ini settings ideal for development
max_execution_time = 300
max_input_time = 300
max_input_vars = 2000
memory_limit = 256M