Skip to content

Instantly share code, notes, and snippets.

View dleone81's full-sized avatar
💭
I may be slow to respond.

Domenico dleone81

💭
I may be slow to respond.
View GitHub Profile
@dleone81
dleone81 / Country selector for Googlebot
Created June 23, 2023 17:09
This HTML page allows Googlebot to pick the right country and collects data from the target views. Based on rules, DNS manager has to catch the crawler only and display this page to it
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="A description of your website">
<meta name="keywords" content="">
<title>Put the title here</title>
@dleone81
dleone81 / www.conf
Last active December 19, 2018 15:53
To update upload_max_filesize && post_max_size on Ubuntu 14.04 LTS with PHP Version 5.5.9-1ubuntu4.24 with PHP5-FPM support you've to update /etc/php5/fpm/pool.d/www.conf
# add at bottom file
# /etc/php5/fpm/pool.d/www.conf
php_value[upload_max_filesize] = 8M
php_value[post_max_size]=10M
# after reboot the service
sudo service php5-fpm restart
@dleone81
dleone81 / wordpress-custom-comment-template.php
Last active July 9, 2018 08:02
Create custom template for comments in Wordpress. You can use the above code in functions.php during theme or plugin development.
# comments.php
# update comments.php in child theme
<div class="comment-list">
<?php
// ref: https://codex.wordpress.org/Function_Reference/wp_list_comments#Arguments
$args = [
'walker' => null,
@dleone81
dleone81 / gist:b8e8e3ed3f5caeddba47096d17963aba
Last active May 23, 2018 21:33
Wordpress changing site url in multisite environment.
# update config.php:
define('DOMAIN_CURRENT_SITE', 'www.newsiteurl.tld');
# update wordpress/wp-content/uploads/nginx-helper/map.conf
# this step works only for NginX webserver
# update wp_options table
UPDATE `db_name`.`wp_options` SET `option_value`='http://www.newsiteurl.tld' WHERE `option_name`='home';
UPDATE `db_name`.`wp_options` SET `option_value`='http://www.newsiteurl.tld' WHERE `option_name`='siteurl';
@dleone81
dleone81 / sshd_config
Last active April 11, 2018 09:44
SFTP Ubuntu 14 LTS
# https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-16-04
# https://askubuntu.com/questions/79565/how-to-add-existing-user-to-an-existing-group
# mount --bind /path/target /var/sftp/uploads
sshd_config add at the bottom of file
Match User USERNAME
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /var/sftp
PermitTunnel no
@dleone81
dleone81 / functions.php
Last active February 13, 2017 12:26
Remove specific product from woo commerce cart
function remove_product_from_cart() {
if( is_cart() || is_checkout() ) {
global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item_key => $item){
if($item['line_total'] == '0' && $item['line_subtotal'] == '0') {
$remove_items = $woocommerce->cart->remove_cart_item($item_key);
}
}
@dleone81
dleone81 / reindexall.sh
Created March 11, 2016 08:48
Avoid Magento
#!/bin/bash
# This file reindex all Magento indexes without any lock table
# This is the right order to reindexall via script
# I update every 3 sec any Magento product via API.
# Before this script I noticed this error
# SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
echo "Reindexall via script"
php /mage/magento/shell/indexer.php --reindex cataloginventory_stock
php /mage/magento/shell/indexer.php --reindex catalog_product_attribute
@dleone81
dleone81 / fpc-cron.php
Last active February 28, 2016 10:57
Clean Lesti FPC cache for specific tags
<?php
/**
* Schedule this via cron if yuo need to empty Lesti FPC cache for products and categories
**/
require_once('app/Mage.php');
umask(0);
Mage::app();
@dleone81
dleone81 / catalog_product_update.php
Created February 2, 2016 10:41
Magento update custom attribute via API SOAP2
<?php
$proxy = new SoapClient("http://www.mydomain.com/api/v2_soap/?wsdl");
$sessionId = $proxy->login("myuser", "mypass");
$update_data = array (
'additional_attributes' => array (
'single_data' => array (
array ('key' => 'foreign_visibility', 'value' => '1')
)
@dleone81
dleone81 / functions.php
Last active February 1, 2016 14:59
Add or remove product to specific category based on product custom attributes
/**
* Add / Remove product to 'Angolo delle offerte' on product save action
**/
function update_product_category( $post_id ) {
global $post;
if(function_exists('get_product')) {
$product = get_product($post->ID);
if($product->is_type('variable')) {
$available_variations = $product->get_available_variations();
$catarray = array();