';
$oenology_404_intro .= __( 'Oh no, not again.', 'oenology' );
$oenology_404_intro .= '
';
$oenology_404_intro .= '
';
$oenology_404_intro .= __( 'Well, this is weird.', 'oenology' ) . ' ' ;
$oenology_404_intro .= __( 'The post, page, or file you requested could not be found. ', 'oenology' ) . ' ';
$oenology_404_intro .= __( 'The best laid plans of mice, and all that. ', 'oenology' ) . ' ';
$oenology_404_intro .= __( 'Those who study the complex interplay of cause and effect in the history of the Universe say that this sort of thing is going on all the time.', 'oenology' );
$oenology_404_intro .= '
';
$oenology_404_intro .= '
';
$oenology_404_intro .= __( 'I apologize for the inconvenience.', 'oenology' ) . ' ';
$oenology_404_intro .= __( 'Let me try to make it up to you!', 'oenology' );
$oenology_404_intro .= '
';
}
// Define "no results" output
$oenology_404_noresults .= '
';
$oenology_404_noresults .= __( 'I apologize.', 'oenology' ) . ' ';
$oenology_404_noresults .= __( 'For the life of me, I am unable to figure out what you were trying to find.', 'oenology' ) . ' ';
$oenology_404_noresults .= __( 'Perhaps try searching, using the search form in the upper right-hand corner?', 'oenology' );
$oenology_404_noresults .= '
';
// Concatenate "results" output
$oenology_404_results = apply_filters( 'oenology_404_intro', $oenology_404_intro ) . apply_filters( 'oenology_404_posts', $oenology_404_posts ) . apply_filters( 'oenology_404_pages', $oenology_404_pages ) . apply_filters( 'oenology_404_category', $oenology_404_category ) . apply_filters( 'oenology_404_tag', $oenology_404_tag );
$oenology404noresults = false;
if ( $oenology404nopostsorpages && $oenology404nocategories && $oenology404notags ) {
$oenology404noresults = true;
}
$oenology_404 = ( $oenology404noresults ? apply_filters( 'oenology_404_noresults', $oenology_404_noresults ) : apply_filters( 'oenology_404_results', $oenology_404_results ) );
return apply_filters( 'oenology_404', $oenology_404 );
}
/**
* Determine Theme Color Scheme
*
* @uses oenology_get_options() Defined in functions/options.php
* @uses oenology_get_option_parameters() Defined in functions/options.php
*/
function oenology_get_color_scheme() {
global $oenology_options;
$oenology_options = oenology_get_options();
$default_options = oenology_get_option_parameters();
$oenology_varietals = $default_options['varietal']['valid_options'];
$oenology_current_varietal = array();
foreach ( $oenology_varietals as $varietal ) {
if ( $varietal['name'] == $oenology_options['varietal'] ) {
$oenology_current_varietal = $varietal;
}
}
$colorscheme = $oenology_current_varietal['scheme'];
return $colorscheme;
}
/**
* Get current page context
*
* Returns a string containing the context of the
* current page. This string is useful for several
* purposes, including applying an ID to the HTML
* body tag, and adding a contextual $name to calls
* to get_header(), get_footer(), get_sidebar(),
* and get_template_part_file(), in order to
* facilitate Child Themes overriding default Theme
* template part files.
*
* @param none
* @return string current page context
*/
function oenology_get_context() {
$context = apply_filters( 'oenology_default_context', 'index' );
if ( is_front_page() ) {
// Front Page
$context = 'front-page';
} else if ( is_date() ) {
// Date Archive Index
$context = 'date';
} else if ( is_author() ) {
// Author Archive Index
$context = 'author';
} else if ( is_category() ) {
// Category Archive Index
$context = 'category';
} else if ( is_tag() ) {
// Tag Archive Index
$context = 'tag';
} else if ( is_tax() ) {
// Taxonomy Archive Index
$context = 'taxonomy';
} else if ( is_archive() ) {
// Archive Index
$context = 'archive';
} else if ( is_search() ) {
// Search Results Page
$context = 'search';
} else if ( is_404() ) {
// Error 404 Page
$context = '404';
} else if ( is_attachment() ) {
// Attachment Page
$context = 'attachment';
} else if ( is_singular( 'post' ) ) {
// Single Blog Post
$context = 'single';
} else if ( is_page() ) {
// Static Page
$context = 'page';
} else if ( is_singular() ) {
// Single Custom Post
$context = get_post_type();
} else if ( is_home() ) {
// Blog Posts Index
$context = 'home';
}
return apply_filters( 'oenology_get_context', $context );
}
/**
* Get Current Page Layout
*/
function oenology_get_current_page_layout() {
// Use default layout for 404 pages
if ( is_404() ) {
return 'default';
}
// Otherwise, determine appropriate layout
$layout = '';
global $post;
global $oenology_options;
$custom = ( get_post_custom( $post->ID ) ? get_post_custom( $post->ID ) : false );
$custom_layout = ( isset( $custom['_oenology_layout'][0] ) ? $custom['_oenology_layout'][0] : 'default' );
if ( ! is_admin() ) {
if ( is_attachment() ) {
$layout .= 'attachment';
}
else if ( is_front_page() && ! is_home() ) {
if ( 'default' == $custom_layout ) {
$layout .= $oenology_options['default_front_page_layout'];
} else {
$layout .= $custom_layout;
}
}
else if ( is_page() ) {
if ( 'default' == $custom_layout ) {
$layout .= $oenology_options['default_static_page_layout'];
} else {
$layout .= $custom_layout;
}
}
else if ( is_singular( 'post' ) ) {
if ( 'gallery' == get_post_format() || 'image' == get_post_format() || 'video' == get_post_format() ) {
$layout .= 'full';
}
else if ( 'default' == $custom_layout ) {
$layout .= $oenology_options['default_single_post_layout'];
}
else {
$layout .= $custom_layout;
}
}
else if ( is_home() || is_archive() || is_search() || is_404() ) {
$layout .= $oenology_options['post_index_layout'];
}
}
else if ( is_admin() ) {
if ( 'attachment' == $post->post_type ) {
$layout .= 'attachment';
}
else if ( 'page' == $post->post_type ) {
if ( 'default' == $custom_layout ) {
$layout .= $oenology_options['default_static_page_layout'];
}
else {
$layout .= $custom_layout;
}
}
else if ( 'post' == $post->post_type ) {
if ( 'gallery' == get_post_format( $post->ID ) || 'image' == get_post_format( $post->ID ) || 'video' == get_post_format( $post->ID ) ) {
$layout .= 'full';
}
if ( 'default' == $custom_layout ) {
$layout .= $oenology_options['default_single_post_layout'];
}
else {
$layout .= $custom_layout;
}
}
}
return apply_filters( 'oenology_get_current_page_layout', $layout );
}
/**
* Get current settings page tab
*/
function oenology_get_current_tab() {
$page = 'oenology-settings';
if ( isset( $_GET['page'] ) && 'oenology-reference' == $_GET['page'] ) {
$page = 'oenology-reference';
}
if ( isset( $_GET['tab'] ) ) {
$current = $_GET['tab'];
} else {
$oenology_options = oenology_get_options();
$current = $oenology_options['default_options_tab'];
}
return apply_filters( 'oenology_get_current_tab', $current );
}
/**
* Get custom category list
*/
function oenology_get_custom_category_list() {
$customcatlist ='';
$customcats= get_categories();
foreach( $customcats as $customcat ) {
$customcathref = get_category_link( $customcat->term_id );
$customcatfeedlink = get_category_feed_link( $customcat->term_id );
$customcatlist .= '
';
}
return apply_filters( 'oenology_get_custom_tag_list', $customtaglist );
}
/**
* Determine Header Text Color Setting
*
* Determine what color value to pass to the
* HEADER_TEXTCOLOR constant, based on whether a
* dark or light color scheme is being displayed.
*/
function oenology_get_header_textcolor() {
$headertextcolor = ( get_header_textcolor() ? get_header_textcolor() : false );
if ( ! $headertextcolor ) {
$colorscheme = oenology_get_color_scheme();
if ( 'light' == $colorscheme ) {
$headertextcolor = apply_filters( 'oenology_light_color_scheme_header_textcolor', '666666' );
} elseif ( 'dark' == $colorscheme ) {
$headertextcolor = apply_filters( 'oenology_light_color_scheme_header_textcolor', 'dddddd' );
}
}
return $headertextcolor;
}
/**
* Get GitHub API Data
*
* Uses the GitHub API (v3) to get information
* regarding open or closed issues (bug reports)
* or commits, then outputs them in a table.
*
* Derived from code originally developed by
* Michael Fields (@_mfields):
* @link https://gist.github.com/1061846 Simple Github commit API shortcode for WordPress
*
* @param string $context (required) API data context. Currently supports 'commits' and 'issues'. Default: 'commits'
* @param string $status (optional) Issue state, either 'open' or 'closed'. Only used for 'commits' context. Default: 'open'
* @param string $releasedate (optional) Date, in YYYY-MM-DD format, used to return commits/issues since last release.
* @param string $user (optional) GitHub user who owns repository.
* @param string $repo (optional) GitHub repository for which to return API data
*
* @return string table of formatted API data
*/
function oenology_get_github_api_data(
$context = 'commits',
$status = 'open',
$milestone = '11',
$roadmap = false,
$currentrelease = '3.2',
$releasedate = '2013-04-09',
$user = 'chipbennett',
$repo = 'oenology'
) {
$capability = 'read';
// $branch is user/repository string.
// Used variously throughout the function
$branch = $user . '/' . $repo;
// Create transient key string. Used to ensure API data are
// pinged only periodically. Different transient keys are
// created for commits, open issues, and closed issues.
$transient_key = 'oenology_' . $currentrelease . '_github_';
if ( 'commits' == $context ) {
$transient_key .= 'commits' . md5( $branch );
} else if ( 'issues' == $context ) {
$transient_key .= 'issues_' . $status . md5( $branch . $milestone );
}
// If cached (transient) data are used, output an HTML
// comment indicating such
$cached = get_transient( $transient_key );
if ( false !== $cached ) {
return $cached .= "\n" . '';
}
// Construct the API request URL, based on $branch and
// $context, for issues, $status, and $milestone
$apiurl = 'https://api.github.com/repos/' . $branch . '/' . $context;
if ( 'commits' == $context ) {
$apiurl .= '';
} else if ( 'issues' == $context ) {
$apiurl .= '?state=' . $status;
$apiurl .= '&milestone=' . $milestone;
$apiurl .= '&sort=created&direction=asc';
}
// Request the API data, using the constructed URL
$remote = wp_remote_get( esc_url( $apiurl ) );
// If the API data request results in an error, return
// an appropriate comment
if ( is_wp_error( $remote ) ) {
if ( current_user_can( $capability ) ) {
return '
Github API: Github is unavailable.
';
}
return;
}
// If the API returns a server error in response, output
// an error message indicating the server response.
if ( '200' != $remote['response']['code'] ) {
if ( current_user_can( $capability ) ) {
return '
Github API: Github responded with an HTTP status code of ' . esc_html( $remote['response']['code'] ) . '.
';
}
return;
}
// If the API returns a valid response, the data will be
// json-encoded; so decode it.
$data = ( ! empty( $remote['body'] ) ? json_decode( $remote['body'] ) : array() );
if ( 'issues' == $context ) {
// Test
}
usort( $data, 'oenology_sort_github_data' );
// If the decoded json data is null, return a message
// indicating that no data were returned.
if ( ! isset( $data ) || empty( $data ) ) {
$apidata = $context;
if ( 'issues' == $context ) {
$apidata = $status . ' ' . $context;
}
if ( current_user_can( $capability ) ) {
return '
No ' . $apidata . ' could be found.
';
return '
Github API: No ' . $apidata . ' could be found for this repository.
';
}
return;
}
// If the decoded json data has content, prepare the data
// to be output.
if ( 'issues' == $context ) {
// $reportdate is used as a table column header
$reportdate = ( 'open' == $status ? 'Reported' : 'Closed' );
// $reportobject is used to return the appropriate timestamp
$reportobject = ( 'open' == $status ? 'created_at' : 'closed_at' );
} else if ( 'commits' == $context ) {
// $reportdate is used as a table column header
$reportdate = 'Date';
}
// $reportidlabel is used as a table column header
$reportidlabel = ( 'issues' == $context ? '#' : 'Commit' );
// $datelastrelease is the PHP date of last released, based
// on the $releasedate parameter passed to the function
$datelastrelease = get_date_from_gmt( date( 'Y-m-d H:i:s', strtotime( $releasedate ) ), 'U' );
// Begin constructing the table
$output = '';
$output .= "\n" . '