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 / aifw-create-categories.php
Created December 23, 2020 19:28
AIFW - Will create categories if not found.
<?php
/**
* Plugin Name: AIFW Create Categories
* Description: Will create categories if not found.
* Version: 1.0.0
* Author: Mário Valney
* Author URI: https://mariovalney.com
* Text Domain: aifw-create-categories
*
* @link https://github.com/mariovalney/api-improver-for-woocommerce
@mariovalney
mariovalney / bootstrap-dropdown-wp-nav-menu.php
Created September 17, 2020 22:04
Add dropdown classes to your wp_nav_menu() output
<?php
/**
* Plugin Name: Bootstrap Dropdown on WP Nav Menu
* Description: Add dropdown classes to your wp_nav_menu() output
* Version: 1.0.0
* Author: Mário Valney
* Author URI: https://mariovalney.com
* Text Domain: bootstrap-dropdown-wp-nav-menu
*/
@mariovalney
mariovalney / cf7-custom-select.php
Created July 12, 2020 16:06
Add data to select of Contact Form 7 like Listo
<?php
/**
* Plugin Name: CF7 Custom Select
* Description: Add data to select like Listo
* Version: 1.0.0
* Author: Mário Valney
* Author URI: https://mariovalney.com
* Text Domain: cf7-custom-select
*/
@mariovalney
mariovalney / create-shortcut.sh
Created March 7, 2020 15:22
Creates a desktop entry on /usr/share/applications
#!/bin/bash
set -euo pipefail
# Common variables
BL=$'\n'
SELECT_YES="YES"
SELECT_NO="NO"
SELECT_OVERWRITE="Overwrite"
SELECT_EXIT="Exit"
@mariovalney
mariovalney / wc-products-shortcode-by-user.php
Last active January 20, 2020 18:56
WC Products Shortcode by User
<?php
/**
*
* Plugin Name: WC Products Shortcode by User
* Description: Ass "current_user" to [products] shortcode to show only products from current user.
* Version: 1.0.0
* Author: Mário Valney
* Author URI: https://mariovalney.com
* Text Domain: wc-products-shortcode-by-user
*
@mariovalney
mariovalney / script.php
Created December 4, 2019 17:29
Turn exported WooCommerce/WordPress Orders into CSV file
<?php
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
header("Pragma: no-cache");
header("Expires: 0");
// Load file
$xml_string = file_get_contents(dirname(__FILE__) . '/file.xml');
str_replace($xml_string, 'dc:', 'dc-');
@mariovalney
mariovalney / SavePNG4XP.jsx
Last active November 13, 2019 19:20
This script is designed to be used as a script that runs after a save event. It's based on default 'Save Extra JPEG' and will save a PNG next to the current active if 'X-Plane' or 'Aircraft' are presented on path. This script does not handle 'as a copy' when saving.
/**
* Developed by Mário Valney <mariovalney@gmail.com>
*
* Inspired on "Save Extra JPEG" and created using:
* https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop_scriptref_js.pdf
*/
/**
* @@@BUILDINFO@@@ Save PNG 4 XP.jsx 1.0.0 Thu Oct 24 2019 19:21:44 GMT-0300
*/
@mariovalney
mariovalney / monitor.js
Created August 6, 2019 13:39
Monitor a API Endpoint to check JSON and sent data to Slack
"use strict";
const API_URL = "https://api.example.com/your-endpoint"; // Your API request
const SLACK_URL = ""; // Check: https://api.slack.com/incoming-webhooks
const NOTIFICATION = {text: "ITEM I WANT CHANGED!"}; // Message sent to Slack
const INTERVAL = 60000; // Interval in miliseconds
const interval = setInterval(() => {
fetch(API_URL)
.then(response => {
@mariovalney
mariovalney / vizir-masks.js
Created June 26, 2019 16:00
Add the most used masks. Requires jQuery Mask Plugin.
'use strict';
jQuery(document).ready(function($) {
// Nineth Digit behavior
var ninethDigitMask = function( val ) {
return ( val.replace( /\D/g, '' ).length === 11 ) ? '(00) 00000-0000' : '(00) 0000-00009';
}
// Multiple Documents Behaviour
var multipleDocumentsMask = function( val, e, field, options ) {
@mariovalney
mariovalney / Database.php
Last active June 6, 2019 00:42
A simple implementation of Active Record.
<?php
namespace App\Database;
interface Database
{
public static function getInstance();
public function create(string $table, array $columns);