codice:
<?php /** * @package WordPress * @subpackage Kassyopea */ // define the text domain location for the theme define( 'TEXTDOMAIN', 'yiw' ); define( 'ENABLE_IMPORT', 1 ); define( 'DEFAULT_COLOR_SET', '#A10404' ); define( 'DEFAULT_FONT', 'champagne' ); // Make theme available for translation // Translations can be filed in the /languages/ directory load_theme_textdomain(TEXTDOMAIN, TEMPLATEPATH . '/languages'); /** * Set the content width based on the theme's design and stylesheet. * * Used to set the width of images and content. Should be equal to the width the theme * is designed for, generally via the style.css stylesheet. */ if ( ! isset( $content_width ) ) $content_width = 558; function warning_version_wp() { global $theme_update_notice, $pagenow; //if ( $pagenow == "themes.php") { ?> <div id="message" class="error fade"> <?php _e( 'The theme you are using requires WordPress version 3.0 or higher. So, many features of it will not perform correctly.', TEXTDOMAIN ) ?> </div> <?php //} } $shortname = "bc"; if( version_compare($wp_version, "3.0", "<") ) add_action('admin_notices', 'warning_version_wp'); $color_theme = (get_option('theme_color') != '') ? get_option('theme_color') : "red"; if(isset($_COOKIE['color_theme_bc'])) $color_theme = strtolower($_COOKIE['color_theme_bc']); $actual_font = get_option( $shortname . '_font', DEFAULT_FONT ); // default theme setup function beauty_setup() { // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style( 'css/editor-style.css' ); // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); // This theme uses the menues add_theme_support( 'menus' ); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); // Post Format support. //add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); if ( ! defined( 'BACKGROUND_IMAGE' ) ) define( 'BACKGROUND_IMAGE', '%s/images/bg.jpg' ); if ( ! defined( 'BACKGROUND_COLOR' ) ) define( 'BACKGROUND_COLOR', 'F0F1F1' ); if ( ! get_theme_mod( 'background_repeat', false ) ) set_theme_mod( 'background_repeat', 'no-repeat' ); if ( ! get_theme_mod( 'background_position_x', false ) ) set_theme_mod( 'background_position_x', 'center' ); // This theme allows users to set a custom background add_custom_background(); // Your changeable header business starts here if ( ! defined( 'HEADER_TEXTCOLOR' ) ) define( 'HEADER_TEXTCOLOR', '' ); // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI. if ( ! defined( 'HEADER_IMAGE' ) ) define( 'HEADER_IMAGE', '%s/images/slideshow/005.jpg' ); // The height and width of your custom header. You can hook into the theme's own filters to change these values. // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'yiw_header_image_width', 864 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'yiw_header_image_height', 319 ) ); // We'll be using post thumbnails for custom header images on posts and pages. // We want them to be 940 pixels wide by 198 pixels tall. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. //set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Don't support text inside the header image. if ( ! defined( 'NO_HEADER_TEXT' ) ) define( 'NO_HEADER_TEXT', true ); // Add a way for the custom header to be styled in the admin panel that controls // custom headers. See twentyten_admin_header_style(), below. add_custom_image_header( '', 'yiw_admin_header_style' ); // ... and thus ends the changeable header business. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( array( 'sea' => array( 'url' => '%s/images/slideshow/001.jpg', 'thumbnail_url' => '%s/images/slideshow/001-thumb.png', /* translators: header image description */ 'description' => __( 'Sea', TEXTDOMAIN ) ), 'flowers' => array( 'url' => '%s/images/slideshow/002.jpg', 'thumbnail_url' => '%s/images/slideshow/002-thumb.png', /* translators: header image description */ 'description' => __( 'Flowers', TEXTDOMAIN ) ), 'portrait' => array( 'url' => '%s/images/slideshow/003.jpg', 'thumbnail_url' => '%s/images/slideshow/003-thumb.png', /* translators: header image description */ 'description' => __( 'Portrait', TEXTDOMAIN ) ), 'hearth' => array( 'url' => '%s/images/slideshow/004.jpg', 'thumbnail_url' => '%s/images/slideshow/004-thumb.png', /* translators: header image description */ 'description' => __( 'Heart', TEXTDOMAIN ) ), 'black-white' => array( 'url' => '%s/images/slideshow/005.jpg', 'thumbnail_url' => '%s/images/slideshow/005-thumb.png', /* translators: header image description */ 'description' => __( 'Black & White', TEXTDOMAIN ) ) ) ); $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 more locations. register_nav_menus( array( 'nav' => __( 'Navigation' ) ) ); // images size add_image_size( 'team-thumb', 100, 100 ); add_image_size( 'thumb-recentposts', 55, 55, true ); // for shortcode add_image_size( 'portfolio-thumb', 280, 149 ); add_image_size( 'portfolio-thumb-slider', 193, 118, true ); add_image_size( 'portfolio-thumb-gallery', 179, 179, true ); // sidebars registers register_sidebar( sidebar_args( 'Blog Sidebar', __( 'The sidebar showed on page with Blog template', TEXTDOMAIN ) ) ); register_sidebar( sidebar_args( 'Home Row', __( 'The row below home content.', TEXTDOMAIN ), 'one-third', 'h2' ) ); // add sidebar created from plugin if( get_option( $GLOBALS['shortname'] . '_sidebars' ) ) { $sidebars = unserialize( get_option( $GLOBALS['shortname'] . '_sidebars' ) ); foreach( $sidebars AS $sidebar ) { register_sidebar( sidebar_args( $sidebar, '', 'widget', 'h2' ) ); } } // add custom style add_action( 'wp_head', 'yiw_custom_style', 999 ); // add custom js add_action( 'wp_footer', 'yiw_custom_js', 999 ); } add_action( 'after_setup_theme', 'beauty_setup' ); /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. * * To override this in a child theme, remove the filter and optionally add * your own function tied to the wp_page_menu_args filter hook. * * @since Twenty Ten 1.0 */ function yiw_page_menu_args( $args ) { $args['show_home'] = true; $args['menu_class'] = 'menu'; return $args; } add_filter( 'wp_page_menu_args', 'yiw_page_menu_args' ); $theme_modules = array( dirname(__FILE__) . '/../includes/colors.php', dirname(__FILE__) . '/../includes/fonts.php', dirname(__FILE__) . '/../admin-options/yiw_panel.php', dirname(__FILE__) . '/../admin-options/notifier/update-notifier.php', dirname(__FILE__) . '/../admin-options/backend.php', dirname(__FILE__) . '/../admin-options/metaboxes.php', dirname(__FILE__) . '/../admin-options/dashboard.php', //dirname(__FILE__) . '/../admin-options/tinymce/tinymce.php', dirname(__FILE__) . '/../includes/widgets/widgets.php', dirname(__FILE__) . '/../includes/shortcodes.php', dirname(__FILE__) . '/../includes/sendemail.php' ); function yiw_custom_style() { string_( '<style type="text/css">', stripslashes_deep( get_option( $GLOBALS['shortname'] . '_custom_style', '' ) ), '</style>' ); } function yiw_custom_js() { string_( '<script type="text/javascript">', stripslashes_deep( get_option( $GLOBALS['shortname'] . '_custom_js', '' ) ), '</script>' ); } function sidebar_args( $name, $description = '', $widget_class = 'widget', $title = 'h3' ) { $id = strtolower( str_replace( ' ', '-', $name ) ); return array( 'name' => $name, 'id' => $id, 'description' => $description, 'before_widget' => '<div id="%1$s" class="' . $widget_class . ' %2$s">', 'after_widget' => '</div>', 'before_title' => '<' . $title . '>', 'after_title' => '</' . $title . '>', ); } if ( ! function_exists( 'yiw_admin_header_style' ) ) : /** * Styles the header image displayed on the Appearance > Header admin panel. * * Referenced via add_custom_image_header() in twentyten_setup(). * * @since Twenty Ten 1.0 */ function yiw_admin_header_style() { ?> <style type="text/css"> /* Shows the same border as on front end */ #headimg { border-bottom: 1px solid #000; border-top: 4px solid #000; } /* If NO_HEADER_TEXT is false, you would style the text with these selectors: #headimg #name { } #headimg #desc { } */ </style> <?php } endif; // add lightbox to the gallery function yiw_add_lightbox( $html, $id, $size, $permalink, $icon, $text ) { if ( ! $permalink ) return str_replace( '<a', '<a rel="prettyPhoto[gallery]"', $html ); else return $html; } add_filter( 'wp_get_attachment_link', 'yiw_add_lightbox', 10, 6 ); // sort array function subval_sort($a, $subkey) { if( is_array($a) AND !empty($a) ) { foreach($a as $k => $v) { $b[$k] = strtolower( $v[$subkey] ); } asort($b); foreach($b as $key => $val) { $c[] = $a[$key]; } return $c; } return $a; } $message = ''; // set of icons $icons_name = array( 'bag', 'box', 'bubble', 'bulb', 'calendar', 'cart', 'chart', 'clipboard', 'coffee', 'diagram', 'doodles', 'gear', 'gift', 'globe', 'info', 'label', 'letter', 'moleskine', 'monitor', 'mphone', 'new', 'open', 'pc', 'pencil', 'phone', 'pictures', 'postit', 'qmark', 'refresh', 'shopbag', 'statistics', 'testimonial', 'tick', 'bag-grey', 'card-grey', 'cart-grey', 'mail-grey', 'pencil-grey', 'phone-grey', 'users-grey' ); // tags for text $tags_allowed = array( 'name_site' => get_bloginfo('name'), 'description_site' => get_bloginfo('description'), 'site_url' => site_url(), 'date' => date_i18n( get_option('date_format'), time() ) ); // include theme modules foreach ( $theme_modules as $module ) if ( file_exists( $module ) ) include_once $module; unset( $module ); function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=['"]([^'"]+)['"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = get_stylesheet_directory_uri()."/images/default.gif"; } return $first_img; }