Skip to content

Instantly share code, notes, and snippets.

View davidperezgar's full-sized avatar

David Perez davidperezgar

View GitHub Profile
@davidperezgar
davidperezgar / escape-svg.php
Created September 22, 2024 09:17
Escape SVG
<?php
public function escapeSvg( string $svg ): string {
$svg_args = array(
'svg' => array(
'xmlns' => true,
'id' => true,
'class' => true,
'style' => true,
@davidperezgar
davidperezgar / close-akismet.sh
Created June 17, 2024 12:26
Automate Plesk change plugin Spam from Akismet to Antispam Bee
#!/bin/bash
# Usar comando bash
# Obtener la lista de todas las instalaciones de WordPress y sus IDs
mapfile -t wordpress_ids < <(plesk ext wp-toolkit --list | awk '{print $1}' | tail -n +2)
# Iterar sobre cada ID de WordPress
for instance in "${wordpress_ids[@]}"
do
@davidperezgar
davidperezgar / download.php
Created June 22, 2022 06:23
Force download file with Get option and generates GA event
<?php
// ---------------------------------
// File: download.php
// Author: Jim Penaloza
// Web: http://blog.unijimpe.net
// ---------------------------------
// verify file
if (!isset($_GET['file']) || empty($_GET['file'])) {
exit();
@davidperezgar
davidperezgar / updatemeta.php
Created July 6, 2021 07:56
Updates meta and adds text to taxonomy
<?php
define('WP_USE_THEMES', false);
require_once('wp-load.php');
echo 'iniciado proceso.<br />';
/**
* Finds product categories ids from array of names given
*
@davidperezgar
davidperezgar / generatepress-comments-hook.php
Created April 7, 2020 14:41
GeneratePress | Add Comments in custom post type
/**
Appearance > Elements > Add new Hook
Hook: after_content
Execute PHP: active
Display rules: All singular of CPT
From: https://generatepress.com/forums/topic/applying-blog-archive-and-single-post-settings-to-custom-type-post/#post-903150
**/
<span class="comments-link">
<?php comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); ?>
</span>
@davidperezgar
davidperezgar / clean-node-modules.sh
Created August 3, 2019 10:29
Clean Node modules folders
find . -name "node_modules" -exec rm -rf '{}' +
@davidperezgar
davidperezgar / htaccess.txt
Created May 30, 2019 14:52
Redirect all domain to new and keep url path
<IfModule mod_rewrite.c>
RewriteEngine On
redirectMatch 301 ^(.*)$ https://www.domain.com$1
</IfModule>
@davidperezgar
davidperezgar / wpcli-updates.sh
Created April 23, 2019 15:22
WordPress rutine SH to update all Local WordPress
#!/bin/bash
#
#
clear
for d in * ; do
#if [ -e "$d/wp-config.php" ]; then
cd "$d"
echo "-----------------------------"
echo "Updating WordPress in... $d"
wp core update
@davidperezgar
davidperezgar / script-fb-track.js
Created April 23, 2019 11:55
Facebook Track Script
<script>fbq('track', 'Lead');</script>
@davidperezgar
davidperezgar / wc-update-weight.php
Created April 16, 2019 08:54
WooCommerce rutine for update weights products
<?php
ini_set( 'memory_limit', '1024M' );
ini_set( 'max_execution_time', 600 );
define( 'WP_USE_THEMES', false );
require_once 'wp-load.php';
echo 'iniciado proceso.' . date( 'H:i:s', time() ) . '<br />';
$weight_final = '1000';