Skip to content

Instantly share code, notes, and snippets.

View JezDriver's full-sized avatar

Jeremy Driver JezDriver

View GitHub Profile
@JezDriver
JezDriver / notepad.html
Created March 22, 2023 00:35
📝 Notepad browser tab
data:text/html, <head><meta name="viewport" content="width=device-width, initial-scale=1.0"><link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAJ6TrAFy+8QCC0vgA7+/vAC6n7ACE0/gAS2RuAKbU5QDAwMAAv+3+ACek6gApoeYAAAAAAAAAAAAAAAAARERERERERABEREREREREAEREREREREQAREREeIRERABJmZSohUREAERERKolVEQAREREozUVRABJmZRDNlFUAEREREQzZRUAREREREM2W1BJmZmZRDNlxUREREREQzZVREREREREMzVJmZmZmURDM0REREREREQzRERERERERAMAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAA" rel="icon" type="image/x-icon" /><style>body{font: 2rem/1.5 monospace;max-width:40ch;margin:0 auto;padding:1ch;}main{background-color:rgb(255,255,204);box-shadow: 0 4px 10px rgba(0,0,0,0.2);}title{font-size: calc(2rem + (3 - 2) * ((100vw - 300px) / (1600 - 300)));line-height:1.1;margin-top:2vw;font-weight: bold;padding:0.5rem 1rem;margin-bottom:2px;border-bottom:2px solid lightgrey;}p{margin-top:0;padding:0 1rem;min-height:calc(20 * (2rem + 2px));line-height:calc(2
@JezDriver
JezDriver / remove-querystring.js
Created March 22, 2023 00:44
Remove Query string from URL #js
window.history.pushState("object or string", "Title", window.location.href.split("?")[0]);
// can also use replaceState to negate back button
@JezDriver
JezDriver / array-to-json.php
Created March 22, 2023 00:45
Write array to JSON file #php
$data = array();
$fp = fopen('data.json', 'w');
fwrite($fp, json_encode($data));
fclose($fp);
@JezDriver
JezDriver / wp-custom-admin-notice.php
Created March 22, 2023 00:47
Custom admin notice/notification #php #wordpress
function author_admin_notice()
{
if (isset($_GET['query_string_here']) && $_GET['query_string_here'] == 'value') {
echo '
<div class="notice notice-success is-dismissible">
<p>Notice goes here! </p>
</div>
';
}
}
@JezDriver
JezDriver / fa-prevent-loading-jank.css
Created March 22, 2023 01:25
Font Awesome - prevent layout shift on SVG icon load #css
/* Keep icons from shifting layout */
html:not(.fontawesome-i2svg-complete) .fa-fw {
display: inline-block;
width: 1.28571429em;
}
html:not(.fontawesome-i2svg-complete) .fa-fw::before {
content: "\00a0";
}
@JezDriver
JezDriver / wp-custom-admin-css.php
Created March 22, 2023 01:53
Add custom styles to admin area #php #wordpress
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
body, td, textarea, input, select {
font-family: "Lucida Grande";
font-size: 12px;
}
</style>';
}
@JezDriver
JezDriver / wp-limit-cpt-hierarchy-depth.php
Last active March 22, 2023 01:55
Limit Depth of Hierarchical Custom Post Type #php #wordpress
function my_test($args) {
global $post_type_object;
if ( $post_type_object->name == 'my_custom_post_type') {
$args['depth'] = 1;
}
return $args;
}
add_filter('page_attributes_dropdown_pages_args','my_test');
add_filter('quick_edit_dropdown_pages_args', 'my_test');
@JezDriver
JezDriver / echo-svg-file-contents.php
Created March 22, 2023 02:02
How to echo the contents of an SVG file - by @geoffgraham #php #svg
/**
* How to echo the contents of an SVG file with PHP
* https://geoffgraham.me/how-to-echo-the-contents-of-an-svg-file-with-php/
*
* "Using this is so much cleaner in the template files than copying and pasting the entire SVG code. Plus, it lets me manage all of my SVG files from a central location. Update it once, and the changes are applied everywhere!"
*/
<?php echo file_get_contents( get_template_directory_uri() . '/dist/img/logo.svg' ); ?>
@JezDriver
JezDriver / time-based-display.php
Created March 22, 2023 02:05
Time based display of content #php
<?php if(time() < strtotime('2020-08-14 11:00-07:00')): ?>
<p>Content!</p>
<?php endif; >
@JezDriver
JezDriver / auto-scroll-margin-top.css
Created March 22, 2023 02:14
Add scroll margin to all elements which can be targeted - by Andy Bell #css
/* https://piccalil.li/quick-tip/add-scroll-margin-to-all-elements-which-can-be-targeted */
[id] {
scroll-margin-top: 2ex;
}