Last active
November 3, 2019 09:44
-
-
Save PetrovStark/e51bf0f1b9fa7c3c29d3ddb9820e1577 to your computer and use it in GitHub Desktop.
CONTROLLERS PERSONALIZAÇÃO CUSTOMIZER WORDPRESS
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 | |
// AUTOMATIZAÇÃO DE CUSTOMIZER DO TEMA - Petrus Nogueira | |
function customizer ($customize) { | |
//ARRAY QUE EDITA AS CUSTOMIZAÇÕES DE FORMA MAIS SIMPLES | |
$ctmz_tree = array( | |
//Início do site | |
array( | |
"section" => "inicio_do_site", | |
"titulo" => "Início do site", | |
"descricao" => "Personalize o estilo do início de sua LP.", | |
"prioridade" => 30, | |
"controls" => array( | |
array( | |
"label" => "Titulo da seção", | |
"descricao" => false, | |
"default" => "Bem vindo a nossa Landing Page", | |
"tipo_de_controle" => "text", | |
"setting" => "section_title", | |
), | |
array( | |
"label" => "Titulo do formulário", | |
"descricao" => false, | |
"default" => "Cadastre-se, é de graça", | |
"tipo_de_controle" => "text", | |
"setting" => "form_title", | |
), | |
array( | |
"label" => "Cor de fundo", | |
"descricao" => false, | |
"default" => "none", | |
"tipo_de_controle" => "paleta_de_cores", | |
"setting" => "section_background", | |
), | |
//BACKGROUND IMAGEM, PROBLEMAS DE IMPLEMENTAÇÃO, URL CONFUSA | |
// array( | |
// "label" => "Imagem de fundo", | |
// "descricao" => "(Caso adicionada, ela irá sobrescrever a cor de fundo.)", | |
// "default" => "", | |
// "tipo_de_controle" => "media_content", | |
// "mime_type" => "image", | |
// "setting" => "background_image", | |
// ), | |
array( | |
"label" => "Cor do título (seção)", | |
"descricao" => false, | |
"default" => "none", | |
"tipo_de_controle" => "paleta_de_cores", | |
"setting" => "section_color_title", | |
), | |
array( | |
"label" => "Cor do título (formulário)", | |
"descricao" => false, | |
"default" => "none", | |
"tipo_de_controle" => "paleta_de_cores", | |
"setting" => "form_color_title", | |
), | |
) | |
), | |
); | |
// DINAMIZANDO A CRIAÇÃO DAS SEÇÕES DE CUSTOMIZAÇÃO | |
foreach ($ctmz_tree as $tree){ | |
$customize->add_section( | |
$tree["section"], | |
array( | |
"title" => $tree["titulo"], | |
"description" => $tree["descricao"], | |
"priority" => $tree["prioridade"], | |
) | |
); | |
foreach($tree["controls"] as $control ){ | |
$customize->add_setting( | |
$control["setting"], | |
array( | |
"default" => $control["default"], | |
"transport" => "refresh", | |
) | |
); | |
if ($control["tipo_de_controle"] == "paleta_de_cores"){ | |
$customize->add_control(new WP_Customize_Color_Control( | |
$customize, | |
$control["setting"], | |
array( | |
"label" => $control["label"], | |
"section" => $tree["section"], | |
) | |
)); | |
}else if ($control["tipo_de_controle"] == "media_content"){ | |
$customize->add_control(new WP_Customize_Media_Control( | |
$customize, | |
$control["setting"], | |
array( | |
"label" => $control["label"], | |
"description"=>$control["descricao"], | |
"section" => $tree["section"], | |
"mime_type" => $control["mime_type"] | |
) | |
)); | |
}else{ | |
$customize->add_control(new WP_Customize_Control( | |
$customize, | |
$control["setting"], | |
array( | |
"label" => $control["label"], | |
"section" => $tree["section"], | |
"description" => $control["descricao"], | |
"settings" => $control["setting"], | |
"type" => $control["tipo_de_controle"], | |
) | |
)); | |
} | |
} | |
} | |
} | |
//HOOK CUSTOMIZER | |
add_action("customize_register", "customizer"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment