Skip to content

Instantly share code, notes, and snippets.

View joecue's full-sized avatar
🎯
Focusing

Joe Querin joecue

🎯
Focusing
View GitHub Profile
@joecue
joecue / .lando.yml
Last active September 7, 2022 17:43
WordPress Multisite - Lando Config
# Replace the entries with {{ }} around them with your customizations.
name: {{ myproject }}
recipe: wordpress
config:
php: "7.4"
via: nginx
config:
vhosts: config/default.conf.tpl
webroot: {{ webroot }}
@joecue
joecue / php-pools.md
Created June 3, 2021 17:19 — forked from holmberd/php-pools.md
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
@joecue
joecue / plugin.php
Created March 12, 2021 21:12
Custom Form within WordPress Admin Dashboard Custom Menu Page
<?php
//Check for hidden field value and select appropriate API field needed
if( $_POST['action'] == 'filterdates' ){
check_admin_referer( 'filter-date', '_wpnonce_filter-date' );
$requestUrl = $sDomain ."/api/v3/events?\$expand=instances";
$currentYear = date("Y");
@joecue
joecue / functions.php
Last active March 12, 2021 20:05
Find What Custom WordPress $hook name is.
//Function Prefixed to not collide with other LCCC related functions or current plugins and WP Core.
function lc_load_custom_wp_admin_style($hook ) {
wp_die($hook );
}
add_action('admin_enqueue_scripts', 'lc_load_custom_wp_admin_style' );
@joecue
joecue / WP_flush_cache_and_transients.php
Created November 14, 2019 16:25 — forked from Jany-M/WP_flush_cache_and_transients.php
[WordPress] Flush Object Cache (Memcached) & Transients - Admin buttons
<?php
// Flush Cache from Admin bar
function flush_memcache_button() {
global $wp_admin_bar;
// If User isnt even logged in or if admin bar is disabled
if ( !is_user_logged_in() || !is_admin_bar_showing() )
return false;
@joecue
joecue / greyscale_colorize_wp_post_images.php
Created November 14, 2019 16:25 — forked from Jany-M/greyscale_colorize_wp_post_images.php
[WP] Colorize (after greyscale), depending on post type, a post image (either feat, parsed or external) and save it as new to uploads
<?php
// This script assumes we are in a Post Loop
// Get the image you need however you like, I use https://github.com/Jany-M/WP-Imager
$image_orig = wp_imager($img_w, $img_h, 3, '', true, '', true, null, null, true);
// Check for image headers to avoid Error 400 - if all images come always from same server/site you dont need this
$userAgent = 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0';
$ch = curl_init ($image_orig);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@joecue
joecue / WP_gists_as_wordpress_posts.php
Created November 14, 2019 16:23 — forked from Jany-M/WP_gists_as_wordpress_posts.php
[WordPress] Display Gists as if they were real WordPress Posts (without saving them to database)
<?php
// This will display Gists as if they were real WP posts, so you can display them mixed with real ones too
// This will NOT add the Gists as real posts in your DB, you won't see them in your backend
/* --------------------------------------
|
| Real Posts Loop
|
|---------------------------------------*/
@joecue
joecue / wp_scripts.php
Created November 14, 2019 16:15 — forked from Jany-M/wp_scripts.php
[WP] Add async, defer and origin attributes to WordPress scripts
<?php
// Place the handles somewhere convenient
global $scripts_to_defer, $scripts_to_async, $scripts_origin;
$scripts_to_defer = array('fancybox_js', 'bootstrap_js');
$scripts_to_async = array('fontawesome_js');
$scripts_origin = array('fontawesome_js');
// Put this in functions.php
function add_defer_attribute($tag, $handle) {
@joecue
joecue / random_masonry.js
Created November 14, 2019 16:14 — forked from Jany-M/random_masonry.js
Masonry image size randomizer (with PHP, LESS and isotope.js)
$('.grid').isotope({
itemSelector: '.grid-item',
//percentPosition: true,
masonry: {
columnWidth: 100
}
})
@joecue
joecue / manage_paragraphs.php
Created November 14, 2019 16:14 — forked from Jany-M/manage_paragraphs.php
[WP][PHP] Split first paragraph from main content, display it elsewhere
<?php
// Grab the first paragraph, show it where you need it, then take the rest of the content and remove the first paragraph and show it elsewhere
// The script uses WordPress functions/content but can be used in any PHP script, just replace the WP functions
// First Paragraph
global $post;
$p1 = wpautop( $post->post_content );
$p1 = substr( $p1, 0, strpos( $p1, '</p>' ) + 4 );
//$p1 = strip_tags($p1, '<a><strong><em><h3><h2><i>'); // in case you need to remove some tags, add the ones you want to KEEP here