Skip to content

Instantly share code, notes, and snippets.

View VernonGrant's full-sized avatar
🤓
Working @twothreebird

Vernon Grant VernonGrant

🤓
Working @twothreebird
View GitHub Profile
@VernonGrant
VernonGrant / functions.php
Last active March 25, 2022 05:48
Limiting chinese excerpts in WordPress.
<?php
/**
* Filters the excerpt to limit Chinese strings properly.
*
* @param string $excerpt The starting execerpt.
* @return string The new limited excerpt
*/
function prefix_filter_chinese_excerpt( $excerpt ) {
$limit = 80;
@VernonGrant
VernonGrant / wp-config.php
Last active November 18, 2018 12:13
WordPress Development Config Constants
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
define( 'DEV_SERVER', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_HOME', DEV_SERVER );
define( 'WP_SITEURL', DEV_SERVER );
define( 'WP_CONTENT_URL', DEV_SERVER .'/wp-content/' );
@VernonGrant
VernonGrant / wp-url-change.sql
Last active February 22, 2020 06:26
Change Database URI #WordPress
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@VernonGrant
VernonGrant / functions.php
Last active March 10, 2021 03:34
Styling WooCommerce notices
<?php
/**
* Displays some notices on the cart and checkout pages for easier styling.
*/
function style_woocommerce_notices() {
wc_print_notice( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.', 'success' );
wc_print_notice( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.', 'error' );
wc_print_notice( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.', 'notice' );
@VernonGrant
VernonGrant / font_awesome_free_cheatsheet.php
Last active December 4, 2022 23:17
Font Awesome Free's Cheatsheet PHP
<?php
$icons = array(
'solid_icons' => array(
'ad' => 'f641',
'address-book' => 'f2b9',
'address-card' => 'f2bb',
'adjust' => 'f042',
'air-freshener' => 'f5d0',
'align-center' => 'f037',
@VernonGrant
VernonGrant / mysql-upload.md
Created June 5, 2019 10:01
Upload MYSQL database via terminal

Try:

mysql -u username -p database_name < file.sql Check MySQL Options.

Note-1: It is better to use the full path of the SQL file file.sql.

Note-2: Use -R and --triggers to keep the routines and triggers of original database. They are not copied by default.

Note-3 You may have to create the (empty) database from mysql if it doesn't exist already and the exported SQL don't contain CREATE DATABASE (exported with --no-create-db or -n option), before you can import it.

@VernonGrant
VernonGrant / remember-credential.sh
Created June 8, 2019 12:05
Remember GIT credentials
git config credential.helper store
@VernonGrant
VernonGrant / .vimrc
Last active March 19, 2021 03:09
Project specific vimrc file
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PROJECT SPECIFIC VIMRC "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if !exists("*LoadProjectVimrc")
function! LoadProjectVimrc()
let vimrcFile = findfile(".vimrc", ".;")
if !empty(l:vimrcFile)
execute ":so" l:vimrcFile
@VernonGrant
VernonGrant / functions.php
Created August 6, 2019 10:39
WordPress rename archive titles.
<?php
// Return an alternate title, without prefix, for every type used in the get_the_archive_title().
add_filter('get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>';
@VernonGrant
VernonGrant / .htaccess
Last active July 10, 2020 07:08
Enable Broweser Caching and GZip to Apache2
# Place before all other things.
# Enable Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype