Skip to content

Instantly share code, notes, and snippets.

@aurooba
aurooba / fade-mixin.scss
Last active June 1, 2023 04:11
A simple mixin to to animate an element to fade it in or fade it out.
/// Simple fade-in/out animation
/// @param {String} $type - "show" or "hide", defaults to "show"
/// @param {Number} $delay - Animation delay in seconds
/// @param {Number} $duration - Animation duration in seconds
/// @param {String} $timing-function - Animation timing function, defaults to "ease-in"
@mixin fade(
$type: "show",
$delay: 0s,
$duration: 0.5s,
$timing-function: ease-in,
@aurooba
aurooba / wp_inline_svg.php
Last active February 17, 2024 23:33
Helper function to inline your SVG files in a WordPress theme or plugin and optionally also update the attributes. Only works with WordPress 6.2 and onwards. Blog post with explanation and usage instructions: https://aurooba.com/inline-svgs-in-your-wordpress-code-with-this-helper-function/
<?php
/**
* Get an SVG file from the imgs/ folder in the theme, update its attributes if necessary and return it as a string.
*
* @author Aurooba Ahmed
* @see https://aurooba.com/inline-svgs-in-your-wordpress-code-with-this-helper-function/
*
* @param string $filename The name of the SVG file to get.
* @param array $attributes (optional) An array of attributes to add/modify to the SVG file.
@aurooba
aurooba / vanilla-js-ready.js
Last active April 10, 2023 12:18
Vanilla JS alternative to jQuery's $(document).ready
var domReady = (callback) => {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
};
// usage
domReady(() => {
// Do things after DOM has loaded completely
});
/* plain JS slideToggle with display option, untested. for tested version, use the gist below */
HTMLElement.prototype.slideToggle = function (
duration,
display = "block",
callback,
) {
if (this.clientHeight === 0) {
_vanilla_slide_effect(this, duration, display, callback, true);
} else {
@aurooba
aurooba / no-text-color-in-media-text-block-heading.js
Last active March 12, 2023 19:55
Custom block settings based on location in WordPress 6.2
import { addFilter } from '@wordpress/hooks';
import { select } from '@wordpress/data';
/**
* Disable text color controls on Heading blocks
* when placed inside of Media & Text blocks.
*/
addFilter(
'blockEditor.useSetting.before',
'myPlugin/useSetting.before',
@aurooba
aurooba / adblock-plus-social.css
Created January 28, 2022 18:12
AdBlock Plus social media class targets
.widget_g1_socials, .widget_getconnected, .widget_googleplus, .widget_heateor_sssp_follow, .widget_ione-facebook-activity, .widget_ione-facebook-like, .widget_ione-social_conversion, .widget_jnews_social, .widget_jnews_social_counter, .widget_latest_tweets_widget, .widget_likeBox, .widget_likebox, .widget_mhsidebarsocialwidget, .widget_mkd_social_icon_widget, .widget_mos_social, .widget_n2_social_contacts, .widget_nypost_social_widget, .widget_oauth_twitter_widget, .widget_omg_widgets_social_widget, .widget_pb_connect_box, .widget_postmedia_social_site_connect, .widget_prisna-social-counter, .widget_psmag_mailsocial_column_2, .widget_radium_social_fans, .widget_reallysimpletwitterwidget, .widget_redwaves_fbpage_widget, .widget_related_tweets, .widget_rotatingtweets_widget, .widget_round_social_media_buttons_widget, .widget_rt_social_media, .widget_siliconcounters, .widget_simple_facebook_page_feed_widget, .widget_sn_social_boxes, .widget_social, .widget_social-feed, .widget_social-pane, .widget_social_contact
@aurooba
aurooba / block-appender.scss
Created January 23, 2022 04:53
WordPress Block Editor: Add aria-label to block appender
[data-type="yourblock/block"] {
.block-list-appender {
button.block-list-appender__toggle {
width: auto;
height: auto;
padding: 0.5rem !important;
&:after {
content: attr(aria-label);
}
}
@aurooba
aurooba / canada-boundary.geojson
Last active March 23, 2021 19:50
Canada's Boundary GeoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aurooba
aurooba / CK-Pro-User-Styles.css
Last active February 15, 2021 17:49 — forked from alexknowshtml/CK Pro User Styles
Tweaked Alex Hillmans CL Pro User Styles to reflect CK changes
/* After switching stackingthebricks.com to ConvertKit in the last few months, I found a handful of things */
/* that seemed to slow me down/force additional scrolling, so I tried hiding them from the UI with these UserStyles */
/* Obviously, these are without warrantee and could potentially break, so don't blame me if they do. */
/* Also, I am not a designer so these may not make the UI better in _your_ eyes, but they make it better for me. 😅 */
/* Hide the dashboard graph (not useful enough to be there taking up 3/4 of the screen real estate every time I log in) */
.subscribers-index div[data-component='ReportsContainer'] {
min-height: 100px !important;
background: transparent;
@aurooba
aurooba / acf-php-to-json.php
Created February 14, 2021 18:39 — forked from ollietreend/acf-php-to-json.php
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
* Author: Ollie Treend
* Author URI: https://gist.github.com/ollietreend/df32c5cbe2914f6fc407332bf6cbfca5
*/
namespace ConvertAcfPhpToJson;