Skip to content

Instantly share code, notes, and snippets.

@gregoirenoyelle
Last active December 13, 2018 06:32
Show Gist options
  • Save gregoirenoyelle/011f9e569ef4d5bcd56a to your computer and use it in GitHub Desktop.
Save gregoirenoyelle/011f9e569ef4d5bcd56a to your computer and use it in GitHub Desktop.
ACF Pro Page d'options
<?php // BALISE PHP À ENLEVER
/**
* Ajouter page d'options ACF 5
*
* @package ACF
*/
if( function_exists('acf_add_options_page') ) {
// Premier menu d'options
acf_add_options_page(array(
'page_title' => 'Options',
'menu_title' => 'Options',
'menu_slug' => 'options-generales',
'capability' => 'edit_posts',
'redirect' => true
));
acf_add_options_sub_page(array(
'page_title' => 'Options d\'Entête',
'menu_title' => 'Entête',
'parent_slug' => 'options-generales',
));
acf_add_options_sub_page(array(
'page_title' => 'Options de Pied de Page',
'menu_title' => 'Pied de page',
'parent_slug' => 'options-generales',
));
// Deuxième menu d'options
acf_add_options_page(array(
'page_title' => 'Options de maquette',
'menu_title' => 'Maquette',
'menu_slug' => 'options-maquette',
'capability' => 'edit_posts',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'Couleur',
'menu_title' => 'Couleur',
'parent_slug' => 'options-maquette',
));
}
<?php // BALISE PHP À ENLEVER
/**
* Ajouter page d'options ACF 5
*
* @package ACF
*/
if( function_exists('acf_add_options_page') ) {
// Page principale
acf_add_options_page(array(
'page_title' => 'Options',
'menu_title' => 'Options',
'menu_slug' => 'options-generales',
'capability' => 'edit_posts',
'redirect' => true
));
// Première sous-page
acf_add_options_sub_page(array(
'page_title' => 'Options d\'Entête',
'menu_title' => 'Entête',
'parent_slug' => 'options-generales',
));
// Deuxième sous-page
acf_add_options_sub_page(array(
'page_title' => 'Options de Pied de Page',
'menu_title' => 'Pied de page',
'parent_slug' => 'options-generales',
));
}
<?php // BALISE PHP À ENLEVER
/**
* CSS depuis les pages d'options ACF
*
* @package ACF
*/
add_action('wp_head','gn_styles_options_acf', 999);
function gn_styles_options_acf() {
if (!function_exists('get_field')) {
return;
}
$font_size = get_field('gn_taille_titre', 'option');
$color = get_field('gn_couleur_titre', 'option');
$color_hover = get_field('gn_couleur_titre_survol', 'option');
$masquer_slogan = get_field('gn_masquer_slogan', 'option');
?>
<style type="text/css">
.site-title {
font-size: <?php echo esc_html($font_size) * 10; ?>px;
font-size: <?php echo esc_html($font_size); ?>rem;
}
.site-title a {
color: <?php echo $color ?>;
}
.site-title a:hover {
color: <?php echo $color_hover ?>;
}
<?php if ( $masquer_slogan ) { ?>
.site-description {
display: none;
}
<?php } ?>
</style>
<?php }
<footer id="colophon" class="site-footer" role="contentinfo">
<div class="site-info">
<?php if (function_exists('get_field')) : ?>
<?php if ( get_field('gn_texte_pied_page','option') ) { ?>
<a href="<?php esc_html(get_field('gn_lien_pied_page','option')) ?>"><?php esc_html(get_field('gn_texte_pied_page','option')) ?></a>
<?php } ?>
<?php endif; ?>
</div><!-- .site-info -->
</footer><!-- .site-footer -->
<?php
/**
* The template for displaying the footer
*
* Contains the closing of the "site-content" div and all content after.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
?>
</div><!-- .site-content -->
<footer id="colophon" class="site-footer" role="contentinfo">
<div class="site-info">
<?php
/**
* Fires before the Twenty Fifteen footer text for footer customization.
*
* @since Twenty Fifteen 1.0
*/
do_action( 'twentyfifteen_credits' );
?>
<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentyfifteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfifteen' ), 'WordPress' ); ?></a>
</div><!-- .site-info -->
</footer><!-- .site-footer -->
</div><!-- .site -->
<?php wp_footer(); ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment