/zentrum_wp_theme/functions.php
PHP | 315 lines | 193 code | 42 blank | 80 comment | 11 complexity | 727934fc47e6eab28b8258a7d7c2f509 MD5 | raw file
- <?php
- /**
- * Starkers functions and definitions
- *
- * @package WordPress
- * @subpackage Starkers
- * @since Starkers HTML5 3.0
- */
- /** Tell WordPress to run starkers_setup() when the 'after_setup_theme' hook is run. */
- add_action( 'after_setup_theme', 'starkers_setup' );
- if ( ! function_exists( 'starkers_setup' ) ):
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_setup() {
- // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
- add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
- // This theme uses post thumbnails
- add_theme_support( 'post-thumbnails' );
- // Add default posts and comments RSS feed links to head
- add_theme_support( 'automatic-feed-links' );
- // Make theme available for translation
- // Translations can be filed in the /languages/ directory
- load_theme_textdomain( 'starkers', TEMPLATEPATH . '/languages' );
- $locale = get_locale();
- $locale_file = TEMPLATEPATH . "/languages/$locale.php";
- if ( is_readable( $locale_file ) )
- require_once( $locale_file );
- // This theme uses wp_nav_menu() in one location.
- register_nav_menus( array(
- 'primary' => __( 'Primary Navigation', 'starkers' ),
- ) );
- }
- endif;
- /**
- * Set our wp_nav_menu() fallback, starkers_menu().
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_menu() {
-
- echo '<nav><ul><li><a href="'.get_bloginfo('url').'">Home</a></li>';
- wp_list_pages('title_li=');
- echo '</ul></nav>';
- }
- /**
- * Remove inline styles printed when the gallery shortcode is used.
- *
- * @since Starkers HTML5 3.2
- */
- add_filter( 'use_default_gallery_style', '__return_false' );
- /**
- * @since Starkers HTML5 3.0
- * @deprecated in Starkers HTML5 3.2 for WordPress 3.1
- *
- * @return string The gallery style filter, with the styles themselves removed.
- */
- function starkers_remove_gallery_css( $css ) {
- return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
- }
- // Backwards compatibility with WordPress 3.0.
- if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
- add_filter( 'gallery_style', 'starkers_remove_gallery_css' );
- if ( ! function_exists( 'starkers_comment' ) ) :
- /**
- * Template for comments and pingbacks.
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_comment( $comment, $args, $depth ) {
- $GLOBALS['comment'] = $comment;
- switch ( $comment->comment_type ) :
- case '' :
- ?>
- <article <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
- <?php echo get_avatar( $comment, 40 ); ?>
- <?php printf( __( '%s says:', 'starkers' ), sprintf( '%s', get_comment_author_link() ) ); ?>
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <?php _e( 'Your comment is awaiting moderation.', 'starkers' ); ?>
- <br />
- <?php endif; ?>
- <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
- <?php
- /* translators: 1: date, 2: time */
- printf( __( '%1$s at %2$s', 'starkers' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'starkers' ), ' ' );
- ?>
- <?php comment_text(); ?>
- <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
- <?php
- break;
- case 'pingback' :
- case 'trackback' :
- ?>
- <article <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
- <p><?php _e( 'Pingback:', 'starkers' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'starkers'), ' ' ); ?></p>
- <?php
- break;
- endswitch;
- }
- endif;
- /**
- * Closes comments and pingbacks with </article> instead of </li>.
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_comment_close() {
- echo '</article>';
- }
- /**
- * Adjusts the comment_form() input types for HTML5.
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_fields($fields) {
- $commenter = wp_get_current_commenter();
- $req = get_option( 'require_name_email' );
- $aria_req = ( $req ? " aria-required='true'" : '' );
- $fields = array(
- 'author' => '<p><label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '*' : '' ) .
- '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
- 'email' => '<p><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '*' : '' ) .
- '<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
- 'url' => '<p><label for="url">' . __( 'Website' ) . '</label>' .
- '<input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
- );
- return $fields;
- }
- add_filter('comment_form_default_fields','starkers_fields');
- /**
- * Register widgetized areas.
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_widgets_init() {
- // Area 1, located at the top of the sidebar.
- register_sidebar( array(
- 'name' => __( 'Logo Widget Area', 'starkers' ),
- 'id' => 'logo-widget-area',
- 'description' => __( 'The primary widget area', 'starkers' ),
- 'before_widget' => '<div id="logo">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ) );
- // Area 3, located in the footer. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Footer Widget Area', 'starkers' ),
- 'id' => 'footer-widget-area',
- 'description' => __( 'The first footer widget area', 'starkers' ),
- 'before_widget' => null,
- 'after_widget' => null,
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ) );
- }
- /** Register sidebars by running starkers_widgets_init() on the widgets_init hook. */
- add_action( 'widgets_init', 'starkers_widgets_init' );
- /**
- * Removes the default styles that are packaged with the Recent Comments widget.
- *
- * @updated Starkers HTML5 3.2
- */
- function starkers_remove_recent_comments_style() {
- add_filter( 'show_recent_comments_widget_style', '__return_false' );
- }
- add_action( 'widgets_init', 'starkers_remove_recent_comments_style' );
- if ( ! function_exists( 'starkers_posted_on' ) ) :
- /**
- * Prints HTML with meta information for the current post—date/time and author.
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_posted_on() {
- printf( __( 'Posted on %2$s by %3$s', 'starkers' ),
- 'meta-prep meta-prep-author',
- sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s" pubdate>%4$s</time></a>',
- get_permalink(),
- esc_attr( get_the_time() ),
- get_the_date('Y-m-d'),
- get_the_date()
- ),
- sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
- get_author_posts_url( get_the_author_meta( 'ID' ) ),
- sprintf( esc_attr__( 'View all posts by %s', 'starkers' ), get_the_author() ),
- get_the_author()
- )
- );
- }
- endif;
- if ( ! function_exists( 'starkers_posted_in' ) ) :
- /**
- * Prints HTML with meta information for the current post (category, tags and permalink).
- *
- * @since Starkers HTML5 3.0
- */
- function starkers_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 <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'starkers' );
- } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
- $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'starkers' );
- } else {
- $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'starkers' );
- }
- // Prints the string, replacing the placeholders.
- printf(
- $posted_in,
- get_the_category_list( ', ' ),
- $tag_list,
- get_permalink(),
- the_title_attribute( 'echo=0' )
- );
- }
- endif;
- // zentrum_categories function
-
- function zentrum_categories() { $pages = get_pages('sort_column=menu_order&title_li=');
- $i=1;
- foreach($pages as $page_data) {
- $content = apply_filters('the_content', $page_data->post_content);
- $title = $page_data->post_title;
- echo "<div class='item'><a href='#' name='content$i'>";
- echo "<div class='design-button' id='meny$i' style='background-color: " .get_option('zentrum_color'.$i.''). "'><span class='menybutton'>";
- echo '<p>' .$title .'</p>';
- echo "</span></div></a></div>";
- $i++;
- }
- }
-
- // zentrum_categories_page function
- function zentrum_categories_page() {$pages = get_pages('sort_column=menu_order&title_li=');
- $i=1;
- foreach($pages as $page_data) {
- $content = apply_filters('the_content', $page_data->post_content);
- $title = $page_data->post_title;
- echo "<div class='item'><a href='#' name='content$i'>";
- echo "<div id=\"innhold_meny_tekst\" style='background-color: " .get_option('zentrum_color'.$i.''). "'>";
- echo $title;
- echo "</div></a></div>";
- $i++;
- }
- }
-
-
-
- //zentrum_pages_all
- function zentrum_all() { $pages = get_pages('sort_column=menu_order&title_li=');
- $i=1;
- foreach ($pages as $page_data) {
- $content = apply_filters('the_content', $page_data->post_content);
- $title = $page_data->post_title;
- $title = strtoupper($title);
- echo "<span class=\"item\" id=\"content$i\" style=\"display: none;\">
- <div class=\"innhold_fix\">
- <div id=\"innhold_meny\">";
- echo zentrum_categories_page($args);
- echo "</div>";
- echo "<div id=\"innhold\" style='background-color: " .get_option('zentrum_color'.$i.''). "'>
- <div id=\"innhold_current\">";
- echo $title;
- echo "</div>
- <div id=\"innhold_info\">
- ";
- echo $content; // Skrive ut innhold
- echo "</div>
- <div id=\"innhold_player\">
- <iframe width=\"439\" height=\"308\" src=\"http://www.youtube.com/embed/4PkcfQtibmU\" frameborder=\"0\" allowfullscreen></iframe>
- </div>
- </div>
- </div>
- </span>";
- $i++;
- }
- }
- include ("zentrum_options_plugin.php");
- include ("zentrum_page_order.php");