";
echo "
$home_link
$menu
";
if ( is_active_sidebar( 'header-widgets' ) ) {
echo '
';
}
echo '
';
}
function anchorage_arrow( $direction = 'down', $classes = array(), $href = '#' ) {
$left = esc_html( '←', 'anchorage' );
$up = esc_html( '↑', 'anchorage' );
$right = esc_html( '→', 'anchorage' );
$down = esc_html( '↓', 'anchorage' );
if ( $direction == 'left' ) {
$out = $left;
} elseif ( $direction == 'up' ) {
$out = $up;
} elseif ( $direction == 'right' ) {
$out = $right;
} else {
$out = $down;
}
$classes = array_map( 'sanitize_html_class', $classes );
$classes = implode( ' ', $classes );
$classes = " class='$classes arrow' ";
$out = " $out ";
$href = esc_attr( $href );
$out = "$out";
return $out;
}
/**
* Returns a WordPress search form.
*
* Accepts arguments to inject CSS classes into the form, which this theme uses
* in order to comply with SMACCS. Passing dynamic class values for each
* instance would not be possible with the normal use of searchform.php.
*
* @param array $form_class CSS Classes for the form.
* @param array $search_input_class CSS Classes for the search input.
* @return string A search form.
*
* @since anchorage 1.0
*/
function anchorage_search_form( $form_classes = array(), $search_input_classes = array() ) {
// An array of CSS classes for the search form.
$form_classes = array_map( 'sanitize_html_class', $form_classes );
$form_classes_string = implode( ' ', $form_classes );
// An array of CSS classes for the search input.
$search_input_classes = array_map( 'sanitize_html_class', $search_input_classes );
$search_input_string = implode( ' ', $search_input_classes );
$placeholder = esc_attr__( 'Search', 'anchorage' );
if( isset( $_GET['s'] ) ) {
$placeholder = esc_attr( $_GET['s'] );
}
$out ="
";
return $out;
}
/**
* Return a string to denote the post format, if not standard.
*
* @return string [description]
*/
function anchorage_get_post_format(){
global $post;
$post_id = absint( $post->ID );
$format = get_post_format( $post_id );
$format = esc_html( $format );
if ( empty( $format ) ) {
return false;
}
$out = "$format →";
return $out;
}
/**
* Return an HTML img tag for the first image in a post content. Used to draw
* the content for posts of the "image" format.
*
* @return string An HTML img tag for the first image in a post content.
*/
function anchorage_get_first_image() {
// Expose information about the current post.
global $post;
// We'll trap to see if this stays empty later in the function.
$src = '';
// Grab all img src's in the post content
$output = preg_match_all( '//i', $post->post_content, $matches );
// Grab the first img src returned by our regex.
if( ! isset ( $matches[1][0] ) ) { return false; }
$src = $matches[1][0];
// Sanitize for output
$src = esc_url( $src );
// Make sure there's still something worth outputting after sanitization.
if( empty( $src ) ) { return false; }
// Grab and sanitize the post title as an alt.
$alt = esc_attr( $post->post_title );
$out = "";
// Trap to see if the post has a caption shortcode
$caption = '';
if( has_shortcode( $post->post_content, 'caption' ) ) {
$output = preg_match_all( '/caption=(.*)\]/smU', $post->post_content, $matches );
if($output){
$caption = $matches[1][0];
$caption = trim($caption, '"');
$caption = trim($caption, "'");
} else {
// Grab the content of the first caption
preg_match_all( '/\[caption\s?.*\](.*)\[\/caption\]/smU', $post->post_content, $matches );
$caption = strip_tags( $matches[1][0], '