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 December 16, 2021 16:08 — forked from cliffordp/functions.php
Automatically login a single WordPress user upon arrival to a specific page.
<?php
/**
* Automatically login a single WordPress user upon arrival to a specific page.
*
* Redirect to home page once logged in and prevent viewing of the login page.
* Compatible with WordPress 3.9.1+
* Updated 2014-07-18 to resolve WP_DEBUG notice: "get_userdatabylogin is deprecated since version 3.3! Use get_user_by('login') instead."
* Updated 2019-07-09 to reformat code, pass 2nd parameter to `do_action()`, and hook into priority 1.
*
@webmasterninjay
webmasterninjay / wp-increase-timeout.php
Created September 30, 2020 15:56 — forked from sudar/wp-increase-timeout.php
Increase the curl timeout in WordPress
<?php
Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/
//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'bal_http_request_args', 100, 1);
function bal_http_request_args($r) //called on line 237
{
$r['timeout'] = 15;
return $r;
}
@webmasterninjay
webmasterninjay / send_custom_email.php
Created August 6, 2019 17:15 — forked from andrewlimaza/send_custom_email.php
Send a custom email when a user checks out for a pmpro level.
<?php
/**
* Add this code to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This function below sends a custom HTML email to the user that checks out for a pmpro membership level, easily extendible to send to admins, or specific users and so on.
* Website: https://paidmembershipspro.com
*/
//let's send a custom email after user checkouts. This will not send an email if an admin changes user's level inside member area.
function custom_email_after_checkout( $user_id, $morder ){
@webmasterninjay
webmasterninjay / iframe_defer.js
Created February 26, 2019 20:50 — forked from bjmiller121/iframe_defer.js
Defer loading of iframes
/**
* Defer iframe loading.
*
* Markup:
* <div class="defer-iframe" data-src="{SOURCE URL}" data-{ATTR}="{VAL}"></div>
*/
$(window).load( function(){
if ($('.defer-iframe').length) {
$('.defer-iframe').each( function() {
var $iframe = $('<iframe frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
@webmasterninjay
webmasterninjay / export_csv.php
Created November 14, 2018 15:49 — forked from apocratus/export_csv.php
Export MySQL to CSV (php script)
<?php
/* vars for export */
// database record to be exported
$db_record = 'XXXXXXXXX';
// optional where query
$where = 'WHERE 1 ORDER BY 1';
// filename for export
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv';
// database variables
// The Loop
/*
* Usage: loop category="news" query="" pagination="false"
*/
<?php
add_shortcode("loop", "myLoop");
function myLoop($atts, $content = null) {
extract(shortcode_atts(array(
@webmasterninjay
webmasterninjay / gist:64de09b14e1cf209f15884038ff396be
Created February 24, 2017 15:49 — forked from srikat/gist:7853312
Showing Full content and Featured image in a CPT archive page regardless of theme settings in Genesis. http://sridharkatakam.com/showing-full-content-featured-image-cpt-archive-page-regardless-theme-settings-genesis/
//* Showing Full content and Featured image in 'testimonial' CPT archive page regardless of theme settings in Genesis
add_action( 'genesis_before_loop', 'sk_full_content_testimonials_archive' );
function sk_full_content_testimonials_archive() {
if ( is_post_type_archive( 'testimonial' ) ) {
add_filter( 'genesis_pre_get_option_content_archive_thumbnail', 'sk_show_post_image' );
add_filter( 'genesis_pre_get_option_content_archive', 'sk_do_full_content' );
add_filter( 'genesis_pre_get_option_content_archive_limit', 'sk_no_content_limit' );
}
@webmasterninjay
webmasterninjay / functions.php
Created October 19, 2016 16:18 — forked from srikat/functions.php
How to add an inline mobile responsive menu in Genesis Sample. https://sridharkatakam.com/add-inline-mobile-responsive-menu-genesis-sample/
// Remove site description
add_filter( 'genesis_attr_site-description', 'abte_add_site_description_class' );
/**
* Add class for screen readers to site description.
*
* Unhook this if you'd like to show the site description.
*
* @since 1.0.0
*
* @param array $attributes Existing HTML attributes for site description element.