Skip to content

Instantly share code, notes, and snippets.

Avatar

Gilberto Tavares camaleaun

View GitHub Profile
@camaleaun
camaleaun / script.js
Created Jun 17, 2021
Variations script
View script.js
/* global MutationObserver */
window.onload = function () {
const variation1 = document.getElementById( 'variation_1' );
const variation2 = document.getElementById( 'variation_2' );
const variation3 = document.getElementById( 'variation_3' );
const form = document.getElementById( 'product_form' );
const submit = form.querySelector( '[type=submit]' );
const observer = new MutationObserver( function ( mutations ) {
mutations.forEach( function ( mutation ) {
if (
View script.js
function isMobileWA()
{
return (/Android|webOS|iPhone|iPad|iPod|Windows Phone|IEMobile|Mobile|BlackBerry/i.test(navigator.userAgent) );
}
var elm = jQuery('a[href*="whatsapp.com"]');
jQuery.each(elm, function(index, value){
var item = jQuery(value).attr('href');
if(item.indexOf('chat') != -1){
//nothing
} else if (item.indexOf('web.whatsapp') != -1 && isMobileWA()){
@camaleaun
camaleaun / cf7-sales-call.php
Last active Oct 20, 2020
Integration Contact Form 7 with Sales Call
View cf7-sales-call.php
<?php
/**
* Integration Contact Form 7 with Sales Call.
*/
function wpcf7_sales_call_register_service() {
$integration = WPCF7_Integration::get_instance();
$integration->add_category(
'call_request',
@camaleaun
camaleaun / .htaccess
Created Jun 16, 2020
Redirection old new domain
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com$
RewriteRule (.*)$ https://new.com/$1 [R=301,L]
</IfModule>
View scripts.js
window.addEventListener( 'load', () => {
document.querySelectorAll( '.sharing-anchor' ).forEach( ( anchor ) => {
anchor.addEventListener( 'click', () => {
if ( undefined !== navigator.share ) {
navigator.share( {
title: document.querySelector( 'meta[property="og:title"]' ).content,
text: document.querySelector( 'meta[property="og:description"]' ).content,
url: document.querySelector( 'meta[property="og:url"]' ).content,
} )
}
@camaleaun
camaleaun / functions.php
Last active May 30, 2020 — forked from jamesdixon/custom-fonts.php
Wordpress Allow Custom Font Upload
View functions.php
<?php
/**
* Allow fonts upload
*
* @param array $mime_types Current allowed mime types.
* @return array $mime_types Modified mime types.
*/
function allow_upload_fonts_mimes_types( $mime_types ) {
$mime_types = array_merge(
View composer.json
{
"require": {
"composer/installers": "^1.6"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"wp-coding-standards/wpcs": "^2.0"
},
"scripts": {
"php:lint": "composer install && vendor/bin/phpcs -p"
@camaleaun
camaleaun / comma.sql
Created Aug 2, 2019
Comma group contact mysql select join
View comma.sql
CREATE TABLE images (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL DEFAULT '0',
image longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
INSERT INTO images (post_id, image) VALUES (2,'image1.jpg'),(2,'image2.jpg');
@camaleaun
camaleaun / upload.php
Last active Jun 28, 2019
Tests file upload in server
View upload.php
<?php
/**
* Uploads tests.
*/
if ( $_POST && isset( $_POST['upload'] ) && ! empty( $_FILES ) ) {
/** Define ABSPATH as this file's directory */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
@camaleaun
camaleaun / functions.php
Last active Aug 13, 2019
Funcions Utils
View functions.php
<?php
add_filter( 'themename_twbs_bootstrap_defaults', 'themename_twbs_bootstrap_defaults' );
function themename_twbs_bootstrap_defaults( $defaults ) {
$defaults['version'] = '3.3.7';
$defaults['files'] = 'both';
$defaults['cdn'] = 'maxcdn';
$defaults['css_path'] = get_theme_file_uri( 'assets/css' );
$defaults['js_path'] = get_theme_file_uri( 'assets/js' );
return $defaults;