post_type}_template", true ); /* If a specific template was input, check that the post template matches. */ if ( !empty( $template) && ( $template == $post_template ) ) return true; /* If no specific template was input, check if the post has a template. */ elseif ( empty( $template) && !empty( $post_template ) ) return true; } /* Return false for everything else. */ return false; } /** * The WordPress.org theme review requires that a link be provided to the single post page for untitled * posts. This is a filter on 'the_title' so that an '(Untitled)' title appears in that scenario, allowing * for the normal method to work. * * @since 0.9.0 * @access public * @param string $title * @return string */ function omega_untitled_post( $title ) { if ( empty( $title ) && !is_singular() && in_the_loop() && !is_admin() ) $title = __( '(Untitled)', 'omega' ); return $title; } /** * Retrieves the file with the highest priority that exists. The function searches both the stylesheet * and template directories. This function is similar to the locate_template() function in WordPress * but returns the file name with the URI path instead of the directory path. * * @since 0.9.0 * @access public * @link http://core.trac.wordpress.org/ticket/18302 * @param array $file_names The files to search for. * @return string */ function omega_locate_theme_file( $file_names ) { $located = ''; /* Loops through each of the given file names. */ foreach ( (array) $file_names as $file ) { /* If the file exists in the stylesheet (child theme) directory. */ if ( is_child_theme() && file_exists( trailingslashit( get_stylesheet_directory() ) . $file ) ) { $located = trailingslashit( get_stylesheet_directory_uri() ) . $file; break; } /* If the file exists in the template (parent theme) directory. */ elseif ( file_exists( trailingslashit( get_template_directory() ) . $file ) ) { $located = trailingslashit( get_template_directory_uri() ) . $file; break; } } return $located; } /** * Converts a hex color to RGB. Returns the RGB values as an array. * * @since 0.9.0 * @access public * @param string $hex * @return array */ function omega_hex_to_rgb( $hex ) { /* Remove "#" if it was added. */ $color = trim( $hex, '#' ); /* If the color is three characters, convert it to six. */ if ( 3 === strlen( $color ) ) $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2]; /* Get the red, green, and blue values. */ $red = hexdec( $color[0] . $color[1] ); $green = hexdec( $color[2] . $color[3] ); $blue = hexdec( $color[4] . $color[5] ); /* Return the RGB colors as an array. */ return array( 'r' => $red, 'g' => $green, 'b' => $blue ); }