This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function _filtering_the_title ($title, $id) { | |
| return wp_kses($title, wp_kses_allowed_html()); | |
| } | |
| add_filter('the_title', '_filtering_the_title', 10, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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." | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 ); |