Skip to content

Instantly share code, notes, and snippets.

View RafaelFunchal's full-sized avatar

Rafael Funchal RafaelFunchal

View GitHub Profile
# Activate the wordpress importer
wp plugin activate wordpress-importer --url=http://localhost/example.com/
# Iterate over all of the import files in a given folder.
for f in myfolder/*.xml; do wp import $f --authors=skip --skip=attachment --url=localhost/example.com/; done
@RafaelFunchal
RafaelFunchal / .htaccess
Created July 28, 2015 20:12
Exclude the files ajax, upload and WP CRON scripts from authentication
# Exclude the files ajax, upload and WP CRON scripts from authentication
<FilesMatch "(admin-ajax\.php|media-upload\.php|async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Order allow,deny
Allow from all
Satisfy any
</FilesMatch>
<?php
// The ID of the lists you want to add a user to
$list_ids = array( 1 );
// User Data without the custom fields
$data_subscriber = array(
'user' => array(
'email' => '[email protected]',
'firstname' => 'John',
'lastname' => 'Doe',
@RafaelFunchal
RafaelFunchal / MailPoet: Conditional to stop loading files in MailPoet pages
Last active August 29, 2015 14:05
If your theme or plugin is inserting files in MailPoet pages and it is breaking some functions, you should apply this conditional to load your files
<?php
/**
* If your theme or plugin is inserting files in MailPoet pages
* and it is breaking some functions, you should apply this
* conditional to load your files.
*
* Normally themes use these functions wp_enqueue_style() and wp_enqueue_script()
*/
if ( ( isset($_GET['page']) && $_GET['page'] != 'wysija_campaigns' ) && ( isset($_GET['page']) && $_GET['page'] != 'wysija_subscribers' ) && ( isset($_GET['page']) && $_GET['page'] != 'wysija_statistics' ) && ( isset($_GET['page']) && $_GET['page'] != 'wysija_config' ) ) {
// Put your enqueue styles and scripts here
@RafaelFunchal
RafaelFunchal / MailPoet: Select newsletter checkbox in register page by default
Last active August 29, 2015 14:05
Insert this jQuery in your JS file or register page to check the subscription checkbox by default
<script>
(function($){
$(document).ready(function(){
$( '#wysija-box-after-register' ).prop( 'checked', true );
});
})(window.jQuery);
</script>
@RafaelFunchal
RafaelFunchal / MailPoet: robots.txt
Last active August 29, 2015 14:05
Block MailPoet newsletters browser version of search engines
User-agent: *
Disallow: /*?wysijap=*
Disallow: /*?wysija-page=*
@RafaelFunchal
RafaelFunchal / MailPoet: Redirect After Submit
Last active February 16, 2018 21:54
Redirects to a custom link after submits the subscription form
<script>
(function($){
$(document).ready(function(){
$( 'form.widget_wysija' ).submit(function(e){
e.preventDefault();
setTimeout(function() {
var msg = $( '.wysija-msg' );
if( msg.text() !== '' ){
window.location.replace( 'http://your_thank_you_page_url' );
}
@RafaelFunchal
RafaelFunchal / MailPoet: Get subscription link
Last active September 19, 2018 21:18 — forked from benheu/wysija_get_subscription_link
Shows the link of the profile page for logged in users and let them edit their subscription
@RafaelFunchal
RafaelFunchal / List Selection Checkbox as Radio
Created July 18, 2014 21:37
This jQuery code will change the behavior of Checkboxes making them behave as Radios
jQuery(document).ready(function($) {
var unique = $('.wysija-checkbox');
$(unique).click(function() {
$(unique).prop('checked', false );
$(this).prop('checked', true);
});
});
@RafaelFunchal
RafaelFunchal / MailPoet: Shortcode to undo unsubscribe
Last active August 29, 2015 14:03 — forked from benheu/undo_unsubscribe_shortcode.php
Shortcode to insert a link to undo the action when someone unsubscribed
<?php
/**
* function to return an undo unsbscribe string for MailPoet newsletters
* you could place it in the functions.php of your theme
* @return string
*/
function mpoet_get_undo_unsubscribe(){
if(class_exists('WYSIJA') && !empty($_REQUEST['wysija-key'])){
$undo_paramsurl = array(