Skip to content

Instantly share code, notes, and snippets.

Avatar

Anthony Hortin maddisondesigns

View GitHub Profile
@maddisondesigns
maddisondesigns / functions.php
Last active Nov 13, 2020
Update the version number on child theme stylesheet that's been enqueued from Parent theme
View functions.php
<?php
/**
* If you have a child theme that has had its stylesheet enqueued from within the main Parent theme,
* and you wish to update the version number that’s appended to the url, you can include this in your
* child theme functions.php file.
*
* Obviously, change the version number (‘6.0.0’ in this example) to whatever is appropriate for you,
* along with comparing the approriate stylesheet handle ('ephemeris-style' in this example)
*
* Where:
@maddisondesigns
maddisondesigns / functions.php
Last active Nov 8, 2019
Convert Phone Word to Phone Number
View functions.php
<?php
/**
* Convert a phone number containing words, to a plain number. e.g. '1800 CALLME' == '1800225563'
*/
function ephemeris_phone_word_to_number( $phone_number ) {
$phone_word_pattern = array(
'a' => '2',
'b' => '2',
'c' => '2',
'd' => '3',
@maddisondesigns
maddisondesigns / functions.php
Last active Aug 10, 2020
Hide those annoying Automattic/WooCommerce/Jetpack/WordPress adverts & promos
View functions.php
<?php
/**
* Turn off WooCommerce Marketplace suggestions
*/
add_filter( 'woocommerce_allow_marketplace_suggestions', '__return_false' );
/**
* Turn off WooCommerce Feature Plugin notice
*/
add_filter( 'woocommerce_show_admin_notice', '__return_false', 'wc_admin_feature_plugin_notice' );
@maddisondesigns
maddisondesigns / functions.php
Created May 22, 2019
Ephemeris Theme - Filter our social icons to add an email icon on the end
View functions.php
<?php
/**
* Filter our social icons to add an email icon on the end
*/
function ephemeris_add_email_to_social_icons( $social_list ) {
$social_list[] = sprintf( '<li class="%1$s"><a href="%2$s" title="%3$s"><i class="%4$s"></i><span class="assistive-text">%3$s</span></a></li>',
'email',
esc_url( home_url( '/contact' ) ),
__( 'Get in touch', 'ephemeris' ),
'far fa-envelope'
@maddisondesigns
maddisondesigns / functions.php
Last active May 7, 2019
Hide the progress count on the Site Health screen
View functions.php
<?php
/**
* Hide the progress count on the Site Health screen
*/
function mytheme_load_custom_wp_admin_style() {
$current_screen = get_current_screen();
if ( strpos( $current_screen->base, 'site-health' ) === false ) {
return;
} else {
@maddisondesigns
maddisondesigns / functions.php
Last active Aug 10, 2020
Create WordPress Custom Post Types & Taxonomies, and add custom columns to display CPT data
View functions.php
<?php
/**
* Add an action when WP Admin initialises to register our Custom Post Type
*/
function mdsgns_create_custom_post_types() {
$types = array(
// Where the magic happens
array(
'the_type' => 'store',
@maddisondesigns
maddisondesigns / blocks-style.css
Last active Apr 23, 2019
Load CSS to style the (Gutenberg) Block Editor like the front-end
View blocks-style.css
/*
Theme Name: Ephemeris
Description: Used to style the Block Editor (Gutenberg)
*/
/* Custom Colours */
/* Eclipse */
.edit-post-visual-editor .has-eclipse-background-color {
background-color: #3a3a3a;
}
@maddisondesigns
maddisondesigns / change-db-collation.php
Last active Mar 25, 2019
Change the Collation of all tables in a Database
View change-db-collation.php
<?php
$hostname = 'localhost';
$username = 'YOUR-DB-USERNAME';
$password = 'YOUR-DB-PASSWORD';
$database = 'YOUR-DB-NAME';
$collation = 'utf8mb4_unicode_ci';
$db = new mysqli( $hostname, $username, $password, $database );
if( $db->connect_errno ) {
@maddisondesigns
maddisondesigns / functions.php
Last active Jan 22, 2021
WooCommerce Custom Fields for Simple & Variable Products
View functions.php
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@maddisondesigns
maddisondesigns / create-wp-admin.php
Created Oct 4, 2017
Create a new WordPress Administrator User
View create-wp-admin.php
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
// Original script by Joshua Winn - https://joshuawinn.com/create-a-new-wordpress-admin-user-from-php
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');