Skip to content

Instantly share code, notes, and snippets.

View claudioweb's full-sized avatar

Claudio Campos Furbino Rabelo claudioweb

View GitHub Profile
@claudioweb
claudioweb / register_post_type
Last active March 17, 2016 14:29
Modificando Wordpress para criar post type e suas taxonomy...
/*===================================
= Posts Types =
===================================*/
/*========== Exemplo ==========*/
function exemplo() {
$args = array(
'labels' => array('name' => 'exemplo', 'add_new' => 'Adicionar'),
'public' => true,
@claudioweb
claudioweb / register_my_menu
Created July 28, 2015 17:52
Registrando Menus no wordpress
/*=========================================
= Cadastro de menus =
=========================================*/
add_action( 'after_setup_theme', 'register_my_menu' );
function register_my_menu() {
register_nav_menu( 'primary_navigation_sistema', __( 'Navegação Sistema', 'theme-slug' ) );
register_nav_menu( 'rodape_1', __( 'Rodapé (Coluna 1)', 'theme-slug' ) );
register_nav_menu( 'rodape_2', __( 'Rodapé (Coluna 2)', 'theme-slug' ) );
register_nav_menu( 'rodape_3', __( 'Rodapé (Coluna 3)', 'theme-slug' ) );
@claudioweb
claudioweb / admin_menu
Last active September 25, 2015 14:09
Ocultar e renomear menu do wp-admin do Wordpress
/*==================================
= Menu ordem =
==================================*/
add_filter( 'admin_menu', 'ocultar_menu_painel', 999 );
function ocultar_menu_painel() {
global $menu;
// print_r($menu); //Alterar o nome do menu
// $menu[5][0] = 'Fique ligado';
@claudioweb
claudioweb / wp-config.php
Last active April 22, 2019 10:12
Opções do wp-config.php do Wordpress
//Altere isso para true para ativar as opções multisite
define( 'WP_ALLOW_MULTISITE', true );
//troca a pasta w-content/uploads
define( 'UPLOADS', 'media' );
//definir o tema padrão
define( 'WP_DEFAULT_THEME', 'meu-tema' );
//desativar a edição de arquivos via painel
@claudioweb
claudioweb / plugin_template_redirect.php
Last active May 4, 2016 17:21
function para redirecionar templates e singles de um plugin para /templates
define( 'PLUGIN_PATH', plugin_dir_path(__FILE__));
add_action('template_redirect', 'load_template_pluginname');
function load_template_pluginname(){
global $post;
if(get_post_meta($post->ID, 'pluginname_page', true)){
if(locate_template('template-plugin-name.php', false) == ""){
@claudioweb
claudioweb / functions_admin.js
Created August 15, 2016 19:13
Abrir Mídia do wordpress
jQuery(document).ready(function($){
var custom_uploader;
$('#upload_image_button').click(function(e) {
e.preventDefault();
if (custom_uploader) {
custom_uploader.open();
return;
}
custom_uploader = wp.media.frames.file_frame = wp.media({
title: 'Escolha a imagem para o banner',
@claudioweb
claudioweb / include_var.php
Created October 31, 2016 19:02
Gravar include na variavel
ob_start();
include 'secondfile.php';
$myvar = ob_get_clean();
@claudioweb
claudioweb / yoast-seo-sitemap.php
Created November 24, 2016 18:38 — forked from mohandere/yoast-seo-sitemap.php
Wordpress yoast seo plugin, generate custom sitemap for custom URLS
<?php
/**
* Create a new custom yoast seo sitemap
*/
add_filter( 'wpseo_sitemap_index', 'ex_add_sitemap_custom_items' );
add_action( 'init', 'init_wpseo_do_sitemap_actions' );
// Add custom index
@claudioweb
claudioweb / post_type_produtos.php
Last active July 4, 2017 19:07
O grupo de posts nada mais é que a classificação de tipo de post, exemplo para produtos
<?php
function produtos() {
$args = array(
'labels' => array(
'name' => 'Produtos',
'add_new' => 'Adicionar Produto'
),
'public' => true,
'publicly_queryable' => true,
@claudioweb
claudioweb / meu-plugin.php
Created July 2, 2017 13:53
Arquivo base para a criação de um plugin
<?php
/***************************************************************************
Plugin Name: Meu Plugin
Plugin URI: https://www.meuplugin.com/
Description: Plugin base para iniciar o desenvolvimento
Version: 1.0
Author: Claudio Web (claudioweb)
Author URI: http://www.claudioweb.com.br/
Text Domain: meu-plugin
**************************************************************************/