'Top Hat', 'regular' => 'Normal Menu', 'footer' => 'Footer Menu' )); if ( ! isset( $content_width ) ) $content_width = 900; function anatomy_css() { wp_register_style( 'skeleton-base', get_stylesheet_directory_uri() . '/stylesheets/skeleton/base.css' ); wp_register_style( 'skeleton-skeleton', get_stylesheet_directory_uri() . '/stylesheets/skeleton/skeleton.css' ); wp_register_style( 'skeleton-layout', get_stylesheet_directory_uri() . '/stylesheets/skeleton/layout.css' ); wp_register_style( 'font-awesome', get_stylesheet_directory_uri() . '/stylesheets/font-awesome/font-awesome.css' ); wp_register_style( 'anatomy-styles', get_stylesheet_directory_uri() . '/style.css' ); wp_register_style( 'skins-default', get_stylesheet_directory_uri() . '/stylesheets/skins/default.css' ); wp_enqueue_style( 'skeleton-base' ); wp_enqueue_style( 'skeleton-skeleton' ); wp_enqueue_style( 'skeleton-layout' ); wp_enqueue_style( 'font-awesome' ); wp_enqueue_style( 'anatomy-styles' ); wp_enqueue_style( 'skins-default' ); } add_action( 'wp_enqueue_scripts', 'anatomy_css' ); /* Add custom thumbnails Detects actual thumbnail, then first image (external or attachment) ================================! */ function anatomy_post_thumbnail() { global $post_id; $post_thumbnail = get_the_post_thumbnail( $post_id, 'thumbnail' ); if ( empty( $post_thumbnail ) ) { // If the thumbnail isn't set, try to get the first image or just use the default global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('//i', $post->post_content, $matches); $first_img_url = isset( $matches[1][0] ) ? $matches[1][0] : null; $attachment_id = get_attachment_id_from_src( $first_img_url ); $first_img = !empty( $attachment_id ) ? wp_get_attachment_thumb_url( $attachment_id ) : null; if ( empty( $attachment_id ) and !empty( $first_img_url ) ) { // External URL $first_img = $first_img_url; } elseif ( empty( $first_img ) ) { // No images at all $first_img = null; } $post_thumbnail = $first_img ? ''. $first_img . '' : null; } return $post_thumbnail; } function get_attachment_id_from_src( $image_src ) { global $wpdb; $query = 'SELECT ID FROM `' . $wpdb->posts . '` WHERE guid="' . $image_src . '"'; $id = $wpdb->get_var( $wpdb->prepare( $query ) ); return $id; } /* Get the comment count. ================================! */ function anatomy_comment_count( $button = true ) { $num_comments = get_comments_number(); // get_comments_number returns only a numeric value if ( comments_open() ) { if ( $num_comments == 0 ) { $comment_icon = 'comment-alt'; $comments = __('No Comments', 'anatomy-lite'); } elseif ( $num_comments > 1 ) { $comment_icon = 'comments'; $comments = $num_comments . __(' Comments', 'anatomy-lite'); } else { $comment_icon = 'comment'; $comments = __('1 Comment', 'anatomy-lite'); } if ( $button ) { $write_comments = ' '. $comments.''; } else { $write_comments = ' '. $comments.''; } } else { $write_comments = __('', 'anatomy-lite'); } echo $write_comments; } /* Register sidebars ================================! */ register_sidebar( array( 'name' => __( 'Sidebar', 'anatomy-lite' ), 'id' => 'normal-sidebar', 'description' => __( 'Widgets in this area will be shown as the default sidebar.', 'anatomy-lite' ), 'before_title' => '

', 'after_title' => '

' ) ); register_sidebar( array( 'name' => __( 'Footer Widgets', 'anatomy-lite' ), 'id' => 'footer-widgets', 'description' => __( 'Widgets in this area will be shown in the footer of every page.', 'anatomy-lite' ), 'before_title' => '

', 'after_title' => '

', 'before_widget' => '
', 'after_widget' => '
' ) ); /* Add options page ================================! */ function anatomy_current_tab( $default = 'engage' ) { if ( isset( $_GET['tab'] ) && $_GET['tab'] ) { return $_GET['tab']; } else { return $default; } } function register_anatomy_options_page() { add_theme_page( 'Theme Options', 'Theme Options', 'edit_theme_options', 'theme_options', 'anatomy_theme_options_function' ); } function anatomy_theme_options_function() { require_once( get_template_directory() . '/theme-options.php' ); } add_action( 'admin_menu', 'register_anatomy_options_page' ); function anatomy_options( $setting = null, $default = null ) { $options = get_option( 'anatomy_options' ); if ( !empty( $setting ) ) { // If options have EVER been saved... default better be false. if ( !empty($options) and $default == 'true' ) { // Adding $default == true means that we're only overriding the default on boolean values $default = false; } // If array, let's dig deeper $bracket = strpos( $setting, '[' ); if ( $bracket !== false ) { // First option... $first = substr( $setting, 0, $bracket ); // Set the new Options variable to this... $options = isset ( $options[ $first ] ) ? $options[ $first ] : null; // Get and set the new Settings call to the subsetting if ( $options ) { $length = (strlen( $first ) + 1); $sub = substr( $setting, $length, -1 ); $setting = $sub; } } if ( $options ) { // Options wasn't null $single_option = isset( $options[ $setting ] ) ? $options[ $setting ] : ( !empty( $default ) ? $default : false ); } else { $single_option = $default; } return $single_option; } else { return !empty( $options ) ? $options : array() ; } } // Add options settings function register_anatomy_settings() { /* functions.php Register Comments Options ================================================== */ add_settings_section( 'anatomy_comments_section', 'Customize Comments', 'anatomy_comments_function', 'anatomy_engage_options' ); add_settings_field( 'anatomy_comments_intro_field', 'Message to show before comments', 'anatomy_comments_intro_function', 'anatomy_engage_options', 'anatomy_comments_section' ); register_setting( 'anatomy_engage_options', 'anatomy_options', 'anatomy_options_validate' ); } add_action( 'admin_init', 'register_anatomy_settings' ); /* For saving tabs & checkboxes ================================================== */ function anatomy_options_validate( $input ) { $options = anatomy_options(); // Check for false checkboxes ( makes checkboxes work with tabs ) if ( isset( $input['checkbox'] ) and is_array( $input['checkbox'] ) ) { foreach ( $input['checkbox'] as $key => $checkboxes ) { if ( is_array( $checkboxes ) ) { foreach ( $checkboxes as $key => $ckbx ) { if ( !isset( $input[ $key ] ) || $input[ $key ] == false || $input[ $key ] == null ) { $input[ $key ] = 'false'; } } } else { if ( !isset( $input[ $key ] ) || $input[ $key ] == false || $input[ $key ] == null ) { $input[ $key ] = 'false'; } } } unset( $input['checkbox'] ); } if ( is_array( $input ) and !empty( $input ) ) { // Just update what's here, OK? foreach ( $input as $key => $changed ) { $options[$key] = $changed; } } return $options; } /* Register Options ================================================== */ include( 'functions/options.php' ); // And, here's the upgrade page function register_anatomy_upgrade() { add_theme_page( 'Upgrade', 'Upgrade', 'edit_theme_options', 'theme_upgrade', 'anatomy_theme_upgrade_function' ); } add_action( 'admin_menu', 'register_anatomy_upgrade' ); function anatomy_theme_upgrade_function() { require_once( get_template_directory() . '/upgrade.php' ); } // Custom Pagination functions function anatomy_pagination() { global $wp_query; $total = $wp_query->max_num_pages; $current = $wp_query->query_vars['paged'] > 1 ? $wp_query->query_vars['paged'] : 1; if ( is_search() ) { // Searches need a special format... $base = get_search_link() . '/' . '%_%'; } elseif ( substr( get_pagenum_link(1), -1) != '/' ) { $base = get_pagenum_link(1) . '/%_%'; } else { $base = get_pagenum_link(1) . '%_%'; } $pages = paginate_links( array( 'base' => $base, 'total' => $total, 'current' => $current, 'prev_text' => '', 'next_text' => '', 'format' => 'page/%#%/', 'type' => 'array' ) ); $paginate = ''; echo $paginate; } // Customize the WYSIWYG include( 'functions/wysiwyg.php' ); // Customize the comments include( 'functions/comments.php' ); // Add shortcodes (icons only) include( 'functions/shortcodes.php' ); // Create a fallback for default menus when the theme is first activated function anatomy_default_menu( $args ) { $all_pages = get_pages(); $current_page_id = get_the_ID(); extract( $args ); $list = ''; echo $list; }