Skip to content

Instantly share code, notes, and snippets.

<?php
$hostsFile = "";
const SLEEP_TIME_SECONDS = 3600; // An hour
function addLine($line, $lineBreaksBefore = 0, $lineBreaksAfter = 0) {
global $hostsFile;
for ($i = 0; $i<$lineBreaksBefore; $i++) {
$hostsFile .= "\n";
@mohiuddin3824
mohiuddin3824 / WpBakery-types
Last active July 24, 2018 03:33
WpBakery page builder addon's types
textarea_html
exploded_textarea
dropdown
colorpicker
textfield
attach_image
checkbox
iconpicker
linecons
vc_link
@glueckpress
glueckpress / wp-rocket-no-browser-caching-pdf.php
Created April 5, 2018 08:51
[WordPress][WP Rocket] Add browser caching rule to .htaccess; example: zero browser caching for PDF files
<?php
/**
* Zero browser caching for PDF files.
*/
add_filter( 'rocket_htaccess_mod_expires', function ( $rules ) {
$rules .= '# Expires headers for PDF' . PHP_EOL;
$rules .= '<IfModule mod_expires.c>' . PHP_EOL;
$rules .= 'ExpiresByType application/pdf "access plus 0 seconds"' . PHP_EOL;
$rules .= '</IfModule>' . PHP_EOL . PHP_EOL;
@thezenmonkey
thezenmonkey / vc_vonts.php
Created April 3, 2018 18:39
Visual Composer Overide Google Font List
add_filter('vc_google_fonts_get_fonts_filter','custom_fonts');
// $font_list from js_composer/include/params/google_fonts/google_fonts.php
function custom_fonts( $fonts_list ) {
$fonts_list = array();
$open_sans = new stdClass();
$open_sans->font_family = 'Open Sans';
$open_sans->font_styles = '300,300italic,regular,italic,600,600italic,700,700italic,800,800italic';
// open all accordions with click on button
add_action( 'wp_footer', function() { ?>
<script>
( function( $ ) {
'use strict';
@glueckpress
glueckpress / wp-rocket-exclude-from-defer-only.php
Last active October 19, 2022 07:51
[WordPress][WP Rocket] Barely tested hack to exclude a file from defer JS only, without having to exclude it from minification.
<?php
/**
* WP Rocket:
* 1. Customise order of minification and defer operations.
* 2. Exclude file from defer JS only (still minified).
*
* Tested rudimentary with WP Rocket 2.11.7 and 3.0.x.
* Test before using this in production!
*/
add_action( 'wp_rocket_loaded', function () {
@wokamoto
wokamoto / http2_push.php
Last active June 8, 2018 07:48
[WordPress]http2_push.php
<?php
add_action('template_redirect', function(){
if ( headers_sent() ) {
return;
}
do_action('wp_enqueue_scripts');
foreach( array('style' => wp_styles(), 'script' => wp_scripts()) as $as => $wp_links ) {
$link = '';
@shehabkhan013
shehabkhan013 / googlefonts.php
Last active October 9, 2018 11:11
Wordpress google fonts Dynamic
//Refarence themeshaper
function theme_name_fonts_url() {
$fonts_url = '';
$OpenSans = _x( 'on', 'OpenSans font: on or off', 'theme-slug' );
$Montserrat = _x( 'on', 'Montserrat font: on or off', 'theme-slug' );
@RishniMeemeduma
RishniMeemeduma / 404.php
Last active January 12, 2018 05:29
Html to wordpress
<?php get_header(); ?>
<!-- BLOG AREA -->
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="box-layer custom-padding">
<section>
@glueckpress
glueckpress / wp-rocket-disable-inline-css-minify.php
Created December 21, 2017 08:08
[WordPress][WP Rocket] Disable minification of inline CSS when Minify HTML is enabled.
<?php
/**
* Disables Minify for inline CSS.
* https://github.com/wp-media/wp-rocket/blob/v2.11.3/inc/front/minify.php#L72
*/
add_filter( 'rocket_minify_html_options', function ( $html_options ) {
$html_options = array();
return $html_options;