Skip to content

Instantly share code, notes, and snippets.

View davidperezgar's full-sized avatar

David Perez davidperezgar

View GitHub Profile
@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';
@davidperezgar
davidperezgar / script-fb-pageview.js
Created April 9, 2019 11:57
Facebook Script Page View for Google Tag Manager
<script>fbq('track', 'PageView');</script>
@davidperezgar
davidperezgar / gist-orders.sh
Created April 5, 2019 22:08
Site ground Installation for Git
ssh-keyscan -t rsa itm20.siteground.biz >> ~/.ssh/known_hosts
cd ~/.ssh/
nano [your-private-key]
chmod 600 [your-private-key]
ssh-add -K ~/.ssh/[your-private-key]
# Poner la frase privada que da SG-Git
git clone ssh://[url]