Skip to content

Instantly share code, notes, and snippets.

View celticwebdesign's full-sized avatar

Darren Stevens celticwebdesign

View GitHub Profile
@celticwebdesign
celticwebdesign / WordPress - non-sass css
Created May 28, 2018 20:15
Adding a non-sass css file to functions.php
function ascendia_scripts() {
wp_enqueue_style( 'ascendia-style', get_stylesheet_uri() );
wp_enqueue_style( 'ascendia-style-non-sass', get_template_directory_uri() . '/style-non-sass.css', array(), '20171001', 'all' );
}
add_action( 'wp_enqueue_scripts', 'ascendia_scripts' );
@celticwebdesign
celticwebdesign / Google Geocode
Created October 25, 2018 10:05
Geocoding a postcode using WordPress post meta.
$prev_location = get_post_meta($post->ID, '_cottages_custom_postal_code', true );
$lat = get_post_meta($post->ID, '_cottages_custom_location_latitude', true );
$lng = get_post_meta($post->ID, '_cottages_custom_location_longitude', true );
if (
(
$cottages_meta['_cottages_custom_postal_code'] != '' &&
$prev_location != $cottages_meta['_cottages_custom_postal_code']
) ||
@celticwebdesign
celticwebdesign / jQuery
Last active November 4, 2018 19:19
Select all links with hashes, MMenu mobile plugin, click menu button and scroll down on mobile.
// Select all links with hashes
$('.menu-item-1385 a, .menu-item-1386 a, .menu-item-1387 a, .menu-item-1383 a')
.click(
function(event) {
// On-page links
// console.log(this);
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
function my_page_template_redirect()
{
if ( is_category( 'uncategorized' ) ) {
$url = site_url( '/' );
wp_safe_redirect( $url, 301 );
exit();
}
}
add_action( 'template_redirect', 'my_page_template_redirect' );
// https://kinsta.com/knowledgebase/remove-query-strings-static-resources/
// Remove Query Strings From Static Resources With Code
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
http://wpgear.org
WP-CLI - The command-line tool for managing WordPress.
https://github.com/wp-cli/wp-cli
WordPress-Coding-Standards
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
WP Migrate DB - Migrates your database by running find & replace on URLs and file paths, handling serialized data, and saving an SQL file.
https://wordpress.org/plugins/wp-migrate-db/
var showingSlider = false;
function show_hide_div_on_scroll_jquery() {
if ($(window).scrollTop()>300)
{
if (!showingSlider){
showingSlider=true;
$('#header-hidden').animate({
top: 0,
opacity: 1,
define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
@celticwebdesign
celticwebdesign / jquery - Click button and scroll to element
Created December 11, 2018 09:10
Works on page and from other page.
var top_space = 0;
if( width <= 1023 ) {
top_space = 0;
} else {
top_space = 105;
}
function scroll_to() {
// https://stackoverflow.com/questions/6677035/jquery-scroll-to-element