Skip to content

Instantly share code, notes, and snippets.

View bordoni's full-sized avatar
:shipit:
Working on The Events Calendar

Gustavo Bordoni bordoni

:shipit:
Working on The Events Calendar
View GitHub Profile
@bordoni
bordoni / Twitch.py
Last active August 29, 2015 14:10 — forked from Xeroday/Twitch.py
import requests
import subprocess
import json
import sys
import threading
import time
from Queue import Queue
numberOfViewers = int(sys.argv[1])
builderThreads = int(sys.argv[2])
@bordoni
bordoni / mailpoet-insert_new_user.php
Last active March 18, 2018 23:27
Insert a new user to MailPoet and handle custom fields
<?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',
$.ajax({
'url': ajaxurl,
'data': {
'action': data.crop_action,
'crop': data.crop,
'attachment': data.$.return.val()
},
'dataType': 'json',
'type': 'POST',
'success': function (response, textStatus, jqXHR){
@bordoni
bordoni / format.php
Last active August 29, 2015 13:57
Format in PHP
<?php
/**
* Ref: http://stackoverflow.com/questions/7683133/does-php-have-a-feature-like-pythons-template-strings
*/
class Helper_StringFormat {
public static function sprintf($format, array $args = array()) {
$arg_nums = array_slice(array_flip(array_keys(array(0 => 0) + $args)), 1);
<?php
/**
* Print MailPoet's Widget without having a Sidebar
*
* Reference: http://codex.wordpress.org/Function_Reference/the_widget
*/
the_widget(
'WYSIJA_NL_Widget', // Name of the widget
array( // Variables that will configure the Widget
'title' => 'Subscribe to our Newsletter',
<?php
/**
* Remove MailPoet Action on the Unsubscribe page `the_content`
*/
add_action( 'init', '__mailpoet_unsubscribe_page' );
function __mailpoet_unsubscribe_page() {
if ( class_exists( 'WYSIJA_help_front' ) && ! is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'subscribe' ) {
$front_helper = WYSIJA::get('front','helper');
@bordoni
bordoni / wp_mail.headers.php
Last active July 8, 2024 15:19
How to Send an Email via WordPress | Article on Sending emails on WordPress -- http://bordoni.me/wordpress/send-wordpress-email/
<?php
$to = "[email protected]";
$subject = "Learning how to send an Email in WordPress";
$content = "WordPress knowledge";
$headers = [
'Reply-To' => "Gustavo Bordoni <[email protected]>"
];
$status = wp_mail( $to, $subject, $content, $headers );
{
"name" : "Wysija Newsletters Premium",
"slug" : "wysija-newsletters-premium",
"download_url" : "http://packager.mailpoet.com/packages/premium_dev_2.6.0.1_c0d80c07c5.zip",
"version" : "2.6.0.2",
"author" : "Wysija",
"sections" : {
"description" : "Plugin description here. Basic HTML allowed."
}
}
@bordoni
bordoni / functions.php
Last active December 29, 2015 20:59
Limita a edição de posts para colaboradores que não tenham posts publicados.
<?php
add_filter( 'user_has_cap', function($all, $caps, $args, $user){
if (!in_array('contributor', $user->roles))
return $all;
$posts = get_posts(array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
'author' => $user->ID,
@bordoni
bordoni / wcsp2013-bordoni-ex-00.php
Last active December 29, 2015 03:49
Exemplos do WordCamp SP 2013 Slides em: http://bit.ly/wcsp2013_bordoni
<?php
// Exemplo 1
// Filtra a edição de posts da categoria 6 permitida apenas para os usuários 5 e 9
add_filter( 'user_has_cap', function( $allcaps, $caps, $args, $user ){
if ( in_array($args[0], array( 'edit_post' ) ) )
return $allcaps;
// Para `edit_post` será passado um argumento com o ID do post que desejamos verificar
if ( !isset( $args[2] ) || $args[2] == 0 || !is_numeric($args[2]) )
return $allcaps;