php
include('settings.php');
if (function_exists('add_theme_support')) {
add_theme_support('menus');
register_nav_menu('header-menu','Header Menu');
// register_nav_menu('footer-menu','Footer Menu');
add_theme_support( 'post-thumbnails' );
add_image_size('home-featured',568,320,true);
add_image_size('home-blog',280,180,true);
}
function get_category_id($cat_name){
$term = get_term_by('name', $cat_name, 'category');
return $term->term_id;
}
function ds_get_excerpt($num_chars) {
$temp_str = substr(strip_shortcodes(strip_tags(get_the_content())),0,$num_chars);
$temp_parts = explode(" ",$temp_str);
$temp_parts[(count($temp_parts) - 1)] = '';
if(strlen(strip_tags(get_the_content())) > 125)
return implode(" ",$temp_parts) . '...';
else
return implode(" ",$temp_parts);
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name'=>'Sidebar',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Footer Col 1',
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Footer Col 2',
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Footer Col 3',
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
));
}
// EX POST CUSTOM FIELD START
$prefix = 'ex_';
$meta_box = array(
'id' => 'my-meta-box',
'title' => 'Custom meta box',
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'Show in slideshow',
'id' => $prefix . 'show_in_slideshow',
'type' => 'checkbox'
)
)
);
add_action('admin_menu', 'mytheme_add_box');
// Add meta box
function mytheme_add_box() {
global $meta_box;
add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']);
}
// Callback function to show fields in meta box
function mytheme_show_box() {
global $meta_box, $post;
// Use nonce for verification
echo '';
echo '';
}
add_action('save_post', 'mytheme_save_data');
// Save data from meta box
function mytheme_save_data($post_id) {
global $meta_box;
// verify nonce
if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($meta_box['fields'] as $field) {
$old = get_post_meta($post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], $new);
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
}
}
// EX POST CUSTOM FIELD END
/* Custom fields for PAGES Starts */
add_action( 'add_meta_boxes', 'pages_extra_fields_box' );
function pages_extra_fields_box() {
add_meta_box(
'pages_extra_fields_box_id',
__( 'Page Details', 'rochebros' ),
'pages_extra_fields_box_content',
'post',
'normal',
'high'
);
}
function pages_extra_fields_box_content( $post ) {
wp_nonce_field( plugin_basename( __FILE__ ), 'pages_extra_fields_box_content_nonce' ); ?>
php
}
add_action( 'save_post', 'pages_extra_fields_box_save' );
function pages_extra_fields_box_save( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( !wp_verify_nonce( $_POST['pages_extra_fields_box_content_nonce'], plugin_basename( __FILE__ ) ) )
return;
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) )
return;
} else {
if ( !current_user_can( 'edit_post', $post_id ) )
return;
}
$page_featured_type = $_POST['page_featured_type'];
$page_video_id = $_POST['page_video_id'];
update_post_meta( $post_id, 'page_featured_type', $page_featured_type );
update_post_meta( $post_id, 'page_video_id', $page_video_id );
}
/* Custom fields for PAGES Ends */
// **** PRODUCTION - Template1 Search START ****
class template1_search extends WP_Widget {
function template1_search() {
parent::WP_Widget(false, 'Custom Search');
}
function widget($args, $instance) {
$args['search_title'] = $instance['search_title'];
t1_func_search($args);
}
function update($new_instance, $old_instance) {
return $new_instance;
}
function form($instance) {
$search_title = esc_attr($instance['search_title']);
?>
php
}
}
function t1_func_search($args = array(), $displayComments = TRUE, $interval = '') {
global $wpdb;
echo $args['before_widget'];
if($args['search_title'] != '')
echo $args['before_title'] . $args['search_title'] . $args['after_title']; ?>
php
echo $args['after_widget'];
wp_reset_query();
}
register_widget('template1_search');
// **** PRODUCTION - Template1 Search END ****
?>