Skip to content

Instantly share code, notes, and snippets.

<?php
// Initilise cURL
$ch = curl_init();
// Set the cURL Options
$optArray = array(
CURLOPT_URL => 'https://example.com/api/getInfo/',
CURLOPT_RETURNTRANSFER => true
);
@alexander-young
alexander-young / functions.php
Created January 15, 2020 02:32
Defer Javascript in WordPress
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 December 22, 2017 15:21
Remove span in Contact Form 7
/*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 February 27, 2023 13:44
Filter wp_dropdown_categories by post type.
<?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 September 18, 2015 11:27
Add your cpts to the Widget Activity of the Dashboard in WordPress
<?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 April 2, 2021 20:35
[WordPress] This plugin started as a Gist, but can now be found at https://github.com/glueckpress/no-comment.
<?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 September 14, 2023 17:58
Pulse animation for FontAwesome icons
.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 {