This file contains 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 | |
/* | |
* Remover scripts e tags desnecessários do head frontend do WP | |
*/ | |
// Emojis | |
remove_action('wp_head', 'print_emoji_detection_script', 7); | |
remove_action('wp_print_styles', 'print_emoji_styles'); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); |
This file contains 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 | |
/* | |
* Filtro para colocar mais classes na função body class, no exmeplo abaixo está adicionando o "slug do post" | |
*/ | |
add_filter('body_class', 'body_classes_plus'); | |
function body_classes_plus($classes) { | |
global $post; | |
$classes[] = (!is_home()) ? $post->post_name : ''; // Slug do post |
This file contains 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 | |
/* | |
* Carregar JS e CSS | |
*/ | |
function load_frontend_scripts(){ | |
if(!is_admin()){ | |
//jQuery | |
wp_deregister_script( 'jquery' ); |
This file contains 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 | |
// Desativar acesso ao painel do WordPress para não-administradores | |
add_action('admin_init', 'only_admin_in_dashboard'); | |
function only_admin_in_dashboard() { | |
if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') { | |
wp_redirect(home_url()); exit; | |
} | |
} |
This file contains 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 | |
// Pegar id do arquivo/imagem pela url | |
function get_attachment_id_by_guid( $attachment_url = '' ) { | |
global $wpdb; | |
$attachment_id = false; | |
// If there is no url, return. | |
if ( '' == $attachment_url ) | |
return; |
This file contains 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 theme_name_setup(){ | |
$domain = 'theme-name'; | |
// wp-content/languages/theme-name/de_DE.mo | |
load_theme_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain ); | |
// wp-content/themes/child-theme-name/languages/de_DE.mo | |
load_theme_textdomain( $domain, get_stylesheet_directory() . '/languages' ); | |
// wp-content/themes/theme-name/languages/de_DE.mo |
This file contains 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 | |
/** | |
* Configura o metabox e os campos personalizados | |
*/ | |
function cmb2_referencias_metaboxes() { | |
// Recomnedado usar um prefixo no id do campo | |
$prefix = '_cmb2_'; | |
// Inicializa o metabox dos campos personalizados |
This file contains 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 cmb2_parceiros_field_metaboxes() { | |
// Start with an underscore to hide fields from custom fields list | |
$prefix = '_cmb2_'; | |
// Cria o Metabox | |
$cmb2_parceiro = new_cmb2_box( array( | |
'id' => $prefix . 'parceiro_configs_metabox', | |
'title' => 'Cadastrar parceiros', |
This file contains 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 get_header(); ?> | |
[...] | |
<ul class="lista-parceitos"> | |
<?php | |
$prefix = '_cmb2_'; | |
$grupo_campos_parceiro = get_post_meta($post->ID, $prefix.'grupo_campos_parceiro', true); | |
foreach ($grupo_campos_parceiro as $key => $value) { |
OlderNewer