basic wp functions.php
<?php
register_nav_menus();
$args = array(
'width' => 980,
'height' => 60,
//'default-image' => get_template_directory_uri() . '/images/header.jpg'
);
add_theme_support( 'custom-header', $args );
add_theme_support( 'custom-logo', array(
'width' => 400,
'height' => 100,
'flex-height' => true,
'flex-width' => true
));
add_theme_support( 'post-thumbnails' );
add_image_size( 'basic-thumb', 100, 100, true );
//*****************************************************
// Register Libs
//*****************************************************
function theme_scripts() {
if (!is_admin()) {
wp_enqueue_style('sample-css', get_stylesheet_directory_uri() . '/css/sample-css.min.css');
wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css');
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'sample-js', get_template_directory_uri() . '/js/sample-js.min.js', false, '', true );
wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/common.min.js', false, '', true );
}
}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
//*****************************************************
// Add Fancybox Rel
//*****************************************************
function add_fancybox($content) {
global $post;
$pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i";
$replacement = '<a$1href=$2$3.$4$5 class="fancybox-thumb"$6>$7</a>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter('the_content', 'add_fancybox');
//*****************************************************
// Add Gallery Rel
//*****************************************************
function add_fancybox_attachment($link, $id = null) {
$id = intval( $id );
$_post = get_post( $id );
$post_title = esc_attr( $_post->post_title );
return str_replace('<a href', '<a title="'. $post_title .'" class="fancybox-thumb" rel="[gallery]" href', $link);
}
add_filter('wp_get_attachment_link', 'add_fancybox_attachment', 10, 2);
//*****************************************************
// Sample Register Sidebar
//*****************************************************
/*register_sidebar(array(
'name' => __( 'Example sidebar' ),
'id' => 'example-sidebar',
'before_title' => '<h2>',
'after_title' => '</h2>',
'before_widget' => '',
'after_widget' => ''
));*/
//*****************************************************
// Example Easy Post Types
//*****************************************************
/*function post_type__sample() {
register_post_type( 'sample_post_type',array(
'labels' => array ('name' => __('Sample Name'),'add_new' => __('Add Post')),
'public' => false,
'show_ui' => true,
'supports' => array('title','thumbnail','custom-fields')
) );
}
add_action('init', 'post_type__sample');*/
//*****************************************************
// Sample Post Type and Taxonomy
//*****************************************************
/*function post_type__and_taxonomy_sample() {
register_post_type( 'sample_post_type',array(
'labels' => array ('name' => __('Sample Name'),'add_new' => __('Add Post')),
'public' => true,
'show_ui' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'sample_slug'),
'supports' => array('title','editor','thumbnail','custom-fields')
) );
}
add_action('init', 'post_type__and_taxonomy_sample');
register_taxonomy('sample_taxonomy', 'sample_post_type', array(
'hierarchical' => true,
'label' => 'Sample Taxonomy Name',
'query_var' => true,
'show_admin_column' => true
));*/
//*****************************************************
// Sample Excerpt
//*****************************************************
/*function custom_excerpt_length( $length ) {
return 41;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function new_excerpt_more( $more ) {
return '...';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );*/
//*****************************************************
// Add Attr to Post Links
//*****************************************************
/*add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');
function posts_link_attributes() {
return 'class="btn btn-default older-posts pull-right"';
}*/