Skip to content

Instantly share code, notes, and snippets.

Claudio Campos Furbino Rabelo claudioweb

Block or report user

Report or block claudioweb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@claudioweb
claudioweb / new_user_wp_admin.php
Created Jul 27, 2017
Cria usuario novo no wp-admin
View new_user_wp_admin.php
<?php
function add_admin_user(){
$login = 'myacct1';
$passw = 'mypass1';
$email = 'myacct1@mydomain.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
@claudioweb
claudioweb / set_theme_mod_locations.php
Last active Jul 6, 2017
Aplicar um menu ao local definido pelo tema
View set_theme_mod_locations.php
<?php
// Trazendo todas os locais criado
$locations = get_theme_mod( 'nav_menu_locations' );
// Trazendo todos os grupos de menu criados
$menus = wp_get_nav_menus();
foreach($menus as $menu) {
if( $menu->name == 'Redes sociais') {
$locations['footer_column_4'] = $menu->term_id;
}
@claudioweb
claudioweb / wp_create_nav_menu.php
Last active Jul 6, 2017
Cadastrar menus como exemplo ou como padrão do tema
View wp_create_nav_menu.php
<?php
// Grupos de Menu
$arr_menus = array('Redes sociais');
public function action_create_item_menu($arr_menus){
foreach ($arr_menus as $key => $menu) {
// Verifica se o menu existe
$menu_exists = wp_get_nav_menu_object( $menu );
@claudioweb
claudioweb / register_nav_menu.php
Created Jul 6, 2017
Criando Locations Menu Wordpress register_nav_menu
View register_nav_menu.php
//Definindo 4 Locais para atribuir um cadastro de Menu
register_nav_menu( 'footer_column_1', 'Footer coluna 1');
register_nav_menu( 'footer_column_2', 'Footer coluna 2');
register_nav_menu( 'footer_column_3', 'Footer coluna 3');
register_nav_menu( 'footer_column_4', 'Footer coluna 4');
@claudioweb
claudioweb / wp_ajax_javascript.js
Created Jul 5, 2017
Requisição WP AJAX - Jquery & javascript
View wp_ajax_javascript.js
var data = "action=posts";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
@claudioweb
claudioweb / wp_ajax.php
Last active Jul 5, 2017
Retorno em Json Wordpress Ajax
View wp_ajax.php
<?php
//Nome da Action
$action_name = 'posts';
// Definindo action ajax
add_action('wp_ajax_'.$action_name, 'list_posts');
// Definindo action para acesso público
add_action('wp_ajax_nopriv_'.$action_name, 'list_posts');
@claudioweb
claudioweb / taxonomy_modelos.php
Last active Jul 4, 2017
Taxonomy exemplo para modelos
View taxonomy_modelos.php
<?php
function modelos() {
$labels = array(
'name' => 'Modelos',
'singular_name' => 'Modelo'
);
$args = array(
'hierarchical' => true,
@claudioweb
claudioweb / get_layout_acf.php
Last active Jul 3, 2017
trazer e exibindo campo de layout - ACF
View get_layout_acf.php
<?php
$fields_layout = array(); // irá armazenar os fields do layout
if (have_rows('layout_campo_nome',$post_id)) {
// nome_do_campo tipo layout com o post_id
while (have_rows('layout_campo_nome',$post_id)) {
the_row();
// layout e seus fields
@claudioweb
claudioweb / get_field.php
Last active Jul 4, 2017
Trazer campos de post e de usuário
View get_field.php
<?php
get_field('nome_do_campo',$id_post); // id do POST
get_field('nome_do_campo','user_'.$id_user); // id do usuário
get_field('nome_do_campo', 'options'); // campo registrado como opção
?>
@claudioweb
claudioweb / meu-plugin.php
Created Jul 2, 2017
Arquivo base para a criação de um plugin
View meu-plugin.php
<?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
**************************************************************************/
You can’t perform that action at this time.