Skip to content

Instantly share code, notes, and snippets.

View cdsaenz's full-sized avatar

charly cdsaenz

View GitHub Profile
@cdsaenz
cdsaenz / google-image-search.php
Last active August 23, 2022 21:57 — forked from susanBuck/google-image-search.php
google image search
<?php
# This grabs the keyword off the url -- index.php?keyword=Clouds
$keyword = $_GET['keyword'];
# Only do this if we've already passed in a keyword (i.e. it's not blank)
if($keyword != "") {
# Load the data from Google via cURL
$curl_handle = curl_init();
curl_setopt($curl_handle,CURLOPT_URL,"http://ajax.googleapis.com/ajax/services/search/images?v=1.0&imgsz=icon&q=".$keyword);
@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 / csdev-lang.php
Last active April 27, 2022 13:51
Wordpress Basic Translation Functions, URL, Session, Localization Domain Setup. Multilanguage
<?php
/**
* WP THEME MULTILINGUAL SUPPORT
* Used with Bootscore, WooCommerce
* Based on https://gist.github.com/l2aelba/5244912
* Version 1.0 - 5mar2022
* Version 2.0 - 27apr2022
* csdev
* NOTE: require this file from functions.php or integrate
@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
Last active August 24, 2022 16:00
.htaccess with expiration/caching settings
## EXPIRES CACHING ##
## verify module is enabled in apache !!! (expires,headers) ##
## ls /etc/apache2/mods-enabled
## sudo a2enmod headers
## sudo a2enmod expires
## sudo /etc/init.d/apache2 restart
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
@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 / 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.