Skip to content

Instantly share code, notes, and snippets.

require_short_url: some hosts require short URLs otherwise they redirect to a forbidden page

no_rewrite_wysijap: some hosts don't work with the URL rewriting wysijap/subscription bounce_max**: by default, we handle 100 bounce emails per process, with this option you can increase or decrease this value

urlstats_base64: to deactivate base 64 links

no_js_val: no AJAX subscription

allow_no_js: with Wysija, you can register with or without JavaScript. This option deactivates the JavaScript-less option which can be used by spammers

function mailpoet_enable_wpmail(){
if(class_exists('WYSIJA')){
$model_config = WYSIJA::get('config','model');
$model_config->save(array('allow_wpmail' => true));
}
}
add_action('init', 'mailpoet_enable_wpmail');
sshexec: {
dump_remote_db: {
options: {
host: '<%= mysql.remote.host %>',
username: '<%= mysql.remote.username %>',
agent: process.env.SSH_AUTH_SOCK
},
command: [
'cd <%= mysql.remote.save_path %>',
'mysqldump <%= mysql.remote.dbname %> -u <%= mysql.remote.dbuser %> -p<%= mysql.remote.dbpass %> > remote-<%= timestamp %>.sql'
@cfxd
cfxd / remove_cf7_assets-action_hook.php
Last active August 29, 2015 14:04
Load the Contact Form 7 Stylesheet and JavaScript Only When Necessary (the Right Way). See http://cfxdesign.com/load-the-contact-form-7-stylesheet-and-javascript-only-when-necessary/
<?php do_action('cf7_before_wp_head'); ?>
@cfxd
cfxd / clear_jetpack_published.php
Last active February 21, 2021 18:33
Clear Jetpack's Publicized data to re-Publicize posts. See http://cfxdesign.com/how-to-re-publicize-posts-with-jetpack/
<?php
function clear_jetpack_published() {
if(empty($_REQUEST['post'])) {
wp_die(__('Invalid post ID or action'));
}
global $wpdb;
$id = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : '';
@cfxd
cfxd / Gruntfile.js
Last active April 24, 2019 03:59
Remove Unused CSS from WordPress Automatically with Grunt. See http://cfxdesign.com/remove-unused-css-from-roots-theme-automatically-with-grunt/
'use strict';
module.exports = function(grunt) {
// Load all tasks
require('load-grunt-tasks')(grunt);
// Show elapsed time
require('time-grunt')(grunt);
var jsFileList = [
'assets/vendor/bootstrap/js/transition.js',
'assets/vendor/bootstrap/js/alert.js',
@cfxd
cfxd / passwordform-bootstrap.php
Last active August 29, 2015 14:04
Roots theme password protected post form function. Use the Bootstrap free markup with the Bootstrap LESS or use the Bootstrap markup version as standalone.
<?php
global $post;
$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
?>
<form action="<?php echo esc_url(site_url('wp-login.php?action=postpass', 'login_post')); ?>" class="post-password-form form-inline" method="post">
<p><?php _e('This content is password protected. To view it please enter your password below:', 'roots'); ?></p>
<p><label for="<?php echo $label; ?>" class="sr-only"><?php _e('Password:', 'roots'); ?></label></p>
<div class="input-group">
<input name="post_password" id="<?php echo $label; ?>" type="password" placeholder="<?php _e('Enter password', 'roots'); ?>" class="form-control" />
<span class="input-group-btn">
@cfxd
cfxd / .htaccess
Last active June 2, 2022 11:53
Deploy WordPress (Bedrock) with Capistrano to a Shared Host (Bluehost). See http://cfxdesign.com/deploy-wordpress-with-capistrano-on-bluehost/
RewriteEngine on
#change dev.example.com to your domain name
RewriteCond %{HTTP_HOST} ^(www.)?dev.example.com$
RewriteCond %{REQUEST_URI} !^/current/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /current/web/$1
#change dev.example.com to your domain name
RewriteCond %{HTTP_HOST} ^(www.)?dev.example.com$
RewriteRule ^(/)?$ current/web/index.php [L]
<?php
/*
* Plugin Name: AA Test Plugin
* Plugin URI: http://wordpress.org/extend/plugins/test
* Description: Testing all kinds of things!
* Author: Richard Archambault
* Version: 1.0
* License: GPL2+
*/
@cfxd
cfxd / wpcf7_dynamic_email_field.php
Last active July 6, 2016 15:39
WordPress Contact Form 7 filter: set your contact form's "To:" field to "%admin%" to automatically use the site admin email dynamically. See http://cfxdesign.com/contact-form-7-dynamic-email-field
<?php
function wpcf7_dynamic_email_field($args) {
if(!empty($args['recipient'])) {
$args['recipient'] = str_replace('%admin%', get_option('admin_email'), $args['recipient']);
return $args;
}
return false;
}
add_filter('wpcf7_mail_components', 'wpcf7_dynamic_email_field');