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
@nilovelez
nilovelez / Robot.txt robot rules
Last active April 24, 2023 10:38
Add rules to the robots.txt file
add_filter( 'robots_txt', function( $output, $public ) {
$add = "# 0. Un robot no puede perjudicar a la Humanidad ni, por omisión, permitir que la Humanidad sufra daño.\n";
$add .= "# 1. Un robot no debe perjudicar a un ser humano ni, por omisión, permitir que un ser humano sufra daño, salvo cuando esto vulnere la Ley Cero.\n";
$add .= "# 2. Un robot debe obedecer las órdenes que le son dadas por un ser humano, excepto si estas órdenes entran en conflicto con la Primera Ley.\n";
$add .= "# 3. Un robot debe proteger su propia existencia, hasta donde esta protección no entre en conflicto con la Primera o la Segunda Ley.\n";
return $add . $output;
}, 99, 2 );
@fgrweb
fgrweb / uploads_produccion.txt
Last active July 19, 2022 22:06
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
/**
* SOAP Test for Redsys.
*
* @package WooCommerce Redsys Gateway (https://woocommerce.com/es-es/products/redsys-gateway/)
* @copyright José Conti
*/
if ( ! class_exists( 'SoapClient' ) ) {
echo 'ATENCIÓN, SOAP NO ACTIVO';
@otakupahp
otakupahp / autoloader.php
Last active August 24, 2022 10:09
Simple WordPress Autoloader
<?php
spl_autoload_register(function($required_file) {
# Transform file name from class based to file based
$fixed_name = strtolower( str_ireplace( '_', '-', $required_file ) );
$file_path = explode( '\\', $fixed_name );
$last_index = count( $file_path ) - 1;
$file_name = "class-{$file_path[$last_index]}.php";
# Get fully qualified path