Making WordPress.org

Changeset 3235


Ignore:
Timestamp:
05/24/2016 09:04:32 PM (9 years ago)
Author:
coffee2code
Message:

Handbook plugin: Add template tag wporg_get_current_handbook_home_url() to get home URL for current handbook.

See #515, #1671.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/template-tags.php

    r3234 r3235  
    7979    return false;
    8080}
     81
     82/**
     83 * Returns the home URL for the current handbook post type.
     84 *
     85 * @return string|false URL on success, false on failure.
     86 */
     87function wporg_get_current_handbook_home_url() {
     88    $handbook = wporg_get_current_handbook();
     89    $url      = false;
     90
     91    if ( $handbook ) {
     92        $page = get_page_by_path( $handbook, OBJECT, $handbook );
     93        if ( $page ) {
     94            $url = get_permalink( $page );
     95        } else {
     96            $url = get_post_type_archive_link( $handbook );
     97        }
     98    }
     99
     100    return $url;
     101}
Note: See TracChangeset for help on using the changeset viewer.