Back to Guides

7.2.3 – Functions

In the Genesis 2.1 genesis/lib/functions/ folder you will find the following files:

  • breadcrumb.php
  • compat.php
  • deprecated.php (functions that shouldn’t be used any longer since they have been replaced by new functions)
  • feed.php (an action and filter with their functions to redirect the feed)
  • formatting.php (functions to format text or returned values of other functions)
  • general.php ( for functions that don’t fit in well with others. Often these will build until a logical group can be formed and a new file is added)
  • image.php (functions for retrieving the thumbnails)
  • layout.php (functions to change the layout/layout options of the site
  • markup.php
  • menu.php (the genesis_nav() function)
  • options.php (functions for retrieving options and custom fields)
  • seo.php (functions related to theme SEO)
  • upgrade.php (handles the theme upgrade)
  • widgetize.php (handles creation of default sidebars, footer sidebars, and provides the genesis_register_sidebar() helper function)

What follows is a list of the functions, with a short accompanying note, which these files contain.

Breadcrumb

// Helper function for the Genesis Breadcrumb Class

function genesis_breadcrumb( $args = array() )

// Display Breadcrumbs above the Loop. Concedes priority to popular breadcrumb plugins.

function genesis_do_breadcrumbs()

Compat

These functions are intended to provide simple compatibilty for those that don’t have the mbstring extension enabled. WordPress already provides a proper working definition for mb_substr().

Deprecated

// Deprecated. Wraps the page title in a `title` element. Only applies, if not currently in admin, or for a feed.

function genesis_doctitle_wrap( $title )

// Deprecated. Push individual setting (or group of setting) into an options db entry stored as an array.

function _genesis_update_settings( $new, $setting = null )

// Deprecated. Used to output archive pagination in older/newer format. Should now use genesis_prev_next_posts_nav() instead.

function genesis_older_newer_posts_nav()

// Deprecated. Show Parent and Child information in the document head if specified by the user. This can be helpful for diagnosing problems with the theme, because you can easily determine if anything is out of date, needs to be updated.

function genesis_show_theme_info_in_head()

// Deprecated. Helper function for dealing with entities. It passes text through the g_ent filter so that entities can be converted on-the-fly.

function g_ent( $text = ” )

// Deprecated. Remove the Genesis theme files from the Theme Editor, except when Genesis is the current theme.

function genesis_theme_files_to_edit()

// Deprecated. Add links to the contents of a tweet. Takes the content of a tweet, detects @replies, #hashtags, and http:// URLs, and links them appropriately.

function genesis_tweet_linkify( $text )

// Deprecated. Provide a callback function for the custom header admin page.

function genesis_custom_header_admin_style()

// Deprecated. Filter the attributes array in the `wp_get_attachment_image()` function. For some reason, the `wp_get_attachment_image()` function uses the caption field value as the alt text, not the Alternate Text field value. Strange.

function genesis_filter_attachment_image_attributes( array $attr, $attachment )

// Deprecated. Create a category checklist.

function genesis_page_checklist( $name, array $selected = array() )

// Deprecated. Wrapper for `genesis_pre` action hook.

function genesis_pre()

// Deprecated. Wrapper for `genesis_pre_framework` action hook.

function genesis_pre_framework()

// Deprecated. Wrapper for `genesis_init` action hook.

function genesis_init()

// Deprecated. Wrapper for `genesis_doctype` action hook.

function genesis_doctype()

// Deprecated. Wrapper for `genesis_title` action hook.

function genesis_title()

// Deprecated. Wrapper for `genesis_meta` action hook.

function genesis_meta()

// Deprecated. Wrapper for `genesis_before` action hook.

function genesis_before()

// Deprecated. Wrapper for `genesis_after` action hook.

function genesis_after()

// Deprecated. Wrapper for `genesis_before_header` action hook.

function genesis_before_header()

// Deprecated. Wrapper for `genesis_header` action hook.

function genesis_header()

// Deprecated. Wrapper for `genesis_header_right` action hook.

function genesis_header_right()

// Deprecated. Wrapper for `genesis_after_header` action hook.

function genesis_after_header()

// Deprecated. Wrapper for `genesis_site_title` action hook.

function genesis_site_title()

// Deprecated. Wrapper for `genesis_site_description` action hook.

function genesis_site_description()

// Deprecated. Wrapper for `genesis_before_content_sidebar_wrap` action hook.

function genesis_before_content_sidebar_wrap()

// Deprecated. Wrapper for `genesis_after_content_sidebar_wrap` action hook.

function genesis_after_content_sidebar_wrap()

// Deprecated. Wrapper for `genesis_before_content` action hook.

function genesis_before_content()

// Deprecated. Wrapper for `genesis_after_content` action hook.

function genesis_after_content()

// Deprecated. Wrapper for `genesis_home` action hook.

function genesis_home()

// Deprecated. Wrapper for `genesis_before_loop` action hook.

function genesis_before_loop()

// Deprecated. Wrapper for `genesis_loop` action hook.

function genesis_loop()

// Deprecated. Wrapper for `genesis_after_loop` action hook.

function genesis_after_loop()

// Deprecated. Wrapper for `genesis_before_post` action hook.

function genesis_before_post()

// Deprecated. Wrapper for `genesis_after_post` action hook.

function genesis_after_post()

// Deprecated. Wrapper for `genesis_before_post_title` action hook.

function genesis_before_post_title()

// Deprecated. Wrapper for `genesis_post_title` action hook.

function genesis_post_title()

// Deprecated. Wrapper for `genesis_after_post_title` action hook.

function genesis_after_post_title()

// Deprecated. Wrapper for `genesis_before_post_content` action hook.

function genesis_before_post_content()

// Deprecated. Wrapper for `genesis_post_content` action hook.

function genesis_post_content()

// Deprecated. Wrapper for `genesis_after_post_content` action hook.

function genesis_after_post_content()

// Deprecated. Wrapper for `genesis_after_endwhile` action hook.

function genesis_after_endwhile()

// Deprecated. Wrapper for `genesis_loop_else` action hook.

function genesis_loop_else()

// Deprecated. Wrapper for `genesis_before_comments` action hook.

function genesis_before_comments()

// Deprecated. Wrapper for `genesis_comments` action hook.

function genesis_comments()

// Deprecated. Wrapper for `genesis_list_comments` action hook.

function genesis_list_comments()

// Deprecated. Wrapper for `genesis_after_comments` action hook.

function genesis_after_comments()

// Deprecated. Wrapper for `genesis_before_pings` action hook.

function genesis_before_pings()

// Deprecated. Wrapper for `genesis_pings` action hook.

function genesis_pings()

// Deprecated. Wrapper for `genesis_list_pings` action hook.

function genesis_list_pings()

// Deprecated. Wrapper for `genesis_after_pings` action hook.

function genesis_after_pings()

// Deprecated. Wrapper for `genesis_before_comment` action hook.

function genesis_before_comment()

// Deprecated. Wrapper for `genesis_after_comment` action hook.

function genesis_after_comment()

// Deprecated. Wrapper for `genesis_before_comment_form` action hook.

function genesis_before_comment_form()

// Deprecated. Wrapper for `genesis_comment_form` action hook.

function genesis_comment_form()

// Deprecated. Wrapper for `genesis_after_comment_form` action hook.

function genesis_after_comment_form()

// Deprecated. Wrapper for `genesis_before_sidebar_widget_area` action hook.

function genesis_before_sidebar_widget_area()

// Deprecated. Wrapper for `genesis_sidebar` action hook.

function genesis_sidebar()

// Deprecated. Wrapper for `genesis_after_sidebar_widget_area` action hook.

function genesis_after_sidebar_widget_area()

// Deprecated. Wrapper for `genesis_before_sidebar_alt_widget_area` action hook.

function genesis_before_sidebar_alt_widget_area()

// Deprecated. Wrapper for `genesis_sidebar_alt` action hook.

function genesis_sidebar_alt()

// Deprecated. Wrapper for `genesis_after_sidebar_alt_widget_area` action hook.

function genesis_after_sidebar_alt_widget_area()

// Deprecated. Wrapper for `genesis_before_footer` action hook.

function genesis_before_footer()

// Deprecated. Wrapper for `genesis_footer` action hook.

function genesis_footer()

// Deprecated. Wrapper for `genesis_after_footer` action hook.

function genesis_after_footer()

// Deprecated. Wrapper for `genesis_import_export_form` action hook.

function genesis_import_export_form()

// Deprecated. Hook this function to `wp_head()` and you’ll be able to use many of the new IE8 functionality. Not loaded by default.

function genesis_ie8_js()

// Deprecated. The Genesis-specific post date.

function genesis_post_date( $format = ”, $label = ” )

// Deprecated. The Genesis-specific post author link.

function genesis_post_author_posts_link( $label = ” )

// Deprecated. The Genesis-specific post comments link.

function genesis_post_comments_link( $zero = false, $one = false, $more = false )

// Deprecated. The Genesis-specific post categories link.

function genesis_post_categories_link( $sep = ‘, ‘, $label = ” )

// Deprecated. The Genesis-specific post tags link.

function genesis_post_tags_link( $sep = ‘, ‘, $label = ” )

// Deprecated. Allow a child theme to add new image sizes.

function genesis_add_image_size( $name, $width = 0, $height = 0, $crop = false )

// Deprecated. Filter intermediate sizes for WP 2.8 backward compatibility.

function genesis_add_intermediate_sizes( array $sizes )

// Deprecated. Was a wrapper for `genesis_comment` hook, but now calls `genesis_after_comment` action hook instead.

function genesis_comment()

Feed

// Filter the feed URI if the user has input a custom feed URI. Applied in the `get_feed_link()` WordPress function.

function genesis_feed_links_filter( $output, $feed )

// Redirect the browser to the custom feed URI. Exits PHP after redirect.

function genesis_feed_redirect()

Formatting

// Return a phrase shortened in length to a maximum number of characters. Result will be truncated at the last white space in the original string. In this function the word separator is a single space. Other white space characters (like newlines and tabs) are ignored. If the first `$max_characters` of the string does not contain a space character, an empty string will be returned.

function genesis_truncate_phrase( $text, $max_characters )

// Return content stripped down and limited content. Strips out tags and shortcodes, limits the output to `$max_char` characters, and appends an ellipsis and more link to the end.

function get_the_content_limit( $max_characters, $more_link_text = ‘(more…)’, $stripteaser = false )

// Echo the limited content.

function the_content_limit( $max_characters, $more_link_text = ‘(more…)’, $stripteaser = false )

// Add `rel=”nofollow”` attribute and value to links within string passed in.

function genesis_rel_nofollow( $text )

// Remove attributes from a HTML element. This function accepts a string of HTML, parses it for any elements in the `$elements` array, then parses each element for any attributes in the `$attributes` array, and strips the attribute and its value(s).

function genesis_strip_attr( $text, $elements, $attributes, $two_passes = true )

// Sanitize multiple HTML classes in one pass.

function genesis_sanitize_html_classes( $classes, $return_format = ‘input’ )

// Return an array of allowed tags for output formatting. Mainly used by `wp_kses()` for sanitizing output.

function genesis_formatting_allowedtags()

// Wrapper for `wp_kses()` that can be used as a filter function.

function genesis_formatting_kses( $string )

// Calculate the time difference – a replacement for `human_time_diff()` until it is improved.

function genesis_human_time_diff( $older_date, $newer_date = false )

// Mark up content with code tags. Escapes all HTML, so `<` gets changed to `<` and displays correctly. Used almost exclusively within labels and text in user interfaces added by Genesis.

function genesis_code( $content )

General

// Enable the author box for ALL users.

function genesis_enable_author_box( $args = array() )

// Redirect the user to an admin page, and add query args to the URL string for alerts, etc.

function genesis_admin_redirect( $page, array $query_args = array() )

// Redirect singular page to an alternate URL.

function genesis_custom_field_redirect()

// Return a specific value from the associative array passed as the second argument to `add_theme_support()`.

function genesis_get_theme_support_arg( $feature, $arg, $default = ” )

// Detect active plugin by constant, class or function existence.

function genesis_detect_plugin( array $plugins )

// Check that we’re targeting a specific Genesis admin page. The `$pagehook` argument is expected to be one of ‘genesis’, ‘seo-settings’ or ‘genesis-import-export’ although others can be accepted.

function genesis_is_menu_page( $pagehook = ” )

// Check whether we are currently viewing the site via the WordPress Customizer.

function genesis_is_customizer()

// Helper function to determine if the blog_page.php template should be used.

function genesis_is_blog_template()

// Get the `post_type` from the global `$post` if supplied value is empty.

function genesis_get_global_post_type_name( $post_type_name = ” )

// Get list of custom post type objects which need an archive settings page.

function genesis_get_cpt_archive_types()

// Get list of custom post type names which need an archive settings page.

function genesis_get_cpt_archive_types_names()

// Check if a post type supports an archive setting page.

function genesis_has_post_type_archive_support( $post_type_name = ” )

// Determine if HTML5 is activated by the child theme.

function genesis_html5()

// Build links to install plugins.

function genesis_plugin_install_link( $plugin_slug = ”, $text = ” )

// A list of Genesis contributors for the current development cycle.

function genesis_contributors()

Image

// Pull an attachment ID from a post, if one exists.

function genesis_get_image_id( $index = 0, $post_id = null )

// Return an image pulled from the media gallery.

function genesis_get_image( $args = array() )

// Echo an image pulled from the media gallery.

function genesis_image( $args = array() )

// Return registered image sizes. Return a two-dimensional array of just the additionally registered image sizes, with width, height and crop sub-keys.

function genesis_get_additional_image_sizes()

// Return all registered image sizes arrays, including the standard sizes. Return a two-dimensional array of standard and additionally registered image sizes, with width, height and crop sub-keys. Here, the standard sizes have their sub-keys populated by pulling from the options saved in the database.

function genesis_get_image_sizes()

function genesis_get_image_sizes_for_customizer()

Layout

// Register Genesis default layouts. Genesis comes with six layouts registered by default. These are: content-sidebar (default); sidebar-content; content-sidebar-sidebar; sidebar-sidebar-content; sidebar-content-sidebar;

full-width-content

function genesis_create_initial_layouts()

// Register new layouts in Genesis.

function genesis_register_layout( $id = ”, $args = array() )

// Set a default layout. Allow a user to identify a layout as being the default layout on a new install, as well as serve as the fallback layout.

function genesis_set_default_layout( $id = ” )

// Unregister a layout in Genesis. Modifies the global $_genesis_layouts variable.

function genesis_unregister_layout( $id = ” )

// Return all registered Genesis layouts.

function genesis_get_layouts( $type = ” )

// Return registered layouts in a format the WordPress Customizer accepts.

function genesis_get_layouts_for_customizer( $type = ” )

// Return the data from a single layout, specified by the $id passed to it.

function genesis_get_layout( $id )

// Return the layout that is set to default.

function genesis_get_default_layout()

// Return the site layout for different contexts. Checks both the custom field and the theme option to find the user-selected site layout, and returns it. Applies `genesis_site_layout` filter early to allow shortcutting of function.

function genesis_site_layout( $use_cache = true )

// Output the form elements necessary to select a layout.

function genesis_layout_selector( $args = array() )

// Potentially echo or return a structural wrap div. A check is made to see if the `$context` is in the `genesis-structural-wraps` theme support data. If so, then the ‘$output` may be echoed or returned.

function genesis_structural_wrap( $context = ”, $output = ‘open’, $echo = true )

// Return layout key ‘content-sidebar’. Used as shortcut second parameter for `add_filter()`.

function __genesis_return_content_sidebar()

// Return layout key ‘sidebar-content’. Used as shortcut second parameter for `add_filter()`.

function __genesis_return_sidebar_content()

// Return layout key ‘content-sidebar-sidebar’. Used as shortcut second parameter for `add_filter()`.

function __genesis_return_content_sidebar_sidebar()

// Return layout key ‘sidebar-sidebar-content’. Used as shortcut second parameter for `add_filter()`.

function __genesis_return_sidebar_sidebar_content()

// Return layout key ‘sidebar-content-sidebar’. Used as shortcut second parameter for `add_filter()`.

function __genesis_return_sidebar_content_sidebar()

// Return layout key ‘full-width-content’. Used as shortcut second parameter for `add_filter()`

function __genesis_return_full_width_content()

Markup

// Output markup conditionally. Supported keys for `$args` are: `html5` (`sprintf()` pattern markup); `xhtml` (XHTML markup); `context` (name of context); `echo` (default is true). If the child theme supports HTML5, then this function will output the `html5` value, with a call to `genesis_attr()` with the same context added in. Otherwise, it will output the `xhtml` value.

function genesis_markup( $args = array() )

// Merge array of attributes with defaults, and apply contextual filter on array. The contextual filter is of the form `genesis_attr_{context}`.

function genesis_parse_attr( $context, $attributes = array() )

// Build list of attributes into a string and apply contextual filter on string. The contextual filter is of the form ‘genesis_attr_{context}_output`.

function genesis_attr( $context, $attributes = array() )

// Filter function. Add attributes for body element.

function genesis_attributes_body( $attributes )

// Filter function. Add attributes for site header element.

function genesis_attributes_header( $attributes )

// Filter function. Add attributes for site title element.

function genesis_attributes_site_title( $attributes )

// Filter function. Add attributes for site description element.

function genesis_attributes_site_description( $attributes )

// Filter function. Add attributes for header widget area element.

function genesis_attributes_header_widget_area( $attributes )

// Filter function. Add typical attributes for navigation elements. Used for primary navigation, secondary navigation, and custom menu widgets in the header right widget area.

function genesis_attributes_nav( $attributes )

// Filter function. Add attributes for structural wrap element.

function genesis_attributes_structural_wrap( $attributes )

// Filter function. Add attributes for main content element.

function genesis_attributes_content( $attributes )

// Filter function. Add attributes for entry element.

function genesis_attributes_entry( $attributes )

// Filter function. Add attributes for entry image element.

function genesis_attributes_entry_image( $attributes )

// Filter function. Add attributes for entry image element shown in a widget.

function genesis_attributes_entry_image_widget( $attributes )

// Filter function. dd attributes for entry image element shown in a grid loop.

function genesis_attributes_entry_image_grid_loop( $attributes )

// Filter function. Add attributes for author element for an entry.

function genesis_attributes_entry_author( $attributes )

// Filter function. Add attributes for entry author link element.

function genesis_attributes_entry_author_link( $attributes )

// Filter function. Add attributes for entry author name element.

function genesis_attributes_entry_author_name( $attributes )

// Filter function. Add attributes for time element for an entry.

function genesis_attributes_entry_time( $attributes )

// Filter function. Add attributes for modified time element for an entry.

function genesis_attributes_entry_modified_time( $attributes )

// Filter function. Add attributes for entry title element.

function genesis_attributes_entry_title( $attributes )

// Filter function. Add attributes for entry content element.

function genesis_attributes_entry_content( $attributes )

// Filter function. Add attributes for entry meta elements.

function genesis_attributes_entry_meta( $attributes )

// Filter function. Add attributes for pagination.

function genesis_attributes_pagination( $attributes )

// Filter function. Add attributes for entry comments element.

function genesis_attributes_entry_comments( $attributes )

// Filter function. Add attributes for single comment element.

function genesis_attributes_comment( $attributes )

// Filter function. Add attributes for comment author element.

function genesis_attributes_comment_author( $attributes )

// Filter function. Add attributes for comment author link element.

function genesis_attributes_comment_author_link( $attributes )

// Filter function. Add attributes for comment time element.

function genesis_attributes_comment_time( $attributes )

// Filter function. Add attributes for comment time link element.

function genesis_attributes_comment_time_link( $attributes )

// Filter function. Add attributes for comment content container.

function genesis_attributes_comment_content( $attributes )

// Filter function. Add attributes for author box element.

function genesis_attributes_author_box( $attributes )

// Filter function. Add attributes for primary sidebar element.

function genesis_attributes_sidebar_primary( $attributes )

// Filter function. Add attributes for secondary sidebar element.

function genesis_attributes_sidebar_secondary( $attributes )

// Filter function. Add attributes for site footer element.

function genesis_attributes_site_footer( $attributes )

Menu

// Determine if a child theme supports a particular Genesis nav menu.

function genesis_nav_menu_supported( $menu )

// Determine if the Superfish script is enabled.

function genesis_superfish_enabled()

// Return the markup to display a menu consistent with the Genesis format. Applies the `genesis_$location_nav` filter e.g. `genesis_header_nav`. For primary and secondary menu locations, it also applies the `genesis_do_nav` and `genesis_do_subnav` filters for backwards compatibility.

function genesis_get_nav_menu( $args = array() )

// Echo the output from `genesis_get_nav_menu()`.

function genesis_nav_menu( $args )

// Echo or return a pages or categories menu. Now only used for backwards-compatibility (genesis_vestige).

function genesis_nav( $args = array() )

Options

// Return option from the options table and cache result. Applies `genesis_pre_get_option_$key` and `genesis_options` filters.

function genesis_get_option( $key, $setting = null, $use_cache = true )

// Echo options from the options database.

function genesis_option( $key, $setting = null, $use_cache = true )

// Return SEO options from the SEO options database.

function genesis_get_seo_option( $key, $use_cache = true )

// Echo an SEO option from the SEO options database.

function genesis_seo_option( $key, $use_cache = true )

// Return a CPT Archive setting value from the options table.

function genesis_get_cpt_option( $key, $post_type_name = ”, $use_cache = true )

// Echo a CPT Archive option from the options table.

function genesis_cpt_option( $key, $post_type_name, $use_cache = true )

// Echo data from a post or page custom field. Echo only the first value of custom field. Pass in a `printf()` pattern as the second parameter and have that wrap around the value, if the value is not falsy.

function genesis_custom_field( $field, $output_pattern = ‘%s’ )

// Return custom field post meta data.

function genesis_get_custom_field( $field )

// Save post meta / custom field data for a post or page. It verifies the nonce, then checks we’re not doing autosave, ajax or a future post request. It then checks the current user’s permissions, before finally either updating the post meta, or deleting the field if the value was not truthy.

function genesis_save_custom_fields( array $data, $nonce_action, $nonce_name, $post, $deprecated = null )

// Takes an array of new settings, merges them with the old settings, and pushes them into the database.

function genesis_update_settings( $new = ”, $setting = GENESIS_SETTINGS_FIELD )

Seo

// Disable the Genesis SEO features.

function genesis_disable_seo()

// Detect whether or not Genesis SEO has been disabled.

function genesis_seo_disabled()

// Check for the existence of popular SEO plugins and disable the Genesis SEO features if one or more of the plugins is active. Runs before the menu is built, so we can disable SEO Settings menu, if necessary.

function genesis_seo_compatibility_check()

// Display admin notice for Scribe SEO Copywriting tool.

function genesis_scribe_nag()

// Potentially disable Scribe admin notice. Detect a query flag, and disables the Scribe nag, then redirect the user back to the SEO settings page.

function genesis_disable_scribe_nag()

// Detect some SEO Plugin that add constants, classes or functions. Applies `genesis_detect_seo_plugins` filter to allow third party manpulation of SEO plugin list.

function genesis_detect_seo_plugins()

Upgrade

The functions found in this file keep Genesis up to date. Leave them be and all will go smoothly.

Widegetize

// Expedites the widget area registration process by taking common things, before / after_widget, before / after_title, and doing them automatically.

function genesis_register_widget_area( $args )

// An alias for `genesis_register_widget_area()`.

function genesis_register_sidebar( $args )

// Alters the widget area params array for HTML5 compatibility.

function _genesis_builtin_sidebar_params()

// Register the default Genesis widget areas.

function genesis_register_default_widget_areas()

// Register footer widget areas based on the number of widget areas the user wishes to create with `add_theme_support()`.

function genesis_register_footer_widget_areas()

// Register after-entry widget area if user specifies in the child theme.

function genesis_register_after_entry_widget_area()

// Conditionally display a sidebar, wrapped in a div by default.

function genesis_widget_area( $id, $args = array() )

Back to the Top