Skip to content

Instantly share code, notes, and snippets.

View cdsaenz's full-sized avatar

charly cdsaenz

View GitHub Profile
@cdsaenz
cdsaenz / dequeue-woocommerce-js-css-on-non-woo-pages.php
Created February 20, 2022 15:06 — forked from carasmo/dequeue-woocommerce-js-css-on-non-woo-pages.php
Dequeue WooCommerce CSS and JS on non-WooCommerce pages for 3.6.4
<?php
//don't add above twice if it already exists
/**
* Check if WooCommerce Page of all kinds (not just cart and shop)
* @thanks: https://faish.al/2014/01/06/check-if-it-is-woocommerce-page/
* Checked IDS with WooCommerce Repo 1 June 2019
*/
function ca_is_really_woocommerce_page() {
@cdsaenz
cdsaenz / mercadolibre_access_token.sh
Created February 22, 2022 16:24 — forked from cavi21/mercadolibre_access_token.sh
Generate an access token for a MercadoLibre Account without the need of doing it through OAuth flow
curl -s -X POST -H 'content-type: application/x-www-form-urlencoded' 'https://api.mercadolibre.com/oauth/token' -d 'grant_type=client_credentials' -d 'client_id=[CLIENT_ID]' -d 'client_secret=[CLIENT_SECRET]'
@cdsaenz
cdsaenz / functions.php
Created March 2, 2022 19:06 — forked from l2aelba/functions.php
This is a Multilingual Wordpress functions to detect a language by pretty URLs like.. `domain.com/en/` `domain.com/postname/en/` `domain.com/pagetname/en/` Add this code in your `functions.php` After added code go to `wp-admin/options-permalink.php` press `Save Changes` So you can use `<?php echo lang();?>` `<?php if( lang() === "en" ) ?>` In yo…
function lang_support() {
return array('en','fr'); // Add your support lang-code (1st place is a default)
}
function rewrite_lang(){
$langs = lang_support();
foreach($langs as $lang) {
add_rewrite_endpoint($lang,EP_PERMALINK|EP_PAGES|EP_ROOT|EP_CATEGORIES);
}
}
@cdsaenz
cdsaenz / http2_apache2_ubuntu20.04.md
Created March 6, 2022 22:33 — forked from GAS85/http2_apache2_ubuntu20.04.md
How to Enable HTTP/2 in Apache 2.4 on Ubuntu 20.04

Based on https://gist.github.com/GAS85/8dadbcb3c9a7ecbcb6705530c1252831

Requirements

  • A self-managed VPS or dedicated server with Ubuntu 20.04 running Apache 2.4.xx.
  • A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.

Step 1: Install Apache2

Per default it will be apache2 version 2.4.41 what is enought for http2 support.

@cdsaenz
cdsaenz / .htaccess
Created March 19, 2022 02:20
Laravel .htaccess to remove public without anything else. Tested in Laravel 8.
# Source is https://stackoverflow.com/a/48494280/827376
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
@cdsaenz
cdsaenz / gist:0887a45847c9e1e34494c9132683fec1
Created March 23, 2022 14:36 — forked from Niloys7/gist:17b88d36c1c38844a6cf2127c15dee63
Get Product Gallery Images - WooCommerce
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id )
{
//Get URL of Gallery Images - default wordpress image sizes
echo $Original_image_url = wp_get_attachment_url( $attachment_id );
echo $full_url = wp_get_attachment_image_src( $attachment_id, 'full' )[0];
echo $medium_url = wp_get_attachment_image_src( $attachment_id, 'medium' )[0];
@cdsaenz
cdsaenz / wc_cancelled_order_add_customer_email.php
Created March 31, 2022 15:09 — forked from jrick1229/wc_cancelled_order_add_customer_email.php
Add customer email to Cancelled Order recipient list
<?php
/*
* Add customer email to Cancelled Order recipient list
*/
function wc_cancelled_order_add_customer_email( $recipient, $order ){
return $recipient . ',' . $order->billing_email;
}
add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
@cdsaenz
cdsaenz / PHOGReadme.md
Last active April 5, 2022 22:17
PHOG SSG in PHP

PHOG PHP Preprocessor for HTML Output Generation

ALIAS "Peckles"

By Charly @ CSDev.com.ar.

A Proof-Of-Concept PHP Script to create a static site from template-injected HTML and dynamic data, mostly inspired in Jekyll (and ideas from others like Sculpin) but PHP/Composer-based without required nodejs dependencies.

Why not using the existing SSG solutions?

  • 100% PHP solution desired.
Add to header or function file:
<?php
// URL Segments and Master ID
//
// Segment Variables: $GLOBALS['segment']['1'], $GLOBALS['segment']['2'], etc.
// Master ID Variable: $GLOBALS['master_id']
global $segment;
global $master_id;