Last active
July 13, 2017 13:03
-
-
Save gregoirenoyelle/51b1391456216d552590 to your computer and use it in GitHub Desktop.
Genesis Functions
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 | |
/* | |
Ajouter des classes au Body et au post | |
---------------------------------------------------------------------------------------------------- */ | |
add_filter( 'body_class', 'gs_add_body_class' ); | |
/** | |
* Add custom body class to the head. | |
* | |
* @param array $classes Array of existing body classes. | |
* @return array $classes Modified Array of body classes. | |
*/ | |
function gs_add_body_class( $classes ) { | |
$classes[] = 'custom-class'; | |
return $classes; | |
} | |
add_filter( 'post_class', 'gs_post_class' ); | |
/** | |
* Add custom post classes. | |
* | |
* @param array $classes Array of existing post classes. | |
* @return array $classes Modified Array of body classes. | |
*/ | |
function gs_post_class( $classes ) { | |
$classes[] = 'custom-class'; | |
return $classes; | |
} |
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 | |
/* | |
Changer la largeur du contenu pour la page 467 et pour les page des fichiers média | |
---------------------------------------------------------------------------------------------------- */ | |
add_filter('template_redirect', 'gn_custom_content_width_embed_size'); | |
function gn_custom_content_width_embed_size($embed_size){ | |
if ( is_page(467) || is_attachment() ) { | |
global $content_width; | |
$content_width = 960; | |
} | |
} |
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 | |
/* | |
Changer le Doctype | |
---------------------------------------------------------------------------------------------------- */ | |
remove_action( 'genesis_doctype', 'genesis_do_doctype' ); | |
add_action( 'genesis_doctype', 'gs_do_doctype' ); | |
/** | |
* Conditional html element classes | |
*/ | |
function child_do_doctype() { | |
?> | |
<!DOCTYPE html> | |
<!--[if lt IE 7 ]> <html class="ie6" xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes( 'xhtml' ); ?>> <![endif]--> | |
<!--[if IE 7 ]> <html class="ie7" xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes( 'xhtml' ); ?>> <![endif]--> | |
<!--[if IE 8 ]> <html class="ie8" xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes( 'xhtml' ); ?>> <![endif]--> | |
<!--[if IE 9 ]> <html class="ie9" xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes( 'xhtml' ); ?>> <![endif]--> | |
<!--[if (gt IE 9)|!(IE)]><!--> <html class="" xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes( 'xhtml' ); ?>> <!--<![endif]--> | |
<head profile="http://gmpg.org/xfn/11"> | |
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" /> | |
<?php | |
} |
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 | |
/* | |
Intégrer les Google fonts | |
---------------------------------------------------------------------------------------------------- */ | |
add_action( 'wp_enqueue_scripts', 'gs_load_google_fonts' ); | |
/** | |
* Enqueue Google fonts | |
*/ | |
function gs_load_google_fonts() { | |
wp_enqueue_style( | |
'child-google-fonts', | |
'http://fonts.googleapis.com/css?family=Merriweather|Open+Sans', | |
array(), | |
CHILD_THEME_VERSION | |
); | |
} |
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 | |
/* | |
Options de mise en page | |
---------------------------------------------------------------------------------------------------- */ | |
/**** Force la mise en page. L'utilisateur ne peux pas changer ****/ | |
// Maquette Pleine largeur | |
add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' ); | |
// Maquette Contenu | Barre latérale | |
add_filter( 'genesis_site_layout', '__genesis_return_content_sidebar' ); | |
// Maquette Barre latérale | Contenu | |
add_filter( 'genesis_site_layout', '__genesis_return_sidebar_content' ); | |
// Maquette Contenu | Barre latérale | Barre latérale | |
add_filter( 'genesis_site_layout', '__genesis_return_content_sidebar_sidebar' ); | |
// Maquette Barre latérale | Barre latérale | Contenu | |
add_filter( 'genesis_site_layout', '__genesis_return_sidebar_sidebar_content' ); | |
// Maquette Barre latérale| Contenu | Barre latérale | |
add_filter( 'genesis_site_layout', '__genesis_return_sidebar_content_sidebar' ); | |
/**** Propose la mise en page. L'utilisateur peux modifier ****/ | |
// Maquette Pleine largeur | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); | |
// Maquette Contenu | Barre latérale | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' ); | |
// FMaquette Barre latérale | Contenu | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' ); | |
// Maquette Contenu | Barre latérale | Barre latérale | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar_sidebar' ); | |
// Maquette Barre latérale | Barre latérale | Contenu | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_sidebar_content' ); | |
// Maquette Barre latérale| Contenu | Barre latérale | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content_sidebar' ); |
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 | |
/* | |
Supprimer les metaboxes | |
---------------------------------------------------------------------------------------------------- */ | |
/** Enlever les options SEO dans chaque contenu */ | |
remove_action( 'admin_menu', 'genesis_add_inpost_seo_box' ); | |
/** Enlever les options de maquette dans chaque contenu */ | |
remove_theme_support( 'genesis-inpost-layouts' ); |
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 | |
/* | |
Changer la position des éléments: Fil d'ariane, Pied de page, Barre latérale 1 et 2 | |
---------------------------------------------------------------------------------------------------- */ | |
/** Changer la position du fil d'Ariane */ | |
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); | |
add_action( 'genesis_after_header', 'genesis_do_breadcrumbs' ); | |
/** Changer la position du footer */ | |
/* je retire et je remets à un endroit différent */ | |
remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 ); | |
remove_action( 'genesis_footer', 'genesis_do_footer' ); | |
remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 ); | |
add_action( 'genesis_after', 'genesis_footer_markup_open', 11 ); | |
add_action( 'genesis_after', 'genesis_do_footer', 12 ); | |
add_action( 'genesis_after', 'genesis_footer_markup_close', 13 ); | |
/** Changer la position de la navigation primaire */ | |
remove_action( 'genesis_after_header', 'genesis_do_nav' ); | |
add_action( 'genesis_before_header', 'genesis_do_nav' ); | |
/** Changer la position de la navigation secondaire */ | |
remove_action( 'genesis_after_header', 'genesis_do_subnav' ); | |
add_action( 'genesis_before_header', 'genesis_do_subnav' ); |
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 | |
/* | |
Info et Meta des articles | |
---------------------------------------------------------------------------------------------------- */ | |
add_filter( 'genesis_post_info', 'gs_post_info_filter' ); | |
/** | |
* Customize the post info function | |
* | |
* @link http://my.studiopress.com/docs/shortcode-reference/ | |
* @param string $post_info Default post info. | |
* (default: '[post_date] ' . __( 'by', 'genesis' ) . ' [post_author_posts_link] [post_comments] [post_edit]') | |
* @return string Modified post info. | |
*/ | |
function gs_post_info_filter( $post_info ) { | |
return '[post_date] by [post_author_posts_link] [post_comments] [post_edit]'; | |
} | |
/** Supprimer les post info */ | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
add_filter( 'genesis_post_meta', 'gs_post_meta_filter' ); | |
/** | |
* Customize the post meta function | |
* | |
* @link http://my.studiopress.com/docs/shortcode-reference/ | |
* @param string $post_meta Default post meta. | |
* (default: '[post_categories] [post_tags]') | |
* @return string Modified post meta. | |
*/ | |
function gs_post_meta_filter( $post_meta ) { | |
return '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]'; | |
} | |
/** Suprimer les post meta */ | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); |
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 | |
/* | |
Editer les Extrait/Contenu avec en lire plus | |
---------------------------------------------------------------------------------------------------- */ | |
// Changer le lien pour en lire plus pour les extraits | |
/** | |
* Edit excerpt read more link | |
* | |
* @param string $more Read More Text, , default: ' ' . '[...]' | |
* @return string Modified Read More Text. | |
*/ | |
function gs_remove_excerpt_more( $more ) { | |
return '...'; | |
} | |
// Changer le lien pour en lire plus | |
/** | |
* Edit read more link. | |
* | |
* @param string $link HTML Read More Link, default: sprintf( '… <a href="%s" class="more-link">%s</a>', get_permalink(), $more_link_text = '(more...)' ). | |
* @return string Modified HTML Read More Link. | |
*/ | |
function gs_read_more_link( $link ) { | |
return '<a class="more-link" href="' . get_permalink() . '" rel="nofollow">Read More</a>'; | |
} |
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 | |
/* | |
Retirer le tailles d'image par défaut | |
---------------------------------------------------------------------------------------------------- */ | |
add_filter( 'intermediate_image_sizes_advanced', 'gs_remove_image_sizes' ); | |
/** | |
* Remove WordPress Image Sizes. | |
* | |
* @param array $sizes Array of Intermediate Image Sizes. | |
* @return array $sizes Modified Array of Intermediate Image Sizes. | |
*/ | |
function gs_remove_image_sizes( $sizes ) { | |
unset( $sizes['thumbnail'] ); | |
unset( $sizes['medium'] ); | |
unset( $sizes['large'] ); | |
return $sizes; | |
} |
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 | |
/* | |
Supprimer les widgets WordPress/Genesis | |
---------------------------------------------------------------------------------------------------- */ | |
add_action( 'widgets_init', 'gn_remove_selected_widget', 20 ); | |
/** | |
* Remove Genesis/WordPress widgets | |
*/ | |
function gn_remove_selected_widget() { | |
// Retirer widget Page à la Une | |
unregister_widget( 'Genesis_Featured_Page' ); | |
// Retirer widget Article à la Une | |
unregister_widget( 'Genesis_Featured_Post' ); | |
// Retirer widget Page Auteur | |
unregister_widget( 'Genesis_User_Profile_Widget' ); | |
// Retirer les widget WordPress | |
//unregister_widget( 'WP_Widget_Pages' ); | |
//unregister_widget( 'WP_Widget_Calendar' ); | |
//unregister_widget( 'WP_Widget_Archives' ); | |
//unregister_widget( 'WP_Widget_Links' ); | |
//unregister_widget( 'WP_Widget_Meta' ); | |
//unregister_widget( 'WP_Widget_Search' ); | |
//unregister_widget( 'WP_Widget_Text' ); | |
//unregister_widget( 'WP_Widget_Categories' ); | |
//unregister_widget( 'WP_Widget_Recent_Posts' ); | |
//unregister_widget( 'WP_Widget_Recent_Comments' ); | |
//unregister_widget( 'WP_Widget_RSS' ); | |
//unregister_widget( 'WP_Widget_Tag_Cloud' ); | |
//unregister_widget( 'WP_Nav_Menu_Widget' ); | |
} |
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 | |
/* | |
Champ et bouton de recherche | |
---------------------------------------------------------------------------------------------------- */ | |
// Changer le texte dans le champ de recherche | |
add_filter( 'genesis_search_text', 'gs_search_text' ); | |
/** | |
* Customize search form input box text | |
* | |
* @param string $text Default search form input box text. | |
* (default: esc_attr__( 'Search this website', 'genesis' ) . '…' ) | |
* @return string Modified search form input box text. | |
*/ | |
function gs_search_text($text) { | |
return esc_attr( 'Search my blog...' ); | |
} | |
// Changer le texte du bouton | |
add_filter( 'genesis_search_button_text', 'gs_search_button_text' ); | |
/** | |
* Customize search form input button text | |
* | |
* @param string $text Default search form input button text. | |
* (default: Search ) | |
* @return string Modified search form input button text. | |
*/ | |
function gs_search_button_text($text) { | |
return esc_attr( 'Go' ); | |
} |
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
Post Shortcodes | |
[post_date] | |
[post_time] | |
[post_author] | |
[post_author_link] | |
[post_author_posts_link] | |
[post_comments] | |
[post_tags] | |
[post_categories] | |
[post_edit] | |
[post_terms] | |
Footer Shortcodes | |
[footer_copyright] | |
[footer_childtheme_link] | |
[footer_genesis_link] | |
[footer_studiopress_link] | |
[footer_wordpress_link] | |
[footer_loginout] |
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 | |
/* | |
Titre du site, description, entête de droite | |
---------------------------------------------------------------------------------------------------- */ | |
/** Supprimer le titre du site */ | |
remove_action( 'genesis_site_title', 'genesis_seo_site_title' ); | |
/** Supprimer la description du site */ | |
remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); | |
/** Supprimer l'entête de droite */ | |
unregister_sidebar( 'header-right' ); | |
/* | |
Changer le lien du titre ou du logo (version HTML5) | |
---------------------------------------------------------------------------------------------------- */ | |
function gn_logo_url( $title, $inside, $wrap ) { | |
$home = get_bloginfo('url' ) . '/votre-page/'; | |
$name = get_bloginfo( 'name' ); | |
$inside = sprintf( '<a href="%s" title="%s">%s</a>', esc_url( $home ), esc_attr( $name ), $name ); | |
$title = sprintf( '<%s class="site-title" itemprop="headline">%s</%s>', $wrap, $inside, $wrap ); | |
return $title; | |
} | |
add_filter( 'genesis_seo_title', 'gn_logo_url', 10, 3 ); |
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 | |
/* | |
Ajouter des supports pour les custom post type | |
---------------------------------------------------------------------------------------------------- */ | |
// 'genesis-seo', 'genesis-cpt-archives-settings', 'genesis-layouts' | |
$genesis_supports = array('genesis-seo', 'genesis-cpt-archives-settings', 'genesis-layouts'); | |
add_post_type_support( $post_type, $genesis_supports); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment