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 / custom.js
Created August 17, 2022 16:00
add title to all images from alt tags using jQuery
<script>
jQuery(document).ready(function($) {
$("img:not([title])").each(function() {
if($(this).attr("alt") != '') $(this).attr("title", $(this).attr("alt"));
else $(this).attr("title", $(this).attr("src"));
});
});
</script>
@webmasterninjay
webmasterninjay / shortcodes.php
Created February 21, 2022 00:55
Genesis Framework: Use genesis_custom_loop as shortcode
<?php
add_shortcode( 'cibaria_loop', 'cibaria_loop_shortcode' );
function cibaria_loop_shortcode( $atts ) {
$param = shortcode_atts( [
'post_status' => 'publish',
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => -1,
@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 / index.html
Created October 6, 2020 12:40
Simple Scroll Indicator
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
font-size: 28px;
font-family: Arial, Helvetica, sans-serif;
}
@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 / custom.php
Last active February 12, 2021 18:34
Woocommerce: Add Additional Fee on cart
<?php
// Add additional fee ( Handling Fee etc. )
add_action( 'woocommerce_cart_calculate_fees','theme_prefix_additional_fees' );
function theme_prefix_additional_fees() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
@webmasterninjay
webmasterninjay / login.php
Last active March 8, 2021 15:56
Customized Login page form in WordPress
<?php
// Customized login page
function theme_prefix_custom_login_page() {
$custom_logo_id = get_theme_mod( 'custom_logo' ); // image from cusomizer logo
$image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
$bg = get_stylesheet_directory_uri() . '/images/bg.jpg'; // change url to your preferred image
?>
<style type="text/css">
body.login {
@webmasterninjay
webmasterninjay / index.html
Created March 25, 2020 18:27
Simple Coming Soon - Underconstruction Template
<!DOCTYPE html>
<html>
<head>
<style>
body, html {
height: 100%;
margin: 0;
}
.bgimg {
@webmasterninjay
webmasterninjay / bp-custom.php
Created January 21, 2020 19:57
Exclude several user roles from buddypress loop
<?php
function exclude_roles_from_members_loop( $retval ) {
if ( bp_is_members_directory() ) {
$exclude_ids = get_users(
array(
'fields' => 'ID',
'role__in' => array( 'editor', 'author' ) // change the roles here
)
);
@webmasterninjay
webmasterninjay / downloader.php
Created September 26, 2019 14:33
Simple PHP script to download file from url
<html>
<form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
<?php
// maximum execution time in seconds
set_time_limit (24 * 60 * 60);
if (!isset($_POST['submit'])) die();