167 lines
4.4 KiB
PHP
167 lines
4.4 KiB
PHP
<?php
|
|
add_theme_support( 'automatic-feed-links' );
|
|
add_theme_support( 'menus' );
|
|
add_theme_support( 'post-thumbnails' );
|
|
|
|
// Register Custom Navigation Walker
|
|
require_once('wp-bootstrap-navwalker.php');
|
|
|
|
register_sidebar(array(
|
|
'name'=> 'Main Sidebar',
|
|
'id' => 'main_sidebar',
|
|
'before_widget' => '',
|
|
'after_widget' => '<div class="thickdivide-side"></div>',
|
|
'before_title' => '<h3 class="title">',
|
|
'after_title' => '</h3>',
|
|
));
|
|
|
|
|
|
/* ACF */
|
|
if( function_exists('acf_add_options_page') ) {
|
|
|
|
acf_add_options_page(array(
|
|
'page_title' => 'Template Options',
|
|
'menu_title' => 'Template Options',
|
|
'menu_slug' => 'theme-general-options',
|
|
'capability' => 'edit_posts',
|
|
'redirect' => false,
|
|
'position' => 20
|
|
));
|
|
}
|
|
|
|
/* Modify the read more link on the_excerpt() */
|
|
|
|
function et_excerpt_length($length) {
|
|
return 35;
|
|
}
|
|
add_filter('excerpt_length', 'et_excerpt_length');
|
|
|
|
/* Add a link to the end of our excerpt contained in a div for styling purposes and to break to a new line on the page.*/
|
|
|
|
function et_excerpt_more($more) {
|
|
global $post;
|
|
return '...';
|
|
}
|
|
add_filter('excerpt_more', 'et_excerpt_more');
|
|
|
|
|
|
|
|
|
|
|
|
function snip_category_rel($result) {
|
|
$result = str_replace('rel="category tag"', 'class="btn btn-xs btn-orange"', $result);
|
|
return $result;
|
|
}
|
|
add_filter('the_category', 'snip_category_rel');
|
|
add_filter('wp_list_categories', 'snip_category_rel');
|
|
|
|
|
|
|
|
|
|
/*
|
|
* Change the comment reply link to use 'Reply to <Author First Name>'
|
|
*/
|
|
function add_comment_author_to_reply_link($link, $args, $comment){
|
|
|
|
$comment = get_comment( $comment );
|
|
|
|
// If no comment author is blank, use 'Anonymous'
|
|
if ( empty($comment->comment_author) ) {
|
|
if (!empty($comment->user_id)){
|
|
$user=get_userdata($comment->user_id);
|
|
$author=$user->user_login;
|
|
} else {
|
|
$author = __('Anonymous');
|
|
}
|
|
} else {
|
|
$author = $comment->comment_author;
|
|
}
|
|
|
|
// If the user provided more than a first name, use only first name
|
|
if(strpos($author, ' ')){
|
|
$author = substr($author, 0, strpos($author, ' '));
|
|
}
|
|
|
|
// Replace Reply Link with "Reply to <Author First Name>"
|
|
$reply_link_text = $args['reply_text'];
|
|
$link = str_replace($reply_link_text, 'Reply to ' . $author, $link);
|
|
|
|
return $link;
|
|
}
|
|
add_filter('comment_reply_link', 'add_comment_author_to_reply_link', 10, 3);
|
|
|
|
/*
|
|
* Change the comment reply cancel link to use 'Cancel Reply to <author First Name>
|
|
*/
|
|
function add_comment_author_to_cancel_reply_link($formatted_link, $link, $text){
|
|
|
|
$comment = get_comment( $comment );
|
|
|
|
// If no comment author is blank, use 'Anonymous'
|
|
if ( empty($comment->comment_author) ) {
|
|
if (!empty($comment->user_id)){
|
|
$user=get_userdata($comment->user_id);
|
|
$author=$user->user_login;
|
|
} else {
|
|
$author = __('Anonymous');
|
|
}
|
|
} else {
|
|
$author = $comment->comment_author;
|
|
}
|
|
|
|
// If the user provided more than a first name, use only first name
|
|
if(strpos($author, ' ')){
|
|
$author = substr($author, 0, strpos($author, ' '));
|
|
}
|
|
|
|
// Replace "Cancel Reply" with "Cancel Reply to <author First Name>"
|
|
$formatted_link = str_ireplace($text, 'Cancel Reply to ' . $author, $formatted_link);
|
|
|
|
return $formatted_link;
|
|
}
|
|
add_filter('cancel_comment_reply_link', 'add_comment_author_to_cancel_reply_link', 10, 3);
|
|
|
|
|
|
/*
|
|
Plugin Name: Remove Website and Email Field
|
|
Description: Removes the website field and email Field from the comments form
|
|
*/
|
|
add_filter('comment_form_default_fields', 'url_filtered');
|
|
function url_filtered($fields)
|
|
{
|
|
if(isset($fields['url']))
|
|
unset($fields['url']);
|
|
return $fields;
|
|
}
|
|
|
|
add_filter('comment_form_default_fields', 'email_filtered');
|
|
function email_filtered($fields)
|
|
{
|
|
if(isset($fields['email']))
|
|
unset($fields['email']);
|
|
return $fields;
|
|
}
|
|
function wpb_remove_commentsip( $comment_author_ip ) {
|
|
return '';
|
|
}
|
|
remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
|
|
|
|
function create_posttype() {
|
|
|
|
register_post_type( 'feed-items',
|
|
// CPT Options
|
|
array(
|
|
'labels' => array(
|
|
'name' => __( 'Feed Items' ),
|
|
'singular_name' => __( 'Feed Item' )
|
|
),
|
|
'public' => true,
|
|
'has_archive' => true,
|
|
'rewrite' => array('slug' => 'feed-items'),
|
|
)
|
|
);
|
|
}
|
|
// Hooking up our function to theme setup
|
|
add_action( 'init', 'create_posttype' );
|
|
|
|
?>
|