Skip to content

Instantly share code, notes, and snippets.

View CarlosLongarela's full-sized avatar
🏠
WordPress Codeable Expert

Carlos Longarela CarlosLongarela

🏠
WordPress Codeable Expert
View GitHub Profile
@CarlosLongarela
CarlosLongarela / uploads_produccion.txt
Created July 19, 2022 22:06 — forked from fgrweb/uploads_produccion.txt
Código en .htaccess para que lea los archivos de medios del sitio en producción
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$
RewriteRule ^(.*)$ https://sitioproduccion.com/$1 [QSA,L]
# Para entornos NGINX me ha funcionado poner lo siguiente en la configuración
location ~* ^.+\.(svg|svgz|jpg|jpeg|gif|png|ico|bmp|pdf)$ {
try_files $uri @image_fallback;
}
location @image_fallback {
<?php
/**
* WordPress menu cache.
*
* @package BJ\Menu
* @author bjornjohansen
* @version 0.1.0
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License version 2 (GPLv2)
*/
@CarlosLongarela
CarlosLongarela / a_faster_load_textdomain.php
Last active November 23, 2022 00:27 — forked from soderlind/a_faster_load_textdomain.php
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
@CarlosLongarela
CarlosLongarela / hide-pods-admin.php
Created September 30, 2019 21:36
Hide Pods Admin Menu if logged user is different that "username"
/**
* Hide Pods Admin Menu if logged user is different that "username".
*/
function css_hide_pods_noncl() {
global $current_user;
if ( 'username' !== $current_user->user_login ) {
echo '<style type="text/css">#toplevel_page_pods{display:none!important;}</style>';
}
}
@CarlosLongarela
CarlosLongarela / wp-change-url.php
Last active December 1, 2018 15:48
Script for change old WordPress url to New WordPress url, from dev to live, live to dev, changes for https and other uses
<?php
/**
* Script for change WordPress live url to local url,
* local url to live url, http url to https url
* or any other url change in database.
*
* @author Carlos Longarela <carlos@longarela.eu>
* @link https://tabernawp.com/
*
*/
@CarlosLongarela
CarlosLongarela / get-order-detail-by-order-id.php
Created September 5, 2018 18:36 — forked from web-hat/get-order-detail-by-order-id.php
Works with WooCommerce 3.x or above
<?php
if (!function_exists('getOrderDetailById')) {
//to get full order details
function getOrderDetailById($id, $fields = null, $filter = array()) {
if (is_wp_error($id))
return $id;
@CarlosLongarela
CarlosLongarela / cl-product-delete-meta-price.php
Last active May 31, 2019 16:21
Delete WordPress WooCommerce ld+json price for hide in snippets like Google results
<?php
function cl_product_delete_meta_price( $product = null ) {
if ( ! is_object( $product ) ) {
global $product;
}
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
Verifying that "carloslongarela.id" is my Blockstack ID. https://onename.com/carloslongarela
@CarlosLongarela
CarlosLongarela / renombra-imagenes-wordpress.php
Created March 16, 2017 18:58
Función para renombrar los archivos subidos a la mediateca de WordPress
function dng_nombre_archivo( $filename, $filename_raw ) {
$info = pathinfo( $filename );
$nombre_arch = $info['filename'];
if ( ! empty( $info['extension'] ) ) {
$ext = $info['extension'];
} else {
$ext = '';
}
@CarlosLongarela
CarlosLongarela / optimizajpg-jpegoptim.php
Created March 16, 2017 00:09
Optimizar las imágenes con el programa de sistema jpegoptim desde PHP
/**
* Optimizar las imágenes con el programa de sistema jpegoptim
*
* @param array $array_imgs Array con los nombres de las fotos.
* @param string $ruta_fotos Ruta donde están las fotos.
* @param boolean $no_exec Si se ejecuta o sólo ver el resultado sin ejecutar.
*
* @return string|array Devuelve una cadena con el fallo o un array con los resultados.
*/
function optimiza_img( $array_imgs, $ruta_fotos = '', $no_exec = true ) {