__( 'Main Navigation', 'Azurite' ) ) ); // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); add_image_size( 'Azurite', 300, 200, true ); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); } add_action( 'after_setup_theme', 'Azurite_setup' ); /* * Loads the Options Panel */ if ( !function_exists( 'optionsframework_init' ) ) { /* Set the file path based on whether we're in a child theme or parent theme */ if ( get_stylesheet_directory() == get_template_directory() ) { define('OPTIONS_FRAMEWORK_URL', get_template_directory() . '/admin/'); define('OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/admin/'); } else { define('OPTIONS_FRAMEWORK_URL', get_stylesheet_directory() . '/admin/'); define('OPTIONS_FRAMEWORK_DIRECTORY', get_stylesheet_directory_uri() . '/admin/'); } require_once (OPTIONS_FRAMEWORK_URL . 'options-framework.php'); } /* * This is an example of how to add custom scripts to the options panel. * This example shows/hides an option when a checkbox is clicked. */ add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts'); function optionsframework_custom_scripts() { ?> get_queried_object(); if ( isset( $page_obj->ID ) && $page_obj->ID >= 0 ) return $page_obj->ID; return -1; } /** * Get custom field of the current page * $type = string|int */ function Azurite_get_custom_field($filedname, $id = NULL, $single=true) { global $post; if($id==NULL) $id = get_the_ID(); if($id==NULL) $id = Azurite_get_page_id(); $value = get_post_meta($id, $filedname, $single); if($single) return stripslashes($value); else return $value; } /** * Get Limited String * $output = string * $max_char = int */ function Azurite_get_limited_string($output, $max_char=100, $end='...') { $output = str_replace(']]>', ']]>', $output); $output = strip_tags($output); $output = strip_shortcodes($output); if ((strlen($output)>$max_char) && ($espacio = strpos($output, " ", $max_char ))) { $output = substr($output, 0, $espacio).$end; return $output; } else { return $output; } } /** * Tests if any of a post's assigned categories are descendants of target categories * * @param mixed $cats The target categories. Integer ID or array of integer IDs * @param mixed $_post The post * @return bool True if at least 1 of the post's categories is a descendant of any of the target categories * @see get_term_by() You can get a category by name or slug, then pass ID to this function * @uses get_term_children() Gets descendants of target category * @uses in_category() Tests against descendant categories * @version 2.7 */ function Azurite_post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) { // get_term_children() accepts integer ID only $descendants = get_term_children( (int) $cat, 'category'); if ( $descendants && in_category( $descendants, $_post ) ) return true; } return false; } /** * Twitter's Blogger.js output for Twitter widgets * $unique_id = string * $username = string * limit = int */ function Azurite_twitter_script($unique_id,$username,$limit) { ?>
  • id="li-comment-">
    comment_approved == '0') : ?>

    $depth, 'max_depth' => $args['max_depth']))) ?>
    '; $after_widget = '
    '; $before_title = '

    '; $after_title = '

    '; register_sidebar(array('name' => __('Default','Azurite'),'id' => 'default','before_widget' => $before_widget,'after_widget' => $after_widget,'before_title' => $before_title,'after_title' => $after_title)); } /** * Filter for get_the_excerpt */ function Azurite_get_the_excerpt($content){ return str_replace(' [...]','',$content); } /** * Get the sidebar ID */ function Azurite_get_sidebar_id(){ global $post; $sidebar_id = 'sidebar-default'; if(isset($post->ID)) if(is_active_sidebar('sidebar-'.$post->ID)) $sidebar_id = 'sidebar-'.$post->ID; return $sidebar_id; } /** * Improved Wordpress page menu function */ function Azurite_wp_page_menu( $args = array() ) { $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => 'menu', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '', 'show_home' => 1); $args = wp_parse_args( $args, $defaults ); $args = apply_filters( 'wp_page_menu_args', $args ); $menu = ''; $list_args = $args; // Show Home in the menu if ( ! empty($args['show_home']) ) { if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) $text = __('Home','Azurite'); else $text = $args['show_home']; $class = ''; if ( is_front_page() && !is_paged() ) $class = 'class="current_page_item"'; $menu .= '
  • ' . $args['link_before'] . $text . $args['link_after'] . '
  • '; // If the front page is a page, add it to the exclude list if (get_option('show_on_front') == 'page') { if ( !empty( $list_args['exclude'] ) ) { $list_args['exclude'] .= ','; } else { $list_args['exclude'] = ''; } $list_args['exclude'] .= get_option('page_on_front'); } } $list_args['echo'] = false; $list_args['title_li'] = ''; $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) ); if ( $menu ) $menu = ''; $menu = apply_filters( 'wp_page_menu', $menu, $args ); if ( $args['echo'] ) echo $menu; else return $menu; } /* Wp Title */ function Azurite_doc_title( $doc_title ) { if( is_category() ) { $doc_title = __( 'Category: ', 'Azurite' ) . $doc_title . ' - '; } elseif( is_tag() ) { $doc_title = single_tag_title( __( 'Tag Archive for "', 'Azurite'), false ) . '" - '; } elseif( is_archive() ) { $doc_title .= __( ' Archive - ', 'Azurite' ); } elseif( is_page() ) { $doc_title .= ' - '; } elseif( is_search() ) { $doc_title = __('Search for "','Azurite') . get_search_query() . '" - '; } elseif( ! is_404() && is_single() || is_page() ) { $doc_title .= ' - '; } elseif( is_404() ) { $doc_title = __( 'Not Found - ', 'Azurite' ); } $doc_title .= get_bloginfo('name'); return $doc_title; } add_filter( 'wp_title', 'Azurite_doc_title' ); add_filter( 'the_content_more_link', 'Azurite_more_link', 10, 2 ); function Azurite_more_link( $more_link, $more_link_text ) { return '

    '.$more_link; } add_filter('the_title','Azurite_has_title'); function Azurite_has_title($title){ global $post; if($title == ''){ return get_the_time(get_option( 'date_format' )); }else{ return $title; } } if (!is_admin()){ add_action( 'wp_print_styles', 'Azurite_add_stylesheets' ); add_action( 'wp_enqueue_scripts', 'Azurite_add_javascript' ); } add_filter('body_class','Azurite_browser_body_class'); add_filter('the_excerpt', 'Azurite_get_the_excerpt'); add_filter('get_the_excerpt', 'Azurite_get_the_excerpt'); add_action( 'widgets_init', 'Azurite_the_widgets_init' ); // Allow Shortcodes in Sidebar Widgets add_filter('widget_text', 'do_shortcode'); /** * Add default options and show Options Panel after activate */ if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) { //Do redirect wp_redirect( admin_url( 'admin.php?page=options-framework' ) ); exit; } ?>