Skip to content

Instantly share code, notes, and snippets.

View andergmartins's full-sized avatar

Anderson Grüdtner Martins andergmartins

View GitHub Profile
@andergmartins
andergmartins / gist:f9c61dd032fe49d2a1efdb46d3756422
Created July 31, 2024 18:50
Get direct connection to Codeception Integration test DB
<?php
// This works inside a test class that extends \lucatume\WPBrowser\TestCase\WPTestCase.
$loaderConfig = $this->getModule('lucatume\WPBrowser\Module\WPLoader')->_getConfig();
$db = new \lucatume\WPBrowser\WordPress\Database\MysqlDatabase(
$loaderConfig['dbName'],
$loaderConfig['dbUser'],
$loaderConfig['dbPassword'],
$loaderConfig['dbHost'],
$loaderConfig['tablePrefix']
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