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 / 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);
@andergmartins
andergmartins / stringIsBoolean.js
Created April 29, 2016 03:04 — forked from deenison/stringIsBoolean.js
Gist that proposes have some fun with values (strings) that may or may not be a boolean.
/**
* Method that tests a string to check if it's value can be assumed as a (bool), regardless of being true/false.
* Note: If the string is empty, this function will return false since there's "no value" to be tested.
* @examples:
* "1".isBool() // returns true
* "yEs".isBool() // returns true
* "off".isBool() // returns true
* "".isBool() // returns false
* " ".isBool() // returns false
*
tell application "Finder"
try
set appPath to (path to application "Evernote" as text)
on error
display dialog "Couldn't find Evernote. Is it installed?"
end try
set printPath to (path to "dlib" from user domain as text) & "PDF Services"
make new alias at printPath to appPath with properties {name:"Send PDF to Evernote"}
end tell
<?php
// no direct access
defined('_JEXEC') or die;
// Variables
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$template = 'templates/' . $this->template;
// get html head data
@andergmartins
andergmartins / select2_fixed_widgets.py
Last active August 29, 2015 13:57 — forked from BertrandBordage/gist:8288704
Fix a wrong class name
# WARNING: This is just a workaround. Consider it as a very
# temporary solution if you really need this feature.
from django.utils.safestring import mark_safe
from django_select2.util import convert_to_js_arr
TEMPORARY_ID = 0
@andergmartins
andergmartins / ssh-config-github-multiple-deploy-keys
Last active January 3, 2016 14:39
When using a CI server, like Jenkins, in conjunction with github, you may wish to use multiple deploy keys (github-speak for an rsa key pair that has been assigned to a single repo, rather than a user) to allow Jenkins to pull code from the github repositories
# In the example here, where three repos are used, the idea is to take advantage of ssh's config mechanism
# For use with Jenkins, do the following:
# login to your CI Server
sudo su -s /bin/bash jenkins
cd ~/.ssh/
# then create three key key pairs
ssh-keygen -f id_rsa_project1
# on prompt, set target file to id_rsa_project1
# repeat for id_rsa_project2 and id_rsa_project3
@andergmartins
andergmartins / 0_reuse_code.js
Created October 10, 2013 01:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<form>
<div class="btn-group" data-toggle-name="is_private" data-toggle="buttons-radio" >
<button type="button" value="0" class="btn" data-toggle="button">Public</button>
<button type="button" value="1" class="btn" data-toggle="button">Private</button>
</div>
<input type="hidden" name="is_private" value="0" />
</form>