Skip to content

Instantly share code, notes, and snippets.

View leowebguy's full-sized avatar

Leo Leoncio leowebguy

View GitHub Profile
@leowebguy
leowebguy / .htaccess
Last active June 10, 2016 19:19
full htaccess file for wordpress developers | password request, redirect, specific files protection, no directory browsing, prevent php execution, mod_cache, mod_mime, etag, mod_expires, mod_deflate, gzip
# Change [/home/public_html/yourwebsite/] to your absolute path
# Create a .htpasswd file
# Add guest:/ls2opk3b1puY >> login: guest | pw: guest
AuthUserFile /home/public_html/yourwebsite/.htpasswd
AuthName "Type Password"
AuthType Basic
Require valid-user
<IfModule mod_rewrite.c>
RewriteEngine On
@leowebguy
leowebguy / parallelize.php
Last active August 31, 2020 15:28
Parallelize downloads across hostnames for WordPress. Useful to boost static resources load speed on websites. Recommended by GTmetrix, Pingdom, Google Speed Insights, and others.
<?php
/******
Parallelize downloads across hostnames for WordPress.
Useful to boost static resources load speed on websites.
Recommended by GTmetrix, Pingdom, Google Speed Insights, and others.
See full post > https://medium.com/p/32e9dc2fec0c
In order to work properly, all subdomains/hostnames MUST have the same structure/path. Ex:
http://mydomain.com/wp-content/uploads/2015/11/myimage.jpg
@leowebguy
leowebguy / add_meta_box.php
Last active November 24, 2015 20:30
A simple php function to add a meta box (add_meta_box) to posts/pages and write it on the footer (wp_footer).
<?php
/******
Simple function to add custom content to posts/pages on WordPress.
Just add to functions.php
******/
function custom_css_add() {
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
add_meta_box(
@leowebguy
leowebguy / query.sql
Created November 16, 2015 20:27
Create an admin user via mysql query on WordPress
INSERT INTO `deploy_wp_db1`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('5', 'admin', MD5('admin'), 'John Doe', '[email protected]', '', '2015-10-15 00:00:00', '', '0', 'John');
INSERT INTO `deploy_wp_db1`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `deploy_wp_db1`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_user_level', '10');
@leowebguy
leowebguy / index.html
Last active October 7, 2024 23:27
Responsive iframe full screen. Display page without and hide original url address.
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
html body {width: 100%;height: 100%;padding: 0px;margin: 0px;overflow: hidden;font-family: arial;font-size: 10px;color: #6e6e6e;background-color: #000;} #preview-frame {width: 100%;background-color: #fff;}</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//function to fix height of iframe!
var calcHeight = function() {
@leowebguy
leowebguy / list.php
Last active November 17, 2015 02:41
List server directory files using php and display into a page.
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
.frame {
width: 30%;
height: 30%;
background-size: cover;
float: left; }
@leowebguy
leowebguy / query.sql
Last active November 17, 2015 02:39
Replace WordPress post content using Mysql query
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://oldsite.com/', 'http://newsite.com');
@leowebguy
leowebguy / functions.php
Created November 16, 2015 20:54
Require featured image on post/page WordPress
<?php
add_action('save_post', 'wpds_check_thumbnail');
add_action('admin_notices', 'wpds_thumbnail_error');
function wpds_check_thumbnail($post_id) {
// change to any custom post type
if(get_post_type($post_id) != 'post')
return;
@leowebguy
leowebguy / functions.php
Last active November 17, 2015 02:50
Custom shortcode for Visual Composer on WordPress
<?php
function vc_integrate_custom() {
vc_map( array (
"name" => "Team",
"base" => "team",
"category" => 'Custom',
"icon" => "icon-wpb-team",
"allowed_container_element" => 'vc_row',
"params" => array(
@leowebguy
leowebguy / functions.php
Last active December 14, 2015 13:48
Quick integrate lightbox to WordPress
<?php
/****
* Download lighbox js on http://lokeshdhakar.com/projects/lightbox/
* Upload to your server Ex. /public_html/lightbox/
*****/
function enqueue_lightbox() {
wp_register_style( 'lightboxcss', get_stylesheet_directory_uri() . '/lightbox/css/lightbox.css' );
wp_register_script('lightbox', get_stylesheet_directory_uri() . '/lightbox/js/lightbox.js','','',TRUE);