Skip to content

Instantly share code, notes, and snippets.

View someguy9's full-sized avatar
🏠
Working from home

Andy Feliciotti someguy9

🏠
Working from home
View GitHub Profile
@someguy9
someguy9 / criticalcss-bookmarklet-devtool-snippet.js
Created February 2, 2016 22:39 — forked from PaulKinlan/criticalcss-bookmarklet-devtool-snippet.js
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@someguy9
someguy9 / iframe-example.html
Last active March 1, 2020 19:37
iFrame example
<iframe src="https://bing.com" height="400"></iframe>
@someguy9
someguy9 / wordpress-iframe-shortcode
Last active July 1, 2019 19:01
iFrame shortcode example for WordPress
[iframe src="https://www.youtube.com/embed/fd0k_hbXWcQ" width="100%" height="500"]
@someguy9
someguy9 / featured-image-wordpress-rss-feed.php
Last active March 6, 2024 17:23
Display Featured Image in WordPress RSS Feed
@someguy9
someguy9 / disable-emojis-wordpress.php
Last active December 21, 2023 13:45
Disable emojis in WordPress
<?php
//Disable emojis in WordPress
add_action( 'init', 'smartwp_disable_emojis' );
function smartwp_disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@someguy9
someguy9 / wp-check-if-user-is-logged-in.php
Created June 25, 2019 13:35
Simple code using the built in WP function that checks if you a user is logged into WordPress.
<?php
if ( is_user_logged_in() ) {
echo 'Welcome, logged in user. <a href="'.wp_logout_url().'">Click here to logout</a>.';
}else{
echo 'Please login by <a href="'.wp_login_url().'">clicking here</a>.'
}
@someguy9
someguy9 / wp-check-if-user-is-admin.php
Created June 25, 2019 13:58
Check if a user is an admin in WordPress.
<?php
if( current_user_can('administrator') ) {
echo 'This will display for WordPress admins only.';
};
@someguy9
someguy9 / wp-remove-gutenberg-block-library-css.php
Last active November 21, 2023 08:00
Removed the "/wp-includes/css/dist/block-library/style.min.css" file from your WordPress site
<?php
//Remove Gutenberg Block Library CSS from loading on the frontend
function smartwp_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-blocks-style' ); // Remove WooCommerce block CSS
}
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css', 100 );
@someguy9
someguy9 / responsive-embed-youtube.css
Last active March 10, 2022 17:53
This CSS lets you wrap an iframe with a div using the class 'responsive-embed-container embed-responsive-16by9' to make it 16:9 responsive
.responsive-embed-container {
position: relative;
display: block;
overflow: hidden;
height: 0;
max-width: 100% !important;
}
.embed-responsive-16by9 {
padding-bottom: 56.25%;
aspect-ratio: 16 / 9;
<div class="responsive-embed-container"><iframe width="560" height="315" frameborder="0" allowfullscreen src="https://www.youtube.com/embed/fd0k_hbXWcQ"></iframe></div>