Skip to content

Instantly share code, notes, and snippets.

@yankiara
yankiara / wp-defer-scripts.js
Created January 17, 2020 11:01
Defer enqueued JS scripts in Wordpress
View wp-defer-scripts.js
add_filter( 'script_loader_tag', 'yankiara_defer_scripts', 10, 3 );
function yankiara_defer_scripts( $tag, $handle, $src ) {
$defer = array( 'script-handle-1', 'script-handle-2', 'script-handle-3' );
if ( in_array( $handle, $defer ) )
return '<script src="' . $src . '" defer="defer" type="text/javascript"></script>' . "\n";
return $tag;
}
@yankiara
yankiara / fluid-fonts-and-icons.css
Last active July 10, 2021 04:31
Fluid fonts and icons in CSS
View fluid-fonts-and-icons.css
body {
--base: 20;
--scale-headings: 1.44;
--scale-mobile: 0.7;
--scale-mobile-headings: 0.4;
--scale-icons: 1.4;
--min-viewport: 480;
--max-viewport: 1600;
--max-size: var(--base);
}
@holmberd
holmberd / php-pools.md
Last active November 24, 2023 14:51
Adjusting child processes for PHP-FPM (Nginx)
View php-pools.md

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
View utf8-to-utf8mb4.php
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
@tatemz
tatemz / docker-wordpress.sh
Last active December 29, 2020 17:25
A quick way to get a WordPress installation up and running with Docker
View docker-wordpress.sh
#!/bin/bash
mkdir wordpress-site && cd wordpress-site
touch docker-compose.yml
cat > docker-compose.yml <<EOL
version: "2"
services:
my-wpdb:
@kshnurov
kshnurov / jquery.photoswipe.js
Created February 23, 2015 23:37
PhotoSwipe: init from DOM using jQuery
View jquery.photoswipe.js
(function( $ ) {
$.fn.photoswipe = function(options){
var galleries = [],
_options = options;
var init = function($this){
galleries = [];
$this.each(function(i, gallery){
galleries.push({
id: i,
@zioproto
zioproto / qtranslate_wordpress39.patch
Created April 17, 2014 10:11
Fix qTranslate plugin for Wordpress 3.9
View qtranslate_wordpress39.patch
diff --git a/wp-content/plugins/qtranslate/qtranslate_core.php b/wp-content/plugins/qtranslate/qtranslate_core.php
index 17b4669..9ac128a 100644
--- a/wp-content/plugins/qtranslate/qtranslate_core.php
+++ b/wp-content/plugins/qtranslate/qtranslate_core.php
@@ -414,6 +414,7 @@ function qtrans_updateTermLibrary() {
function qtrans_strftime($format, $date, $default = '', $before = '', $after = '') {
// don't do anything if format is not given
+ return $default;
@forgeandsmith
forgeandsmith / Gravity Forms Reset Styles
Last active June 22, 2021 07:33
Gravity Forms SCSS reset styles for easy style editing and management
View Gravity Forms Reset Styles
///////////////////////////////////////////////
////// GRAVITY FORMS RESET STYLES //////
///////////////////////////////////////////////
// These styles are made in mind to be used with SCSS or LESS
// If you use these styles, you must go to the Gravity Forms settings in the WordPress back end and set Output CSS to No.
////----- Core Containers
.gform_heading,
.gform_body,
@spivurno
spivurno / gw-gravity-forms-map-fields-to-field.php
Last active May 22, 2023 17:27
Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
View gw-gravity-forms-map-fields-to-field.php
<?php
/**
* Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
*
* Usage
*
* 1 - Enable "Allow field to be populated dynamically" option on field which should be populated.
* 2 - In the "Parameter Name" input, enter the merge tag (or merge tags) of the field whose value whould be populated into this field.
*
* Basic Fields
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active November 30, 2023 10:25
A badass list of frontend development resources I collected over time.
View frontendDevlopmentBookmarks.md