Skip to content

Instantly share code, notes, and snippets.

View webmasterninjay's full-sized avatar
💭
I may be slow to respond.

Jay webmasterninjay

💭
I may be slow to respond.
View GitHub Profile
@webmasterninjay
webmasterninjay / functions.php
Created February 21, 2015 07:55
Redirect user after successful login
<?php
/**
* @param string $redirect_to URL to redirect to.
* @param string $request URL the user is coming from.
* @param object $user Logged user's data.
* @return string
*/
function ja_login_redirect( $redirect_to, $request, $user ) {
@webmasterninjay
webmasterninjay / lamp.sh
Created February 21, 2015 08:04
Install LAMP on Ubuntu based linux
sudo apt-get update
sudo apt-get install apache2
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
sudo service apache2 restart
@webmasterninjay
webmasterninjay / wp-enforce-featured-img.php
Created February 21, 2015 08:09
WordPress function enforce Featured post image on publish
@webmasterninjay
webmasterninjay / wp-query-shortcode.php
Created February 21, 2015 08:15
WP function to create shortcode that display posts base on attribute
<?php
function jay_query_shortcode($atts) {
// Example usage of this shortcode:
// [loop the_query="showposts=100&post_type=page&post_parent=453"]
// Defaults
extract(shortcode_atts(array(
"the_query" => ''
@webmasterninjay
webmasterninjay / linux.sh
Created February 21, 2015 08:20
Linux command to add user, change owner and change folder permission
sudo adduser <username> www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rw /var/www
@webmasterninjay
webmasterninjay / applet.sh
Last active August 29, 2015 14:15
My fave monitoring applet
sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor
sudo apt-get update
sudo apt-get install indicator-sysmonitor
@webmasterninjay
webmasterninjay / wp-nav-class.php
Created February 21, 2015 08:25
WP filter function to add class on nav's current page
<?php
function jay_nav_class($classes, $item){
if( in_array('current-menu-item', $classes) ){
$classes[] = 'selectedLava';
}
return $classes;
}
add_filter('nav_menu_css_class' , 'jay_nav_class' , 10 , 2);
@webmasterninjay
webmasterninjay / wp-login-shortcode.php
Last active August 29, 2015 14:15
WP function to create a shortcode to embed login form on page or post
<?php
// Use the shortcode [jay-login-form] to embed the login form
// Create shortcode
function jay_add_shortcodes() {
add_shortcode( 'jay-login-form', 'jay_login_form_shortcode' );
}
// Shortcode callback
@webmasterninjay
webmasterninjay / widget.php
Last active August 29, 2015 14:16
Add default value for widget field
<?php
// Form function
$default = array( 'recent_post_count' => '2' );
$instance = wp_parse_args( (array) $instance, $default );
@webmasterninjay
webmasterninjay / menu.js
Created March 7, 2015 12:58
Genesis Responsive Menu (jQuery)
( function( window, $, undefined ) {
'use strict';
$( 'nav' ).before( '<button class="menu-toggle" role="button" aria-pressed="false"></button>' ); // Add toggles to menus
$( 'nav .sub-menu' ).before( '<button class="sub-menu-toggle" role="button" aria-pressed="false"></button>' ); // Add toggles to sub menus
// Show/hide the navigation
$( '.menu-toggle, .sub-menu-toggle' ).on( 'click', function() {
var $this = $( this );
$this.attr( 'aria-pressed', function( index, value ) {