Skip to content

Instantly share code, notes, and snippets.

@aurooba
aurooba / wp-block-library.css
Created February 3, 2021 14:57
Unminified default Block Library styles (Feb 3, 2021, WP Core 5.6)
:root {
--wp-admin-theme-color: #007cba;
--wp-admin-theme-color-darker-10: #006ba1;
--wp-admin-theme-color-darker-20: #005a87;
}
#start-resizable-editor-section {
display: none;
}
.wp-block-audio figcaption {
margin-top: 0.5em;
@aurooba
aurooba / custom-block-editor-palette.css
Last active January 2, 2021 19:27
Add Custom Palette to WordPress Block Editor
/* add these two classes for EVERY colour you add */
.has-COLOUR-background-color {
background-color: HEXCODE;
}
.has-COLOUR-color {
color: HEXCODE;
}
@aurooba
aurooba / gulpfile.js
Last active June 26, 2020 22:30
A basic Gulp.js file for WordPress Theme Development
/**
* Gulpfile.
*
* Workflow Supercharged
*
* Implements:
* 1. Live reloads browser with BrowserSync.
* 2. CSS: SCSS to CSS conversion, error catching, autoprefixing, sourcemaps, and CSS minification
* 3. JS: Concatenates & uglifies Vendor and Custom JS files.
* 4. Images: Minifies PNG, JPEG, GIF and SVG images.
@aurooba
aurooba / wo_is_role.php
Last active October 17, 2018 17:32
Shortcode for restricting things based on ANY WordPress role
<?php
/**
* Creates a shortcode [wo_is_role] that allows you to restrict anything inside to a particular role or roles.
* To use: [wo_is_role role="subscriber"] Put content here to show subscriber [/wo_is_role]
* To use with multiple roles: [wo_is_role role="contributor,subscriber"] Put content here to show contributors and susbcribers. [/wo_is_role]
*
* Works with ANY role, including all custom roles.
*/
@aurooba
aurooba / nav_social_walker.php
Last active August 4, 2019 00:22
Social Media Navigation Walker
<?php
/**
* Custom Social Media Nav Walker by Aurooba Ahmed
* This uses Font Awesome and adds in the correct icon by detecting the URL of the menu item.
* You can use this by doing a custom wp_nav_menu query:
* wp_nav_menu(array('items_wrap'=> '%3$s', 'walker' => new WO_Nav_Social_Walker(), 'container'=>false, 'menu_class' => '', 'theme_location'=>'social', 'fallback_cb'=>false ));
*
*/
class WO_Nav_Social_Walker extends Walker_Nav_Menu {
@aurooba
aurooba / migratesql.sql
Created October 26, 2017 20:05
SQL query to run when migrating WordPress dbs
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');
@aurooba
aurooba / breakpointmixin.scss
Last active August 3, 2017 19:14
Custom Breakpoint Mixin
/// This mixin assumes mobile-first coding, and helps you respond to different breakpoints
/// from within each applicable selector.
/// It pulls breakpoints from a map of breakpoints set in _variables.scss ( but provided below in this gist )
/// USAGE:
/// .entry-content {
/// @respond-to(river) {
/// width: 50%
/// }
/// }
@aurooba
aurooba / postnotification.php
Last active June 2, 2017 23:12
Post Notification
<?php
add_action("publish_post", "publication_notification");
//add_action("save_post", "publication_notification");
//add_action ( 'draft_to_publish', 'publication_notification', 10, 3);
function publication_notification($post_id) {
$post = get_post($post_id);
$coauthors = get_coauthors($post_id);
@aurooba
aurooba / wpseo-opengraph-coauthor-integration.php
Last active August 26, 2016 02:03
Making Co-author Plus play nice with Yoast SEO Open Graph
/**
* Pulls the correct facebook link for guest authors using
* Co-author Plus. Ideally, need to fix this so it works with empty fields as well.
*/
add_filter('wpseo_opengraph_author_facebook', 'aa_wpseo_facebook');
function aa_wpseo_facebook($fb) {
if(! function_exists('get_coauthors') )
return $fb;
@aurooba
aurooba / has_post_thumbnail_caption.php
Created May 31, 2016 15:37
Post Thumbnail (Featured Image) Captions in WordPress
/**
* Check if Post Thumbnail (Featured Image) has a caption, return true if it does
*/
function has_post_thumbnail_caption() {
global $post;
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
$thumbnail_excerpt = $thumbnail_image[0]->post_excerpt;