Skip to content

Instantly share code, notes, and snippets.

@holmberd
holmberd / php-pools.md
Last active April 19, 2024 07:24
Adjusting child processes for PHP-FPM (Nginx)

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
@mkg20001
mkg20001 / generate-nginx-cloudflare-allow.sh
Last active April 5, 2024 07:41
A script to generate a config to allow or additionally allow cloudflare addresses for a specific domain
#!/bin/bash
set -e
cf_ips() {
echo "# https://www.cloudflare.com/ips"
for type in v4 v6; do
echo "# IP$type"
curl -sL "https://www.cloudflare.com/ips-$type/" | sed "s|^|allow |g" | sed "s|\$|;|g"
@soderlind
soderlind / a_faster_load_textdomain.php
Created October 26, 2015 22:08
A faster load_textdomain for WordPress
<?php
/*
Plugin Name: A faster load_textdomain
Version: 0.0.1
Description: While we're wating for https://core.trac.wordpress.org/ticket/32052.
Author: Per Soderlind
Author URI: https://soderlind.no
Plugin URI: https://gist.github.com/soderlind/610a9b24dbf95a678c3e
License: GPL
@ThatGuySam
ThatGuySam / allowed-block-types.php
Last active October 31, 2023 08:06
Limit allowed Gutenberg Blocks with full list of native Wordpress Blocks
<?php
// Hook up function to allowed_block_types filter
add_filter( 'allowed_block_types', 'set_allowed_block_types' );
/**
* Set allowed gutenburg block types
* https://rudrastyh.com/gutenberg/remove-default-blocks.html
*/
@yankiara
yankiara / oxygen-repeater-dynamic-query.php
Last active September 6, 2023 19:25
Use dynamic queries with Oxygen's repeater
/* I'll put here different examples of dynamic query for Oxygen repeater :
* - Use one of the following repeater_dynamic_query definitions
* in code block just BEFORE the repeater
* - Set the repeater custom query settings : post type, number of posts, order...
* - Add the remove_action in a code block AFTER the repeater
*/
/****************************************************************************************************
* Display related posts for any CPT with taxonomy:
@JTruax
JTruax / wp-snippets.php
Last active June 29, 2023 17:54
WordPress Function Snippets
<!--------------------------------------------------------
SNIPPETS INDEX
-- 01 - Enqueue Google Fonts
-- 02 - Make jQuery load from Google Library
-- 03 - Customize excerpt length and read more characters
-- 04 - Enable Pagination Links
-- 05 - Replace WP login logo with custom
-- 06 - Displays a custom Dashboard Widget
-- 07 - Allow different file formats in Media Library
-- 08 - Turn Off Your Self-referring Pingbacks
@lubieowoce
lubieowoce / yoast_coauthors_integration.php
Last active June 1, 2023 01:17
Integrate Yoast with CoAuthors Plus
<?php
// Written against:
// - Yoast SEO 12.3
// - Co-Authors Plus 3.4
// - Wordpress 4.9.3
// - PHP 7.1
/*
@ulziibat-n
ulziibat-n / wpseo_schema_organization.php
Created September 10, 2019 14:14 — forked from nicomollet/wpseo_schema_organization.php
Yoast SEO Organization Schema Replaced By LocalBusiness
<?php
/**
* Add LocalBusiness to schema Organization
*
* @api array $data The graph piece to filter.
*
* @return array
*/
function custom_wpseo_schema_organization($data){
@fedegomez
fedegomez / checkTitles.js
Last active May 24, 2023 03:38
Checks if the title of the result in the SERP matches the title of the URL
javascript: (function (doc){var changed=0; function checkTitles(){console.log('jQuery version ', $.fn.jquery, ' loaded'); var position=1; var items=[]; var results=$('#rso .kp-blk .g, #rso .g[class="g"], #rso .srg .g').not('.kno-kp .g').find('div:first').find('a:first'); $('.title-changed, #CountTitlesChanged').remove(); results.each(function (){if (!$(this).parents('.related-question-pair').length){var parent=$(this).closest('.tF2Cxc').length > 0 ? $(this).closest('.tF2Cxc') : $(this).closest('li'); items.push([ position, $(this).find('h3').text(), encodeURI($(this).attr('href')), parent]); position++;}}); var numItems=1; cors_proxies=[ 'https://api.codetabs.com/v1/proxy?quest=', 'https://jsonp.afeld.me/?url=',]; items.forEach(item=>{$.ajax({url: cors_proxies[Math.floor(Math.random() * cors_proxies.length)] + item[2], success: function (data, status, xhr){title=$(data).filter('title').text(); var html='<div class="title-changed">'; if (title !=item[1]){html +='<span style="font-weight: bold;color: #ff6961;">
@icetee
icetee / wp_ext_pll_functions.php
Last active March 20, 2023 12:54
Polylang function_exists (active the plugin) - WordPress - Paste the code into functions.php
/*
* Polylang Language API functions tester - WordPress
* Github: https://gist.github.com/icetee/fbbfef5534fead58611e
*
*/
function ex_pll_the_languages($arg = '') {
if ( function_exists('pll_the_languages') ) {
return pll_the_languages($arg);
}