Skip to content

Instantly share code, notes, and snippets.

View sebastianmoran-mainwp's full-sized avatar
🚀
Fast Lane Strategies: Turbocharging Your WordPress Website for Optimal Speed.

Sebastian Moran sebastianmoran-mainwp

🚀
Fast Lane Strategies: Turbocharging Your WordPress Website for Optimal Speed.
View GitHub Profile
<?php
/**
* AMP WebP Img Wrapper
*
* @package AMP_WebP_Img_Wrapper
* @author Weston Ruter, Google
* @link https://gist.github.com/westonruter/332abdb2adefc6b204ad6fcc1beecedf
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
@thomasplevy
thomasplevy / llms_before_checkout_validation-email-blacklist.php
Last active May 11, 2020 17:02
Create an email blacklist to prevent spam checkouts when using LifterLMS
<?php // Don't copy this line to your functions.php file.
/**
* Create an email blacklist to prevent spam registrations during LifterLMS checkout
*
* This is hooked to llms_before_checkout_validation
*
* This filter runs prior to any built-in checkout form validations allowing custom
* validations to be run.
*
@leepowers
leepowers / wpseo-yoast-sitemap-custom.php
Last active March 28, 2024 05:19
WordPress Yoast SEO: Create a custom sitemap with data not sourced from a custom post type.
<?php
/**
* USAGE:
* - Search and replace the `CUSTOM_SITEMAP` string with a lowercase identifier name: e.g., "vehicles", "customer_profiles"
* - The `your_alternate_data_source()` function does not exist; it's simply a placeholder for your own function that returns some sort of data array.
* - Uses heredocs for inline XML: https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
*/
/**
@majick777
majick777 / autosplit-admin-menu.php
Last active October 22, 2019 17:24
Auto Split WordPress Admin Menu
<?php
// -----------------------------
// === Auto Split Admin Menu ===
// -----------------------------
// Automatically splits WordPress Admin Menus into 3 sections:
// A = Dashboard and Post Type Menus
// B = All Other Default WordPress Menus
// C = Any Other Added Menu Items
.woocommerce div.product.elementor form.cart.variations_form .woocommerce-variation-add-to-cart,
.woocommerce div.product.elementor form.cart:not(.grouped_form):not(.variations_form) {
display: block;
}
.elementor-element ul.pewc-product-extra-groups {
padding: 0;
}
@mathetos
mathetos / site-health-curl-test.php
Last active May 9, 2019 18:53
Add cURL test to WP 5.2 Site Health tests
<?php
/**
* Adds a cURL version test to Site Health
*
* Info here: https://make.wordpress.org/core/2019/04/25/site-health-check-in-5-2/
* NOTE: Requires version 5.2+ of WordPress
*
**/
@wp-seopress
wp-seopress / filter-the-analyzed-content.php
Last active September 25, 2020 03:06
Filter the analyzed content
function sp_content_analysis_content($content, $id) {
//$content = default WP editor
//$id = current post ID
//Example to add your custom field to content analysis
//Flexible content must be called like this: name_of_your_flexible_content_0_name_of_your_field
$cf = get_post_meta($id, 'my-custom-field', true);
$content = $content.$cf;
return $content;
}
add_filter('seopress_content_analysis_content', 'sp_content_analysis_content', 10, 2);
@davekiss
davekiss / gist:2639184ac066c53416b23c5a66f42d1e
Created February 2, 2019 17:44
EDD Weekly Domain Report via Email
/**
* Add a weekly email report that summarizes which domains that
* your products are being used on.
*/
add_filter( 'cron_schedules', function( $schedules ) {
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __('Once Weekly')
);
@futtta
futtta / autoptimize_defer_inline_jquery.php
Last active November 11, 2022 21:43
POC to defer inline JS that requires jQuery
<?php
add_action('plugins_loaded','ao_defer_inline_init');
function ao_defer_inline_init() {
if ( get_option('autoptimize_js_include_inline') != 'on' ) {
add_filter('autoptimize_html_after_minify','ao_defer_inline_jquery',10,1);
}
}
function ao_defer_inline_jquery( $in ) {
@bogdan-mainwp
bogdan-mainwp / custom-mainwp-menu-header.php
Last active December 6, 2018 14:00
Custom snippet for renaming the MainWP Dashboard WP Admin menu header
<?php
// Add the following code snippet to the functions.php file of the MainWP Customisations plugin
// Download MainWP Customisations here: https://github.com/mainwp/mainwp-customisations
// More about the plugin: https://mainwp.com/mainwp-customisations/
add_action( 'admin_head', 'mycustom_menu_admin_head' );
function mycustom_menu_admin_head() {
global $menu;
foreach( $menu as &$item ) {