Skip to content

Instantly share code, notes, and snippets.

View mariovalney's full-sized avatar
🏠
Working from home

Mário Valney mariovalney

🏠
Working from home
View GitHub Profile
@mariovalney
mariovalney / woo-enable-reviews-bulk-edit.php
Created August 7, 2017 19:55
WooCommerce Enable Reviews - Bulk Edit
<?php
/**
*
* Plugin Name: WooCommerce Enable Reviews - Bulk Edit
* Description: Allow enable reviews by bulk edit into WooCommerce
* Version: 1.0.0
* Author: Mário Valney
* Author URI: http://mariovalney.com
* Text Domain: woo-enable-reviews-bulk-edit
*
@mariovalney
mariovalney / AddMask.js
Created August 11, 2017 15:08
Plugin jQuery para criar máscaras para inputs
(function ($) {
var AddMask = {
masks: {
phone: function(value) {
var new_value = '',
value = this.number(value);
if (value.length <= 0) {
new_value = '';
} else if (value.length < 3) {
@mariovalney
mariovalney / functions.php
Last active October 4, 2017 01:34
Compare two meta_values in WP_Query
<?php
add_filter( 'posts_request', 'gist_posts_request' );
function gist_posts_request( $sql ) {
if ( strrpos( $sql, 'value_of_' ) === false ) {
return $sql;
}
$matches = array();
@mariovalney
mariovalney / functions.php
Created November 24, 2017 13:32
A function to wrap a string with "A" HTML tag if it's a link
<?php
function wrap_with_link( $string ) {
/**
* The Regex:
*
* From the start of the string we look for http or https protocols or just "://"
* After that we look for one or more not-whitespace string plus dot in the end
* After that we look for one not-whitespace-with-2-or-3 string
* In the end we look for one '?' or '/' character and than zero or more not-whitespace string
@mariovalney
mariovalney / human-text.jquery.js
Last active January 10, 2018 15:12
A simple jQuery plugin to make a input be checked against punctuation, spaces and wrong capitalized words.
(function ($) {
$.fn.humanText = function(options) {
var defaults = {}, settings = {}, app = {};
/**
* Array of default settings:
*
* - last_mark: string The mark to last line. Default is period (.);
*/
defaults = {
@mariovalney
mariovalney / load-csv-to-database.php
Last active May 20, 2019 14:20
LOAD DATA from file to Database
<?php
/**
* Adding data to table using CSV data
* Using WPDB in WordPress but you can use any PHP...
*
* @link https://dev.mysql.com/doc/refman/5.7/en/load-data.html
*/
global $wpdb;
@mariovalney
mariovalney / .gitignore
Created April 8, 2018 14:40
Gitignore para WordPress
#------------------------------#
# Gitignore to WordPress #
#------------------------------#
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
@mariovalney
mariovalney / class-vzr-updater-helper.php
Last active July 14, 2018 00:18
A Helper to help you create Pages, Elementor and ACF Data to be inserted using installers
<?php
/**
* VZR_Updater_Helper
* Helper to VZR_Module_Updater
*
* @package VZR_Example
* @subpackage VZR_Module_Updater
* @since 1.0.0
*
*/
@mariovalney
mariovalney / wp-loop.sublime-snippet
Created October 9, 2018 18:30
[Sublime Text 3] WordPress Loop Snippet
<snippet>
<content><![CDATA[if ( ${8:\$the_query->}have_posts() ) : ${1:?>
${2:<!-- HTML Before Loop -->}
<?php }while ( ${9:\$the_query->}have_posts() ) : ${10:\$the_query->}the_post(); ?>
${3:<!-- Post Content -->}
<?php endwhile;${4: ?>
${5:<!-- HTML After Loop-->}
<?php }${6:else : ?>
${7:<!-- HTML If No Content-->}
<?php }endif;
@mariovalney
mariovalney / jquery-slick-filterable.js
Created November 9, 2018 17:54
Filter a Slick carousel when using grid mode (rows).
(function( $ ) {
$.fn.slickFilterable = function( options ) {
/**
* A plugin to create a slick we can filter.
*
* If you are not using Rows you can use slickFilter
* (check documentation) otherwise we can provide a valid filter.
*
* options {