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 / no-peek.js
Created April 4, 2015 00:25
Extra security
jQuery("body").bind("contextmenu",function(e){
return false;
});
jQuery("body").bind("cut copy paste",function(e) {
e.preventDefault();
});
document.onkeydown = function(e) {
if (e.ctrlKey &&
@webmasterninjay
webmasterninjay / defaults.php
Created April 6, 2015 14:33
Genesis Framework: Adding Default child theme setting
<?php
//* Advance Theme Setting Defaults
add_filter( 'genesis_theme_settings_defaults', 'advance_theme_defaults' );
function advance_theme_defaults( $defaults ) {
$defaults['blog_title'] = 'image';
$defaults['blog_cat_num'] = 5;
$defaults['content_archive'] = 'full';
$defaults['content_archive_limit'] = 200;
@webmasterninjay
webmasterninjay / featured-image.php
Created April 8, 2015 23:13
Wordpress Genesis: Add featured image conditionally
@webmasterninjay
webmasterninjay / function.php
Created April 10, 2015 05:58
Wordpress: Remove widget title using !
<?php
/*
* Remove Widget Title using !
*/
add_filter( 'widget_title', 'jay_remove_widget_title' );
function jay_remove_widget_title( $widget_title ) {
if ( substr ( $widget_title, 0, 1 ) == '!' )
return;
else
@webmasterninjay
webmasterninjay / loop.php
Created April 13, 2015 15:55
Genesis custom loop
<?php
// Genesis custom parameter loop
add_action('genesis_before_loop', 'jay_before_loop');
function jay_before_loop () {
global $query_string;
query_posts($query_string . "&order=DESC&orderby=date");
}
@webmasterninjay
webmasterninjay / widget.php
Created April 30, 2015 05:21
Wordpress: Widget to display custom post type testimonial
<?php
//* START WIDGET
class Testimonial_Widget extends WP_Widget {
function __construct() {
parent::__construct(
'testimonial_widget', // Base ID
__('Testimonial Widgets', 'marilynhorowitz'), // Name
@webmasterninjay
webmasterninjay / functions.php
Last active August 29, 2015 14:23
WP Genesis: Add external link on Post Title
<?php
// Filter post title
// to add custom url, just add a custom field with name ExternalURL and url as value where you want the title to go when clicked
add_filter( 'genesis_post_title_output', 'jay_post_title_output', 15 );
function jay_post_title_output( $title ) {
if ( is_singular() && get_post_meta( get_the_ID(), 'ExternalURL', true) )
$exturl = get_post_meta( get_the_ID(), 'ExternalURL', true);
@webmasterninjay
webmasterninjay / function.php
Created June 23, 2015 03:33
WP Genesis - Modify Site Title for SEO
<?php
//* Modify the header URL - HTML5 Version
add_filter( 'genesis_seo_title', 'crizelda_header_title', 10, 3 );
function crizelda_header_title( $title, $inside, $tag ) {
$tag = ( is_home() || is_front_page() ) ? 'h1' : 'p';
$inside = sprintf( '<a href="%s" title="%s">%s</a>', get_bloginfo('url'), esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) );
return sprintf( '<%1$s class="site-title">%2$s</%1$s>', $tag, $inside );
@webmasterninjay
webmasterninjay / functions.php
Created July 10, 2015 14:41
Woocommerce - Redirect after payment
<?php
/* Redirect user after check out */
add_action( 'template_redirect', 'jay_custom_redirect_after_purchase' );
function jay_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://www.yoururl.com/your-page/' );
exit;
@webmasterninjay
webmasterninjay / functions.php
Created July 12, 2015 20:17
WordPress: Redirect non-admin user to My Account page
<?php
/**
* Redirect back to homepage and not allow access to
* WP admin for Subscribers.
*/
function jay_redirect_admin(){
if ( ! current_user_can( 'edit_posts' ) ){
wp_redirect( site_url('/my-account') );
exit;