__('Main Menu', 'orange'),
));
// Enable support for Post Formats.
//add_theme_support('post-formats', array('aside', 'image', 'video', 'quote', 'link'));
// Setup the WordPress core custom background feature.
add_theme_support('custom-background', apply_filters('orange_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
)));
// Enable support for HTML5 markup.
add_theme_support('html5', array(
'comment-list',
'search-form',
'comment-form',
'gallery',
'caption',
));
}
endif; // orange_setup
add_action('after_setup_theme', 'orange_setup');
/**
* Get value from theme option
*/
function orange_option($option_id, $default = null) {
if (function_exists('ot_get_option')) {
$options = ot_get_option($option_id, $default);
return $options;
}
return $default;
}
/**
* Update theme option values
*/
function orange_update_option($name, $value) {
$options = get_option('orange_options');
$options[$name] = $value;
return update_option('orange_options', $options);
}
/**
* Delete values from theme option
*/
function orange_delete_option($name) {
$options = get_option('orange_options');
unset($options[$name]);
return update_option('orange_options', $options);
}
/**
* Default nav fallback
*/
function orange_nav_fallback() {
?>
'custom_menu', 'container_id' => 'menu', 'menu_class' => 'pkmenu', 'fallback_cb' => 'orange_nav_fallback'));
} else {
orange_nav_fallback();
}
}
/**
* For attachment page
*/
if (!function_exists('orange_posted_in')) :
/**
* Prints HTML with meta information for the current post (category, tags and permalink).
*
*/
function orange_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list('', ', ');
if ($tag_list) {
$posted_in = __('This entry was posted in %1$s and tagged %2$s. Bookmark the permalink .', 'orange');
} elseif (is_object_in_taxonomy(get_post_type(), 'category')) {
$posted_in = __('This entry was posted in %1$s. Bookmark the permalink .', 'orange');
} else {
$posted_in = __('Bookmark the permalink .', 'orange');
}
// Prints the string, replacing the placeholders.
printf(
$posted_in, get_the_category_list(', '), $tag_list, get_permalink(), the_title_attribute('echo=0')
);
}
endif;
/**
* Pagination
*/
function orange_pagination($pages = '') {
?>
'; // tag before the current crumb
$after = ''; // tag after the current crumb
echo '';
global $post;
$homeLink = home_url();
echo '
' . $home . ' ' . $delimiter . ' ';
if (is_category()) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0)
echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;
}
elseif (is_day()) {
echo '
' . get_the_time('Y') . ' ' . $delimiter . ' ';
echo '
' . get_the_time('F') . ' ' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;
} elseif (is_month()) {
echo '
' . get_the_time('Y') . ' ' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;
} elseif (is_year()) {
echo $before . get_the_time('Y') . $after;
} elseif (is_single() && !is_attachment()) {
if (get_post_type() != 'post') {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '
' . $post_type->labels->singular_name . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} else {
$cat = get_the_category();
$cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo $before . get_the_title() . $after;
}
} elseif (!is_single() && !is_page() && get_post_type() != 'post') {
$post_type = get_post_type_object(get_post_type());
echo $before . $post_type->labels->singular_name . $after;
} elseif (is_attachment()) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID);
$cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo '
' . $parent->post_title . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} elseif (is_page() && !$post->post_parent) {
echo $before . get_the_title() . $after;
} elseif (is_page() && $post->post_parent) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '
' . get_the_title($page->ID) . ' ';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb)
echo $crumb . ' ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} elseif (is_search()) {
echo $before . 'Search results for "' . get_search_query() . '"' . $after;
} elseif (is_tag()) {
echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
} elseif (is_author()) {
global $author;
$userdata = get_userdata($author);
echo $before . 'Articles posted by ' . $userdata->display_name . $after;
} elseif (is_404()) {
echo $before . 'Error 404' . $after;
}
if (get_query_var('paged')) {
if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
echo ' (';
echo __('Page', 'swiftray') . ' ' . get_query_var('paged');
if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
echo ')';
}
echo '
';
}
/**
* This function thumbnail id and
* returns thumbnail image
* @param type $iw
* @param type $ih
*/
function orange_get_thumbnail($iw, $ih) {
$permalink = get_permalink();
$thumb = get_post_thumbnail_id();
$image = orange_thumbnail_resize($thumb, '', $iw, $ih, true, 90);
if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) {
print " ";
}
}
/**
* This function gets image width and height and
* Prints attached images from the post
*/
function orange_get_image($width, $height) {
$w = $width;
$h = $height;
global $post, $posts;
//This is required to set to Null
$img_source = '';
$permalink = get_permalink();
ob_start();
ob_end_clean();
$output = preg_match_all('//i', $post->post_content, $matches);
if (isset($matches [1] [0])) {
$img_source = $matches [1] [0];
}
$img_path = orange_image_resize($img_source, $w, $h);
if (!empty($img_path['url'])) {
print " ";
}
}
/**
* Portfolio Image
*/
function orange_blog_image($imgwh, $imght) {
global $post, $posts;
//This is required to set to Null
$id = '';
$the_title = '';
// Till Here
$permalink = get_permalink();
$homeLink = get_template_directory_uri();
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('//i', $post->post_content, $matches);
if (isset($matches [1] [0])) {
$first_img = $matches [1] [0];
}
if (!empty($first_img)) { //Defines a default image
print " ";
}
}
/**
* Favicon option
*/
function orange_childtheme_favicon() {
if (orange_option('site_favicon') != '') {
echo ' ' . "\n";
}
}
add_action('wp_head', 'orange_childtheme_favicon');
/**
* Custom css
*/
function orange_custom_css() {
$output = '';
$custom_css = orange_option('custom_css');
if ($custom_css <> '') {
$output .= $custom_css . "\n";
}
// Output styles
if ($output <> '') {
$output = "\n\n";
echo $output;
}
}
add_action('wp_head', 'orange_custom_css');
/**
* Alter default excerpt length
*/
function orange_excerpt_length($length) {
return 35;
}
add_filter('excerpt_length', 'orange_excerpt_length');
/**
* Custom excerpt
*/
function orange_trim_excerpt($length) {
global $post;
$explicit_excerpt = $post->post_excerpt;
if ('' == $explicit_excerpt) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
} else {
$text = apply_filters('the_content', $explicit_excerpt);
}
$text = strip_shortcodes($text); // optional
$text = strip_tags($text);
$excerpt_length = $length;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[…]');
$text = implode(' ', $words);
$text = apply_filters('the_excerpt', $text);
}
return $text;
}
/**
* Enqueuing css
*/
function orange_css() {
wp_enqueue_style('orange-bootstrap', get_template_directory_uri() . '/css/bootstrap.css');
wp_enqueue_style('orange-bootstrap-theme', get_template_directory_uri() . '/css/bootstrap-theme.css');
wp_enqueue_style('orange-reset', get_template_directory_uri() . '/css/reset.css');
wp_enqueue_style('orange-font', 'http://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300');
wp_enqueue_style('orange-style', get_stylesheet_uri());
wp_enqueue_style('orange-meanmenu', get_template_directory_uri() . '/css/meanmenu.css');
wp_enqueue_style('orange-responsive', get_template_directory_uri() . '/css/responsive.css');
}
add_action('wp_enqueue_scripts', 'orange_css');
/**
* Enqueue scripts and styles.
*/
function orange_scripts() {
wp_enqueue_script('orange-menu', get_template_directory_uri() . '/js/menu.js', array('jquery'), '', true);
wp_enqueue_script('orange-flex', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), '', true);
wp_enqueue_script('orange-meanmenu', get_template_directory_uri() . '/js/jquery.meanmenu.js', array('jquery'), '', true);
wp_enqueue_script('orange-init', get_template_directory_uri() . '/js/init.js', array('jquery'), '', true);
if (is_singular() && get_option('thread_comments'))
wp_enqueue_script('comment-reply');
}
add_action('wp_enqueue_scripts', 'orange_scripts');
function orange_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list('', ', ');
if ($tag_list) {
$posted_in = __('This entry was posted in %1$s and tagged %2$s. Bookmark the permalink .', 'swiftray');
} elseif (is_object_in_taxonomy(get_post_type(), 'category')) {
$posted_in = __('This entry was posted in %1$s. Bookmark the permalink .', 'swiftray');
} else {
$posted_in = __('Bookmark the permalink .', 'swiftray');
}
// Prints the string, replacing the placeholders.
printf($posted_in, get_the_category_list(', '), $tag_list, get_permalink(), the_title_attribute('echo=0'));
}