Skip to content

Instantly share code, notes, and snippets.

View utopianfool's full-sized avatar

Philip Porter utopianfool

View GitHub Profile
@utopianfool
utopianfool / hide-api-keys-from-github.md
Last active August 27, 2020 20:38
Hide API keys from github using Javascript
@utopianfool
utopianfool / .htaccess
Created August 28, 2020 10:41
Force https in .htaccess file
# Force https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
@utopianfool
utopianfool / add-new-user-to-wordpress-database.sql
Last active August 28, 2020 11:27
Add a new user to WordPress database in SQL
/* Add new user to wordpress database */
/*
* Replace the number "4" with an available number in the user_id field
* Only user name and email address is necessary to create a new user
*/
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
@utopianfool
utopianfool / update-wordpress-urls.sql
Created August 28, 2020 11:38
Update WordPress URLs in the database instead of find and replace in a text editor
/* Update WordPress URLs in database */
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.old-domain.com', 'http://www.new-domain.com');
@utopianfool
utopianfool / update-linux-servers.md
Created August 28, 2020 11:41
Update linux servers - the basics

Update Servers

Log in to servers with admin@ then switch users "su" before running following commands:

Find what updates are available

apt-get update

Upgrade the found updates

@utopianfool
utopianfool / detect-browsers.js
Created August 28, 2020 11:50
Detect user's browser and run related example functions
/**
* Detect Browsers functions
*/
/* Get IE or Edge browser version */
var version = detectIE();
if (version === false) {
document.getElementById('result').innerHTML = '<s>IE/Edge</s>';
@utopianfool
utopianfool / ekko-lightbox-gallery-example.scss
Created September 22, 2020 05:19
Ekko Lightbox for Bootstrap and WordPress Example SCSS
@utopianfool
utopianfool / ekko-lightbox-jquery-example.js
Created September 22, 2020 05:24
Ekko Lightbox for Bootstrap and WordPress Example jQuery
jQuery(function($){
// Ekko lightbox attribute data-toggle to gallery links
$('.gallery-item').find('a').attr('data-toggle', 'lightbox');
$('.gallery-item').find('a').attr('data-gallery', 'gallery');
$('.gallery-item').find('a').attr('data-type', 'image');
// enable ekko lightbox on page
$(document).on('click', '[data-toggle="lightbox"]', function(event) {
event.preventDefault();
$(this).ekkoLightbox({
@utopianfool
utopianfool / accordion-wordpress-bootstrap-acf.html
Created September 22, 2020 05:34
Accordions in 2 column WordPress Bootstrap ACF Example
<section class="content-section">
<div class="container">
<div class="row justify-content-center py-3">
<div class="col-12 col-md-6 mb-3 pb-3">
<?php the_field('left_column_content'); ?>
<div class="accordion" id="fact-accordion">
<?php if( have_rows('accordion') ): ?>
@utopianfool
utopianfool / worpress-custom-login-logo.php
Created September 22, 2020 06:06
WordPress Custom Login Logo Function
<?php
/**
* Add custom logo to login
*/
function custom_login_logo() { ?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/login-logo.png);
height:65px;
width:320px;