Skip to content

Instantly share code, notes, and snippets.

View dartiss's full-sized avatar
🏠
Always working from home

David Artiss dartiss

🏠
Always working from home
View GitHub Profile
@dartiss
dartiss / upside-down.html
Created February 3, 2024 15:40
Turn your site upside down!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ǝɯɐɟ ɟo qƃ5˙1 ʎɯ | ssıʇɹɐ pıʌɐp</title>
</head>
<style type="text/css">
body, iframe {
display: block;
margin: 0;
@dartiss
dartiss / your-plugin.php
Last active September 2, 2023 07:02
WordPress function to perform certain validation checks on a plugin
/**
* Validate Plugin Requirements
*
* Deactivate the plugin if a minimum set of requirements aren't met.
*/
function validate_plugin_requirements() {
$exit = false;
$reasons = '';
@dartiss
dartiss / functions.php
Last active July 16, 2023 10:39
Embed Threads in a WordPress Post
<?php
/**
* Thread Embed
*
* @package threads-embed
* @author David Artiss
* @license GPL-2.0-or-later
*
* Plugin Name: Threads Embed
* Plugin URI: https://gist.github.com/dartiss/97b7da945b9de709dba8fed5a7f23ede
@dartiss
dartiss / functions.php
Created June 27, 2023 17:14
Remove WordPress admin notices for non-administrators
function dismiss_admin_notices() {
// Check if the current user is not an administrator.
if ( ! current_user_can( 'administrator' ) ) {
// Dismiss all admin notices.
remove_all_actions( 'admin_notices' );
}
}
add_action( 'admin_init', 'dismiss_admin_notices' );
@dartiss
dartiss / colortohex.php
Created April 24, 2023 18:41
Color name to hex compression
$tocolor = array(
'Black' => '#000',
'DarkBlue' => '#00008B',
'MediumBlue' => '#0000CD',
'DarkGreen' => '#006400',
'DarkCyan' => '#008B8B',
'DeepSkyBlue' => '#00BFFF',
'DarkTurquoise' => '#00CED1',
'MediumSpringGreen' => '#00FA9A',
'SpringGreen' => '#00FF7F',
@dartiss
dartiss / hextocolor.php
Created April 24, 2023 18:30
Hex to color name compression
$tocolor = array(
'#000080' => 'Navy',
'#008000' => 'Green',
'#008080' => 'Teal',
'#00FF00' => 'Lime',
'#4B0082' => 'Indigo',
'#800000' => 'Maroon',
'#800080' => 'Purple',
'#808000' => 'Olive',
'#808080' => 'Gray',
@dartiss
dartiss / functions.php
Created November 18, 2022 12:52
Add Mastodon verification to a WordPress site
function add_mastodon_verification() {
?>
<link rel="me" href="[your Mastodon profile link]">
<?php
}
add_action( 'wp_head', 'add_mastodon_verification' );
@dartiss
dartiss / functions.php
Last active December 5, 2021 17:08
Add theme color support to a WordPress site
<?php
/**
* Add support for a theme colour
*/
function add_theme_colour() {
?>
<meta name="theme-color" content="#BE702B" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#333333" media="(prefers-color-scheme: dark)">
<?php
}
@dartiss
dartiss / functions.php
Last active April 24, 2020 11:45
Add modules to Jetpack menu
/**
* Admin menu changes
*/
function add_menus() {
if ( class_exists( 'Jetpack' ) ) {
add_action( 'jetpack_admin_menu', 'add_jetpack_menu' );
}
}
@dartiss
dartiss / functions.php
Created April 24, 2020 09:56
WordPress script to add reusable blocks to the WP Admin menu
/**
* Add a menu for the block editor
*/
function add_block_menu() {
add_menu_page(
'Reusable Blocks',
'Reusable Blocks',
'manage_options',
'edit.php?post_type=wp_block',