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
<?php
add_filter('archive_template', function($located) {
$post_type = 'seu-post-type';
$template = plugin_dir_path(__FILE__) . "templates/archive-{$post_type}.php";
if (is_post_type_archive($post_type) && (empty($located) || preg_match("/archive.php$/", $located)) && file_exists($template)){
load_template( $template, true );
return $template;
}
return $located;
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
<?php
function _filtering_the_title ($title, $id) {
return wp_kses($title, wp_kses_allowed_html());
}
add_filter('the_title', '_filtering_the_title', 10, 2);
@bordoni
bordoni / meu-portifolio.php
Last active December 22, 2015 01:29
WP Aula Plugins - Parte 1
<?php
/*
Plugin Name: Meu Portifólio
Version: 0.1
Plugin URI: https://vimeo.com/bordoni
Description: Um plugin para gerenciar os meus trabalhos como freelancer
Author: Gustavo Bordoni
Author URI: http://bordoni.me
License: GPL v3
@bordoni
bordoni / class.folio.php
Last active December 22, 2015 08:39
WP Aula Plugins - Parte 2
<?php
if (!class_exists("MeuPortifolio")){
class MeuPortifolio {
/**
* Uma variável estática contendo uma instância dinâmica da classe
* @var [object||null]
*/
public static $instance = null;
public function __construct() {
@bordoni
bordoni / utils.youtube.php
Created October 7, 2013 14:08
Functions to use Youtube
<?php
function youtube_image_url($id, $which=false){
$server = rand(1,5);
if ($server===5) {
$url = "http://img.youtube.com/vi/{$id}/";
} else {
$url = "http://i{$server}.ytimg.com/vi/{$id}/";
}
switch ($which) {
case 0:
@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;
@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,
{
"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 / 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 );