Skip to content

Instantly share code, notes, and snippets.

@topleague
topleague / webp-conversion-wordpress.php
Created December 16, 2017 05:12
Convert PNG/JPG Files into WebP Format in WordPress
#Apache WebP Configuration
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule ^(wp-content/uploads.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
@glueckpress
glueckpress / wp-rocket-critical-css-params.php
Created December 15, 2017 14:55
[WordPress][WP Rocket] As of 2.11, WP Rocket generates critical CSS automatically. Here’s how to adjust parameters for maximum viewport width and height.
<?php
/**
* Customise parameters for critical CSS generator.
*/
add_filter( 'rocket_cpcss_job_request', function ( $item ) {
return array(
'url' => $item['url'],
'mobile' => 0, // 1 = Emulate a mobile device
'viewport_width' => 1300 // px maximum width of the viewport
'viewport_height' => 900 // px maximum height of the viewport
@glueckpress
glueckpress / wp-rocket-remove-cache-options-meta-box.php
Last active October 5, 2023 09:54
[WordPress][WP Rocket] Remove Cache Options meta box from Edit screens.
<?php
/**
* PLEASE SEE COMMENT BELOW:
* https://gist.github.com/glueckpress/0fcd12a8ada43e37e400facd987016a1#gistcomment-3009533
*/
defined( 'ABSPATH' ) or die();
/**
* Plugin Name: WP Rocket | Remove Cache Options Meta Boxx
* Description: Removes the Cache Options meta box from Edit screens.
* Author: Caspar Hübinger
@wolfthemes
wolfthemes / add-wvc-social-networks.php
Created December 12, 2017 10:08
Add social network to Wolf WPBakery Page Builder extension
/**
* Add social networks
*/
function add_social_networks( $socials ) {
$socials[] = 'wechat';
$socials[] = 'weibo';
return $socials;
}
@lukecav
lukecav / functions.php
Last active February 9, 2018 21:26
Kill Gutenberg in WordPress
function kill_gutenberg_post_type( $is_enabled, $post_type ) {
if ( ‘post’ === $post_type || ‘page’ === $post_type ) {
return false; //==> add_action( ‘admin_print_scripts-edit.php’,…) ==> gutenberg_replace_default_add_new_button is disabled
}
return $is_enabled;
}
add_filter( ‘gutenberg_can_edit_post_type’, ‘kill_gutenberg_post_type’, 10, 2 ); //gutenberg_add_edit_link_for_post_type
function kill_gutenberg_modify_add_new_button_url( $url, $path ) {
<script type="text/javascript">
// Make jQuery WP friendly
(function ($) {
// Initiate after document loads
$( document ).ready(function() {
// Custom function
jQuery('#content a').click(function(){
jQuery('html, body').animate({
@lukecav
lukecav / functions.php
Created December 1, 2017 03:57
Add wording after the regular price in WooCommerce
add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
function custom_price_message( $price ) {
$wording = ' Pricing ';
return $price . $wording;
}
@lukecav
lukecav / functions.php
Created December 1, 2017 03:56
Add wording before the regular price in WooCommerce
add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
function custom_price_message( $price ) {
$wording = ' Pricing ';
return $wording . $price;
}
@kisildev
kisildev / index.php
Last active March 1, 2019 10:52
Remove & Restore Wp Plugins
/******************* HIDE/SHOW WORDPRESS PLUGINS MENU ITEM *********************/
/**
* Remove and Restore ability to Add new plugins to site
*/
function remove_plugins_menu_item($role_name){
$role = get_role( $role_name );
$role->remove_cap( 'activate_plugins' );
$role->remove_cap( 'install_plugins' );
@kneupmedia
kneupmedia / remove-read-more-link-in-wordpress-feed
Created November 18, 2017 13:46
Remove "Read more" link from WordPress Feed