Skip to content

Instantly share code, notes, and snippets.

View algmelo's full-sized avatar

André Melo algmelo

View GitHub Profile
@algmelo
algmelo / wp_rewrite_rules.log
Created January 28, 2023 14:42 — forked from thenbrent/wp_rewrite_rules.log
Default WordPress Rewrite Rules
[rules] => Array (
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[tag/([^/]+)/?$] => index.php?tag=$matches[1]
[type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
@algmelo
algmelo / fix-wordpress-permissions.sh
Created August 5, 2020 18:04 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@algmelo
algmelo / wp-fix-meta-serialization.php
Created July 26, 2018 21:49 — forked from kythin/wp-fix-meta-serialization.php
Fix wordpress serialized variables in custom meta data when running a migration
<?php
/*
* Wordpress postmeta find&replace code
*
* This file should be run on your source database to echo out update statements to run on your migrated database.
* It is to address the issue of when doing a find/replace on an sql file during a wordpress migration, that breaks
* any content changed within wordpress serialized meta values, particularly if you have custom post types etc.
*
* Do your normal find/replace over the exported sql, import it into your new database, then run this code and copy the resulting
* update SQL into your new database to fix it.
@algmelo
algmelo / run-all.sql
Created May 7, 2018 17:00 — forked from eduardopintor/run-all.sql
These are various SQL Queries to run to update urls within a WordPress Database. These queries assume the table prefix is the standard `wp_`, if you have a custom prefix you will need to update the queries. I also recommend changing the default urls using this method: https://codex.wordpress.org/Changing_The_Site_URL or http://codex.wordpress.or…
/* Set our Old and New URLS */
SET @oldurl := "http://www.oldsite.com";
SET @newurl := "http://www.newsite.com";
/* Replaces URL in WordPress Home and Site URL in wp_options */
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
/* Replaces URL in GUID of all posts/cpt/etc */
/* https://deliciousbrains.com/wordpress-post-guids-sometimes-update/ */
UPDATE wp_posts SET guid = replace(guid, @oldurl, @newurl);
@algmelo
algmelo / popular-posts.php
Created July 20, 2017 19:08 — forked from wturrell/popular-posts.php
Wordpress & Google Analytics - retrieve most popular posts
@algmelo
algmelo / repeatable-fields-metabox.php
Created July 5, 2017 17:28 — forked from helen/repeatable-fields-metabox.php
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@algmelo
algmelo / add-term-to-post-tag.php
Created July 5, 2017 16:15 — forked from ms-studio/add-term-to-post-tag.php
add term metabox to post_tag taxonomy - using WP 4.4 term meta functions
<?php
// source: http://wordpress.stackexchange.com/questions/211703/need-a-simple-but-complete-example-of-adding-metabox-to-taxonomy
// code authored by jgraup - http://wordpress.stackexchange.com/users/84219/jgraup
// REGISTER TERM META
add_action( 'init', '___register_term_meta_text' );
function ___register_term_meta_text() {