Skip to content

Instantly share code, notes, and snippets.

View roelmagdaleno's full-sized avatar
🏠
Working from home

Roel Magdaleno roelmagdaleno

🏠
Working from home
View GitHub Profile
<?php
function get_estimated_reading_time( $content = '', $wpm = 250 ) {
$content = strip_tags( $content );
$word_count = str_word_count( $content );
return ceil( $word_count / $wpm );
}
@roelmagdaleno
roelmagdaleno / gist:f0978e10e13a2c6247e3154d4e71df1d
Last active December 12, 2019 20:51
WP CLI: Export and Import Pages
# Export all pages
wp export --post_type=page
# Delete all pages from staging
wp post delete $(wp post list --post_type='page' --format=ids)
# Import XML in staging
wp import example.wordpress.2016-06-21.xml --authors=skip
@roelmagdaleno
roelmagdaleno / export.php
Last active December 10, 2019 22:27
Export and Import WordPress Page Templates
<?php
add_action( 'wp_loaded', 'rmr_export_page_templates' );
function rmr_export_page_templates() {
$pages = get_posts( array(
'numberposts' => -1,
'post_type' => 'page',
) );
@roelmagdaleno
roelmagdaleno / mu-disable-plugin.php
Created November 13, 2019 23:01
MU plugin to disable a selected plugin before WordPress load
<?php
/*
Plugin Name: Disable Plugin
Plugin URI: https://roelmagdaleno.com
Description: Disable Plugin
Version: 0.1.0
Author: Roel Magdaleno
Author URI: https://roelmagdaleno.com
*/
@roelmagdaleno
roelmagdaleno / mp-create-preference.sh
Created May 14, 2019 03:34
Crear una preferencia en MercadoPago usando cURL
curl -X POST \
'https://api.mercadopago.com/checkout/preferences?access_token=[ACCESS_TOKEN]' \
-H 'content-type:application/json' \
-d '{
"items": [
{
"title": "Dummy Item",
"description": "Multicolor Item",
"quantity": 1,
"currency_id": "ARS",
@roelmagdaleno
roelmagdaleno / wp-coinmarketcap.php
Last active January 21, 2022 18:47
Show the latest cryptocurrencies in WordPress admin bar.
<?php
/*
Plugin Name: WP CoinMarketCap
Plugin URI: https://roelmagdaleno.com/
Description: Get the latest cryptocurrency data.
Version: 2.0
Author: Roel Magdaleno
Author URI: https://roelmagdaleno.com/
License: GPL2