Skip to content

Instantly share code, notes, and snippets.

@wplit
wplit / style.css
Last active February 14, 2022 07:23
Allow tabbing across the sub menu items in Oxygen Menu (for keyboard user)
/* Allows focus on sub menu items by tabbing menu
------------------------------------------------ */
.oxy-nav-menu:not(.oxy-nav-menu-open) .menu-item .sub-menu {
right: 5000px;
visibility: visible;
}
.oxy-nav-menu:not(.oxy-nav-menu-open).menu-item .sub-menu .sub-menu {
right: auto;
@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"
@hnq90
hnq90 / functions.php
Created January 11, 2018 16:52 — forked from yoren/functions.php
Parent Post From Another Post Type And A New URL Structure In WordPress
<?php
// Flush rewrite rules after switch theme
function my_rewrite_flush() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );
// A little help so we can get the stylesheet from parent theme
// Remove line 10-19 if this is not a child theme
function my_enqueue_styles() {
@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
@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
@habibimroncn
habibimroncn / pll.md
Last active January 3, 2022 11:59
Get Current language on Polylang Plugin for Wordpress.

Reference for language code : Language Code

<?php 
$currLang = get_bloginfo('language');
if($currLang == "id-ID"){ // Replace condition with your language code.
	echo 'Bahasa Indonesia';
} else {
	echo 'up to you'
}
?&gt;
@amboutwe
amboutwe / yoast_seo_json_remove.php
Last active July 23, 2021 08:08
Remove all JSON output by Yoast SEO
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove all JSON output by Yoast SEO
* Credit: Yoast development team
* Documentation: https://developer.yoast.com/schema-documentation/api/
* Last Tested: Apr 16 2019 using Yoast SEO 11.0 on WordPress 5.1.1
*/
add_filter( 'wpseo_json_ld_output', '__return_false' );
@c3mdigital
c3mdigital / cacheable-ajax.php
Last active February 19, 2023 13:35
Example of how to cache fronted ajax requests in WordPress. This will allow you to use ajax and page caching like varnish or redis. Where ajax requests would normally not be cached using the built in wp_ajax_action method.
<?php
add_filter( 'rewrite_rules_array', 'cache_frontend_ajax_rules' );
/**
* Rewrite rules filter to add rules for front end ajax calls
*
* @param array $rewrite_rules
*
* @return array
*/
@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
@cdsalmons
cdsalmons / htaccess-vhost
Last active December 14, 2022 09:41
Base htaccess rules
# v2 7/29/2015
# prevent listing files in folders
Options -Indexes
# some security rules
<IfModule mod_rewrite.c>
RewriteEngine On
# prevent php execution in uploads
RewriteRule /uploads/.*\.php - [F]