Skip to content

Instantly share code, notes, and snippets.

@alexander-young
alexander-young / functions.php
Created Jan 15, 2020
Defer Javascript in WordPress
View functions.php
function defer_parsing_of_js($url)
{
if (is_admin()) return $url; //don't break WP Admin
if (false === strpos($url, '.js')) return $url;
if (strpos($url, 'jquery.js')) return $url;
return str_replace(' src', ' defer src', $url);
}
add_filter('script_loader_tag', 'defer_parsing_of_js', 10);
@kharakhordindemo
kharakhordindemo / form.php
Created Dec 22, 2017
Remove span in Contact Form 7
View form.php
/*Contact form 7 remove span*/
add_filter('wpcf7_form_elements', function($content) {
$content = preg_replace('/<(span).*?class="\s*(?:.*\s)?wpcf7-form-control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content);
$content = str_replace('<br />', '', $content);
return $content;
});
@joshuadavidnelson
joshuadavidnelson / basic-dropdown-usage.php
Last active Feb 18, 2021
Filter wp_dropdown_categories by post type.
View basic-dropdown-usage.php
<?php
/**
* Using wp_dropdown_categories with the post type filter applied.
*
* @link https://joshuadnelson.com/category-taxonomy-dropdown-filtered-by-post-type/
*/
// Taxonomy dropdown arguments
$args = array(
'taxonomy' => 'department',
@Mte90
Mte90 / dashboard-activity-cpt.php
Created Sep 18, 2015
Add your cpts to the Widget Activity of the Dashboard in WordPress
View dashboard-activity-cpt.php
<?php
/*
Plugin Name: Dashboard Widget Activity Custom Post Type
Plugin URI:
Description:
Author: Daniele Mte90 Scasciafratte
Version: 1.0.0
Author URI: http://mte90.net
*/
@glueckpress
glueckpress / no-comment.php
Last active Apr 2, 2021
[WordPress] This plugin started as a Gist, but can now be found at https://github.com/glueckpress/no-comment.
View no-comment.php
<?php
/**
* Plugin Name: No Comment
* Description: A plugin to close, disable and remove comments from the WordPress admin UI.
* Version: 0.1
* Author: Caspar Hübinger
* Author URI: https://profiles.wordpress.org/glueckpress/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
@gubi
gubi / fa-bounce.css
Last active Oct 13, 2020
Pulse animation for FontAwesome icons
View fa-bounce.css
.fa-bounce {
display: inline-block;
position: relative;
-moz-animation: bounce 1s infinite linear;
-o-animation: bounce 1s infinite linear;
-webkit-animation: bounce 1s infinite linear;
animation: bounce 1s infinite linear;
}
@-webkit-keyframes bounce {