Skip to content

Instantly share code, notes, and snippets.

View andergmartins's full-sized avatar

Anderson Grüdtner Martins andergmartins

View GitHub Profile
public function is_cache_plugin_installed() {
return
function_exists( 'w3tc_flush_post' ) ||
function_exists( 'wp_cache_post_change' ) ||
function_exists( 'rocket_clean_post' ) ||
has_action( 'cachify_remove_post_cache' ) ||
has_action( 'litespeed_purge_post' ) ||
function_exists( 'wpfc_clear_post_cache_by_id' ) ||
class_exists( 'WPO_Page_Cache' ) ||
has_action( 'cache_enabler_clear_page_cache_by_post' ) ||
@andergmartins
andergmartins / sort-posts-by-meta.php
Created October 23, 2020 19:22
Sort PHP posts by PublishPress editorial metadata
<?php
/**
* @param WP_Query $query
*
* @return bool
*/
function pp_should_change_post_order($query)
{
// Add a conditional here to filter when the queries should be filtered.
return true;
nome sigla
Acre AC
Alagoas AL
Amapá AP
Amazonas AM
Bahia BA
Ceará CE
Distrito Federal DF
Espírito Santo ES
Goiás GO
socat TCP-LISTEN:33064,reuseaddr,fork UNIX-CONNECT:/Users/anderson/Library/Application\ Support/Local/run/eUTWMHcg4/mysql/mysqld.sock
@andergmartins
andergmartins / smart-loader.php
Last active April 14, 2020 20:35
Smart loader for libraries in WordPress
<?php
use PPWPProPluginsAds\Autoloader;
if (file_exists(__DIR__ . '/vendor')) {
require_once __DIR__ . '/vendor/autoload.php';
}
$version = '0.1.0';
@andergmartins
andergmartins / smart-load-library.php
Last active February 17, 2020 16:17
Smart Loading for libraries in WordPress
<?php
/**
* Increment this number for every build.
* You can use an environment variable if you prefer.
*
* @var int
*/
$buildNumber = 1;
@andergmartins
andergmartins / class-virtualthemedpage-bc.php
Created December 31, 2018 19:50 — forked from brianoz/class-virtualthemedpage-bc.php
WordPress Virtual page with theme
<?php
/*
* Virtual Themed Page class
*
* This class implements virtual pages for a plugin.
*
* It is designed to be included then called for each part of the plugin
* that wants virtual pages.
*
* It supports multiple virtual pages and content generation functions.
@andergmartins
andergmartins / functions-mu-encryption.php
Created December 3, 2017 00:04 — forked from muhammad-naderi/functions-mu-encryption.php
Wordpress encrypt usermeta data database
<?php
/**
* Created by PhpStorm.
* User: Muhammad
* Date: 05/07/2016
* Time: 01:20 PM
*/
add_filter('get_user_metadata', 'decrypt_user_meta',10,4);
<?php
include dirname(__FILE__) . '/../Database/dbcon.php';
header('Content-Type: text/html; charset=utf-8');
$inicio = $_REQUEST['inicio'];
$fin = $_REQUEST['final'];
$sql = "SELECT SUM(gastos.Cantidad) 'Cantidad', YEAR(gastos.Fecha) 'anio'
FROM ciclo
INNER JOIN gastos ON ciclo.Identificador = gastos.year_id
@andergmartins
andergmartins / resize.scpt
Created November 17, 2016 00:57
Resize files to multiple sizes and move to folders with the same name of the source file
set image_ext_list to {"jpg", "jpeg", "png"}
set size_list to {"64", "48", "32", "24", "16"}
set source_path to (choose folder "Select the folder with the base images" without invisbles) as text
set dest_path to (choose folder "Select the destination folder" without invisbles) as text
with timeout of 86400 seconds
tell application "Finder"
set image_files to (files of entire contents of (source_path as alias) whose name extension is in image_ext_list) as alias list
end tell
end timeout