Skip to content

Instantly share code, notes, and snippets.

View thomasgriffin's full-sized avatar
👋

Thomas Griffin thomasgriffin

👋
View GitHub Profile
@thomasgriffin
thomasgriffin / database-indexes.txt
Created November 22, 2023 12:30
Helpful indexes and SQL queries to add to make WordPress run faster.
alter table `wp_usermeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_postmeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_termmeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_commentmeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_edd_customermeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_edd_licensemeta` add index `ndx_meta_key_meta_val1` (`meta_key`(40), `meta_value`(191));
alter table `wp_posts` add index `ndx_id_post_status_val1` (`id`, `post_status`);
SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM wp_options WHERE autoload='yes'
UNION
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '532160876956612',
autoLogAppEvents : true,
xfbml : true,
version : 'v3.2'
});
};
@thomasgriffin
thomasgriffin / deletecustomvariable.js
Created December 9, 2015 21:47
OptinMonster Dynamic Text Replacement API - deleteCustomVariable
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
/**
* API method for deleting a custom variable. Must be accessed via the app object.
*
* @param string $key The custom variable to delete.
* @return null
*/
app.deleteCustomVariable('foo');
};
@thomasgriffin
thomasgriffin / hascustomvariables.js
Created December 9, 2015 21:44
OptinMonster Dynamic Text Replacement API - hasCustomVariables
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
/**
* API method for checking if any custom variable has been registered.
* Must be accessed via the app object.
*
* @return bool True if any custom variable has been registered, false otherwise.
*/
app.hasCustomVariables();
};
@thomasgriffin
thomasgriffin / hascustomvariable.js
Last active May 7, 2020 21:51
OptinMonster Dynamic Text Replacement API - hasCustomVariable
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
/**
* API method for checking if a custom variable has been registered.
* Must be accessed via the app object.
*
* @param string $key The custom variable key to check.
* @return bool True if the custom variable exists, false otherwise.
*/
app.hasCustomVariable('foo');
@thomasgriffin
thomasgriffin / getcustomvariables.js
Created December 9, 2015 21:40
OptinMonster Dynamic Text Replacement API - getCustomVariables
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
/**
* API method for retrieving all custom variables. Must be accessed via the app object.
*
* @return object A JavaScript object with key/value pairs for custom variables.
*/
app.getCustomVariables();
};
</script>
@thomasgriffin
thomasgriffin / getcustomvariable.js
Created December 9, 2015 21:38
OptinMonster Dynamic Text Replacement API - getCustomVariable
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
/**
* API method for retrieving a custom variable. Must be accessed via the app object.
*
* @param string $key The custom variable key to retrieve.
* @return string|bool The value of the custom variable key or false if not found.
*/
app.getCustomVariable('foo');
};
@thomasgriffin
thomasgriffin / setcustomvariable.js
Last active May 7, 2020 21:47
OptinMonster Dynamic Text Replacement API - setCustomVariable
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
/**
* API method for setting a custom variable. Must be accessed via the app object.
*
* @param string $key The custom variable key to set.
* @param string $value The custom variable value to set for the key.
* @return null
*/
app.setCustomVariable('foo', 'bar');
@thomasgriffin
thomasgriffin / variablefunctioncallback.js
Last active August 28, 2018 16:40
OptinMonster Dynamic Replacement API - variable function callback example.
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
app.setCustomVariable('name', 'Thomas');
};
</script>
@thomasgriffin
thomasgriffin / customvariablefunction.js
Created December 9, 2015 17:55
OptinMonster Dynamic Replacement API - function callback example.
<script type="text/javascript">
function OptinMonsterCustomVariables(app) {
app.setCustomVariable('name', 'Thomas');
}
</script>