Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<?php
function ovpr_enqueue_scripts() {
wp_enqueue_script('ovpr', get_bloginfo('stylesheet_directory').'/ovpr.js', array('uc-hale-custom'), false, true);
}
add_action('wp_enqueue_scripts', 'ovpr_enqueue_scripts', 900);
add_action( 'init', 'register_my_menus' );
// Register Sidebar
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Article Feed 1',
'id' => 'articlefeed1'
));
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Article Feed 2',
'id' => 'articlefeed2'
));
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Article Feed 3',
'id' => 'articlefeed3'
));
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Article Feed 4',
'id' => 'articlefeed4'
));
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Article Feed 5',
'id' => 'articlefeed5'
));
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Article Feed 6',
'id' => 'articlefeed6'
));
}
function custom_searchform($form){
global $search_counter;
if( !$search_counter ){
$search_counter = 0;
}
$search_counter++;
$form = '<div class="searchform"><form action="'.home_url( '/' ).'" method="get" class="form-inline" role="form"><div class="form-group"><fieldset><legend class="sr-only">Search this Site</legend>';
$form .= '<label for="searchfield-'.$search_counter.'" class="sr-only" Search in '.home_url( '/' ).'</label>';
$form .= '<input type="text" name="s" id="searchfield-'.$search_counter.'" value="'.get_search_query().'" class="form-control search" placeholder="Search '.get_bloginfo("name").'... " />';
$form .= '<button type="submit" class="btn" title="Search"><i class="icon-search"></i><span class="sr-only"></span></button>';
$form .= '</fieldset></div></form></div>';
return $form;
}
add_filter('get_search_form', 'custom_searchform');
function ovpr_init(){
register_sidebar( array(
'name' => 'OVPR Home',
'id' => 'ovpr-home',
'description' => 'Appears on the OVPR Homepage',
'class' => '',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>'
));
}
add_action( 'widgets_init', 'ovpr_init' );
function ovpr_customize_register( $wp_customize ) {
$wp_customize->add_section( 'colors' , array(
'title' => __( 'OVPR Colors', 'ovpr' ),
'priority' => 30,
) );
$wp_customize->add_setting( 'border_color',
array(
'default' => '#e60021',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => 'refresh'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'border_color',
array(
'label' => __( 'Border Color', 'ovpr' ),
'section' => 'colors',
'settings' => 'border_color',
) )
);
}
add_action( 'customize_register', 'ovpr_customize_register' );
function ovpr_add_theme_support(){
add_theme_support( 'post-formats', array(
'link',
) );
}
add_action( 'after_setup_theme', 'ovpr_add_theme_support' );
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_post-link',
'title' => 'Post Link',
'fields' => array (
array (
'key' => 'field_55db77d8658e3',
'label' => 'Post Link',
'name' => 'post_link',
'type' => 'text',
'instructions' => 'Add a web address here. ',
'required' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'none',
'maxlength' => '',
),
),
'location' => array (
array (
array (
'param' => 'post_format',
'operator' => '==',
'value' => 'link',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
}
if( !class_exists('OVPR_Widget_Recent_Posts') ){
class OVPR_Widget_Recent_Posts extends WP_Widget_Recent_Posts {
/**
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) {
$cache = array();
if ( ! $this->is_preview() ) {
$cache = wp_cache_get( 'widget_recent_posts', 'widget' );
}
if ( ! is_array( $cache ) ) {
$cache = array();
}
if ( ! isset( $args['widget_id'] ) ) {
$args['widget_id'] = $this->id;
}
if ( isset( $cache[ $args['widget_id'] ] ) ) {
echo $cache[ $args['widget_id'] ];
return;
}
ob_start();
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
if ( ! $number )
$number = 5;
$show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
/**
* Filter the arguments for the Recent Posts widget.
*
* @since 3.4.0
*
* @see WP_Query::get_posts()
*
* @param array $args An array of arguments used to retrieve the recent posts.
*/
$r = new WP_Query( apply_filters( 'widget_posts_args', array(
'posts_per_page' => $number,
'no_found_rows' => true,
'post_status' => 'publish',
'ignore_sticky_posts' => true
) ) );
$linkPostsQuery = new WP_Query(array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-link'
)
),
'fields' => 'ids'
));
$linkPosts = $linkPostsQuery->get_posts();
if ($r->have_posts()) :
?>
<?php echo $args['before_widget']; ?>
<?php if ( $title ) {
echo $args['before_title'] . $title . $args['after_title'];
} ?>
<ul>
<?php while ( $r->have_posts() ) : $r->the_post(); ?>
<?php
$permalink = get_permalink();
if( in_array(get_the_ID(),$linkPosts) ){
$permalink = get_field('post_link', get_the_ID()); //Retrieve post link from ACF
}
?>
<li>
<a href="<?php echo $permalink ?>"><?php get_the_title() ? the_title() : the_ID(); ?></a>
<?php if ( $show_date ) : ?>
<span class="post-date"><?php echo get_the_date(); ?></span>
<?php endif; ?>
</li>
<?php endwhile; ?>
</ul>
<?php echo $args['after_widget']; ?>
<?php
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();
endif;
if ( ! $this->is_preview() ) {
$cache[ $args['widget_id'] ] = ob_get_flush();
wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
} else {
ob_end_flush();
}
}
}
}
function register_ovpr_recent_posts_widget() {
unregister_widget('WP_Widget_Recent_Posts');
register_widget( 'OVPR_Widget_Recent_Posts' );
}
add_action( 'widgets_init', 'register_ovpr_recent_posts_widget' );
?>