Skip to content

Instantly share code, notes, and snippets.

View s3rgiosan's full-sized avatar

Sérgio Santos s3rgiosan

View GitHub Profile
@johnbillion
johnbillion / hierarchy.php
Last active June 22, 2023 23:05
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Theme Template Hierarchy Last updated for WordPress 5.4
==================================
This diagram is partially simplified for legibility. To view the complete template hierarchy in use on your site see the
Template panel in the Query Monitor plugin.
@BronsonQuick
BronsonQuick / wp_cli_command_to_delete_all_woocommerce_users
Created April 16, 2015 04:32
WP-CLI command to delete all WooCommerce users
wp user list --field=ID --role=customer | xargs wp user delete --yes
@paulirish
paulirish / what-forces-layout.md
Last active June 9, 2024 13:52
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@wkw
wkw / README.md
Last active April 5, 2024 08:26
WordPress functions to selectively disable WPEngine site caching temporarily.

Controlled WPEngine Cache Busting

This technique was used to control WPEngine's caching by making WPE think there was a WordPress CMS user logged in by setting a fake cookie.

This code was developed to display site-wide dynamic content when a user authenticated against an external (non-WordPress) service.

N.B.: this worked as of 10/2015, but WPE may make infratructure changes which break the technique.

Usage

<?php
/**
* Make an internal REST request
*
* @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
* @param $request_or_method WP_REST_Request|string A WP_REST_Request object or a request method
* @param $path (optional) if the path is not specific in the rest request, specify it here
* @param $data (optional) option data for the request.
* @return WP_Error|mixed
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active May 27, 2024 17:37
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@jazzsequence
jazzsequence / update.sql
Created February 12, 2016 21:24
Update wp_postmeta and wp_posts database tables with posts from another site
# What if you are trying to migrate a bunch of posts from one site into
# another site that already has content? We'll assume you already have
# a database export of the posts and postmeta you want to migrate. You
# will want to create a database locally to alter the tables to get them
# ready to merge into the production database that already has content.
# You will also need to know the highest `meta_id` and `ID` values from
# the `wp_postmeta` and `wp_posts` tables, respectively.
# First, we need to create new columns in the tables we have locally. To
# do this the right way, we are going to figure out what type of data
@petenelson
petenelson / wordpress-list-users.sql
Created May 3, 2016 18:00
WordPress: MySQL query to list user names, emails, and first & last name
SELECT wp_users.user_login, wp_users.user_email, firstmeta.meta_value as first_name, lastmeta.meta_value as last_name FROM wp_users left join wp_usermeta as firstmeta on wp_users.ID = firstmeta.user_id and firstmeta.meta_key = 'first_name' left join wp_usermeta as lastmeta on wp_users.ID = lastmeta.user_id and lastmeta.meta_key = 'last_name'
@ffoodd
ffoodd / improved-sr-only.markdown
Last active May 16, 2024 23:15
Improved .sr-only

Improved .sr-only

Theorically bulletproof CSS class for visually hide anything and keep it accessible to ATs.

A Pen by ffoodd on CodePen.

License.

@igorbenic
igorbenic / admin.js
Last active September 2, 2021 12:29
Extending the WordPress Media Uploader: Custom Tab | http://ibenic.com/extending-wordpress-media-uploader-custom-tab
var Library = wp.media.controller.Library;
var oldMediaFrame = wp.media.view.MediaFrame.Post;
// Extending the current media library frame to add a new tab
wp.media.view.MediaFrame.Post = oldMediaFrame.extend({
initialize: function() {
// Calling the initalize method from the current frame before adding new functionality
oldMediaFrame.prototype.initialize.apply( this, arguments );