Add new functios pages & styles
This commit is contained in:
@@ -21,18 +21,18 @@ class StarterSite extends Site {
|
||||
add_action( 'after_setup_theme', [ $this, 'theme_supports' ] );
|
||||
add_action( 'init', [ $this, 'register_post_types' ] );
|
||||
add_action( 'init', [ $this, 'register_taxonomies' ] );
|
||||
|
||||
|
||||
add_action('wp_enqueue_scripts', [$this,'load_assets']);
|
||||
|
||||
add_filter( 'timber/context', [ $this, 'add_to_context' ] );
|
||||
add_filter( 'timber/twig/filters', [ $this, 'add_filters_to_twig' ] );
|
||||
add_filter( 'timber/twig/functions', [ $this, 'add_functions_to_twig' ] );
|
||||
add_filter( 'timber/twig/environment/options', [ $this, 'update_twig_environment_options' ] );
|
||||
|
||||
|
||||
add_filter('upload_mimes', [$this, 'add_svg_support']); //add svg files
|
||||
add_filter('timber/context', [$this, 'add_global_context']); // variables globales
|
||||
add_filter('timber/twig', [$this, 'add_videos_embed_to_twig']); //videos embed
|
||||
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -518,10 +518,40 @@ class StarterSite extends Site {
|
||||
return $subpaginas;
|
||||
}
|
||||
|
||||
private function formContact() {
|
||||
$form_test = do_shortcode('[contact-form-7 id="5ed613c" title="Formulario de contacto 1"]');
|
||||
public function getContactoFields() {
|
||||
$post = Timber::get_post();
|
||||
$form_shortcode = get_field('etiqueta_formulario', $post->ID); // o el campo ACF donde esté el shortcode
|
||||
|
||||
return $form_test;
|
||||
$contactsFields = [
|
||||
'nombre' => get_field('nombre_contacto', $post->ID),
|
||||
'direccion' => get_field('direccion', $post->ID),
|
||||
'url_mapa' => get_field('url_mapa', $post->ID),
|
||||
'forma_contacto' => get_field('forma_contacto', $post->ID),
|
||||
'url_web' => get_field('url_web', $post->ID),
|
||||
'url_facebook' => get_field('url_facebook', $post->ID),
|
||||
'url_twitter' => get_field('url_twitter', $post->ID),
|
||||
'form' => !empty($form_shortcode) ? do_shortcode($form_shortcode) : '',
|
||||
];
|
||||
|
||||
return $contactsFields;
|
||||
|
||||
}
|
||||
|
||||
public function getAfiliateFields() {
|
||||
$post = Timber::get_post();
|
||||
|
||||
|
||||
$afiliateFields = [
|
||||
'imagen_afiliate' => get_field('imagen_afiliate', $post->ID),
|
||||
'enlace_boton_afiliate' => get_field('enlace_boton_afiliate', $post->ID),
|
||||
'texto_boton' => get_field('texto_boton', $post->ID),
|
||||
];
|
||||
|
||||
if (empty($afiliateFields['imagen_afiliate']) && empty($afiliateFields['enlace_boton_afiliate'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $afiliateFields;
|
||||
}
|
||||
|
||||
//Global variables
|
||||
@@ -541,7 +571,8 @@ class StarterSite extends Site {
|
||||
$context['enlaces'] = $this->getEnlaces();
|
||||
$context['subpaginas_servicios_publicos'] = $this->getPaginasServiciosPublicos();
|
||||
$context['subpaginas_servicios_privados'] = $this->getPaginasServiciosPrivados();
|
||||
$context['form_test'] = $this->formContact();;
|
||||
$context['contacto_info'] = $this->getContactoFields();
|
||||
$context['afiliate_fields'] = $this->getAfiliateFields();
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user