Advertisement
downloadtaky

Appartamenti Acquario Functions.php

Mar 22nd, 2011
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.43 KB | None | 0 0
  1. <?php
  2. /**
  3.  * AppartamentiAcquario functions and definitions
  4.  *
  5.  * Sets up the theme and provides some helper functions. Some helper functions
  6.  * are used in the theme as custom template tags. Others are attached to action and
  7.  * filter hooks in WordPress to change core functionality.
  8.  *
  9.  * The first function, appaqua_setup(), sets up the theme by registering support
  10.  * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  11.  *
  12.  * When using a child theme (see http://codex.wordpress.org/Theme_Development and
  13.  * http://codex.wordpress.org/Child_Themes), you can override certain functions
  14.  * (those wrapped in a function_exists() call) by defining them first in your child theme's
  15.  * functions.php file. The child theme's functions.php file is included before the parent
  16.  * theme's file, so the child theme functions would be used.
  17.  *
  18.  * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  19.  * to a filter or action hook. The hook can be removed by using remove_action() or
  20.  * remove_filter() and you can attach your own function to the hook.
  21.  *
  22.  * We can remove the parent theme's hook only after it is attached, which means we need to
  23.  * wait until setting up the child theme:
  24.  *
  25.  * <code>
  26.  * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  27.  * function my_child_theme_setup() {
  28.  *     // We are providing our own filter for excerpt_length (or using the unfiltered value)
  29.  *     remove_filter( 'excerpt_length', 'appaqua_excerpt_length' );
  30.  *     ...
  31.  * }
  32.  * </code>
  33.  *
  34.  * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  35.  *
  36.  * @package Appartamenti Acquario
  37.  * @subpackage Appartamenti_Acquario
  38.  * @since Appartamenti Acquario 1.0
  39.  */
  40.  
  41. /**
  42.  * Set the content width based on the theme's design and stylesheet.
  43.  *
  44.  * Used to set the width of images and content. Should be equal to the width the theme
  45.  * is designed for, generally via the style.css stylesheet.
  46.  */
  47. if ( ! isset( $content_width ) )
  48.     $content_width = 640;
  49.  
  50. /** Tell WordPress to run appaqua_setup() when the 'after_setup_theme' hook is run. */
  51. add_action( 'after_setup_theme', 'appaqua_setup' );
  52.  
  53. if ( ! function_exists( 'appaqua_setup' ) ):
  54. /**
  55.  * Sets up theme defaults and registers support for various WordPress features.
  56.  *
  57.  * Note that this function is hooked into the after_setup_theme hook, which runs
  58.  * before the init hook. The init hook is too late for some features, such as indicating
  59.  * support post thumbnails.
  60.  *
  61.  * To override appaqua_setup() in a child theme, add your own appaqua_setup to your child theme's
  62.  * functions.php file.
  63.  *
  64.  * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
  65.  * @uses register_nav_menus() To add support for navigation menus.
  66.  * @uses add_custom_background() To add support for a custom background.
  67.  * @uses add_editor_style() To style the visual editor.
  68.  * @uses load_theme_textdomain() For translation/localization support.
  69.  * @uses add_custom_image_header() To add support for a custom header.
  70.  * @uses register_default_headers() To register the default custom header images provided with the theme.
  71.  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  72.  *
  73.  * @since Appartamenti Acquario 1.0
  74.  */
  75. function appaqua_setup() {
  76.  
  77.     // This theme styles the visual editor with editor-style.css to match the theme style.
  78.     add_editor_style();
  79.  
  80.     // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
  81.     add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
  82.  
  83.     // This theme uses post thumbnails
  84.     add_theme_support( 'post-thumbnails' );
  85.  
  86.     // Add default posts and comments RSS feed links to head
  87.     add_theme_support( 'automatic-feed-links' );
  88.  
  89.     // Make theme available for translation
  90.     // Translations can be filed in the /languages/ directory
  91.     load_theme_textdomain( 'appaqua', TEMPLATEPATH . '/languages' );
  92.  
  93.     $locale = get_locale();
  94.     $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  95.     if ( is_readable( $locale_file ) )
  96.         require_once( $locale_file );
  97.  
  98.     // This theme uses wp_nav_menu() in one location.
  99.     register_nav_menus( array(
  100.         'primary' => __( 'Primary Navigation', 'appaqua' ),
  101.     ) );
  102.  
  103.     // This theme allows users to set a custom background
  104.     add_custom_background();
  105.  
  106.     // Your changeable header business starts here
  107.     if ( ! defined( 'HEADER_TEXTCOLOR' ) )
  108.         define( 'HEADER_TEXTCOLOR', '' );
  109.  
  110.     // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
  111.     if ( ! defined( 'HEADER_IMAGE' ) )
  112.         define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
  113.  
  114.     // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  115.     // Add a filter to appaqua_header_image_width and appaqua_header_image_height to change these values.
  116.     define( 'HEADER_IMAGE_WIDTH', apply_filters( 'appaqua_header_image_width', 940 ) );
  117.     define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'appaqua_header_image_height', 198 ) );
  118.  
  119.     // We'll be using post thumbnails for custom header images on posts and pages.
  120.     // We want them to be 940 pixels wide by 198 pixels tall.
  121.     // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  122.     set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  123.  
  124.     // Don't support text inside the header image.
  125.     if ( ! defined( 'NO_HEADER_TEXT' ) )
  126.         define( 'NO_HEADER_TEXT', true );
  127.  
  128.     // Add a way for the custom header to be styled in the admin panel that controls
  129.     // custom headers. See appaqua_admin_header_style(), below.
  130.     add_custom_image_header( '', 'appaqua_admin_header_style' );
  131.  
  132.     // ... and thus ends the changeable header business.
  133.  
  134.     // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  135.     register_default_headers( array(
  136.         'berries' => array(
  137.             'url' => '%s/images/headers/berries.jpg',
  138.             'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  139.             /* translators: header image description */
  140.             'description' => __( 'Berries', 'appaqua' )
  141.         ),
  142.         'cherryblossom' => array(
  143.             'url' => '%s/images/headers/cherryblossoms.jpg',
  144.             'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  145.             /* translators: header image description */
  146.             'description' => __( 'Cherry Blossoms', 'appaqua' )
  147.         ),
  148.         'concave' => array(
  149.             'url' => '%s/images/headers/concave.jpg',
  150.             'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  151.             /* translators: header image description */
  152.             'description' => __( 'Concave', 'appaqua' )
  153.         ),
  154.         'fern' => array(
  155.             'url' => '%s/images/headers/fern.jpg',
  156.             'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  157.             /* translators: header image description */
  158.             'description' => __( 'Fern', 'appaqua' )
  159.         ),
  160.         'forestfloor' => array(
  161.             'url' => '%s/images/headers/forestfloor.jpg',
  162.             'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  163.             /* translators: header image description */
  164.             'description' => __( 'Forest Floor', 'appaqua' )
  165.         ),
  166.         'inkwell' => array(
  167.             'url' => '%s/images/headers/inkwell.jpg',
  168.             'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  169.             /* translators: header image description */
  170.             'description' => __( 'Inkwell', 'appaqua' )
  171.         ),
  172.         'path' => array(
  173.             'url' => '%s/images/headers/path.jpg',
  174.             'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  175.             /* translators: header image description */
  176.             'description' => __( 'Path', 'appaqua' )
  177.         ),
  178.         'sunset' => array(
  179.             'url' => '%s/images/headers/sunset.jpg',
  180.             'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  181.             /* translators: header image description */
  182.             'description' => __( 'Sunset', 'appaqua' )
  183.         )
  184.     ) );
  185. }
  186. endif;
  187.  
  188. if ( ! function_exists( 'appaqua_admin_header_style' ) ) :
  189. /**
  190.  * Styles the header image displayed on the Appearance > Header admin panel.
  191.  *
  192.  * Referenced via add_custom_image_header() in appaqua_setup().
  193.  *
  194.  * @since Appartamenti Acquario 1.0
  195.  */
  196. function appaqua_admin_header_style() {
  197. ?>
  198. <style type="text/css">
  199. /* Shows the same border as on front end */
  200. #headimg {
  201.     border-bottom: 1px solid #000;
  202.     border-top: 4px solid #000;
  203. }
  204. /* If NO_HEADER_TEXT is false, you would style the text with these selectors:
  205.     #headimg #name { }
  206.     #headimg #desc { }
  207. */
  208. </style>
  209. <?php
  210. }
  211. endif;
  212.  
  213. /**
  214.  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  215.  *
  216.  * To override this in a child theme, remove the filter and optionally add
  217.  * your own function tied to the wp_page_menu_args filter hook.
  218.  *
  219.  * @since Appartamenti Acquario 1.0
  220.  */
  221. function appaqua_page_menu_args( $args ) {
  222.     $args['show_home'] = true;
  223.     return $args;
  224. }
  225. add_filter( 'wp_page_menu_args', 'appaqua_page_menu_args' );
  226.  
  227. /**
  228.  * Sets the post excerpt length to 40 characters.
  229.  *
  230.  * To override this length in a child theme, remove the filter and add your own
  231.  * function tied to the excerpt_length filter hook.
  232.  *
  233.  * @since Appartamenti Acquario 1.0
  234.  * @return int
  235.  */
  236. function appaqua_excerpt_length( $length ) {
  237.     return 40;
  238. }
  239. add_filter( 'excerpt_length', 'appaqua_excerpt_length' );
  240.  
  241. /**
  242.  * Returns a "Continue Reading" link for excerpts
  243.  *
  244.  * @since Appartamenti Acquario 1.0
  245.  * @return string "Continue Reading" link
  246.  */
  247. function appaqua_continue_reading_link() {
  248.     return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'appaqua' ) . '</a>';
  249. }
  250.  
  251. /**
  252.  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and appaqua_continue_reading_link().
  253.  *
  254.  * To override this in a child theme, remove the filter and add your own
  255.  * function tied to the excerpt_more filter hook.
  256.  *
  257.  * @since Appartamenti Acquario 1.0
  258.  * @return string An ellipsis
  259.  */
  260. function appaqua_auto_excerpt_more( $more ) {
  261.     return ' &hellip;' . appaqua_continue_reading_link();
  262. }
  263. add_filter( 'excerpt_more', 'appaqua_auto_excerpt_more' );
  264.  
  265. /**
  266.  * Adds a pretty "Continue Reading" link to custom post excerpts.
  267.  *
  268.  * To override this link in a child theme, remove the filter and add your own
  269.  * function tied to the get_the_excerpt filter hook.
  270.  *
  271.  * @since Appartamenti Acquario 1.0
  272.  * @return string Excerpt with a pretty "Continue Reading" link
  273.  */
  274. function appaqua_custom_excerpt_more( $output ) {
  275.     if ( has_excerpt() && ! is_attachment() ) {
  276.         $output .= appaqua_continue_reading_link();
  277.     }
  278.     return $output;
  279. }
  280. add_filter( 'get_the_excerpt', 'appaqua_custom_excerpt_more' );
  281.  
  282. /**
  283.  * Remove inline styles printed when the gallery shortcode is used.
  284.  *
  285.  * Galleries are styled by the theme in Appartamenti Acquario's style.css. This is just
  286.  * a simple filter call that tells WordPress to not use the default styles.
  287.  *
  288.  * @since Appartamenti Acquario 1.0
  289.  */
  290. add_filter( 'use_default_gallery_style', '__return_false' );
  291.  
  292. /**
  293.  * Deprecated way to remove inline styles printed when the gallery shortcode is used.
  294.  *
  295.  * This function is no longer needed or used. Use the use_default_gallery_style
  296.  * filter instead, as seen above.
  297.  *
  298.  * @since Appartamenti Acquario 1.0
  299.  * @deprecated Deprecated in Appartamenti Acquario 1.2 for WordPress 3.1
  300.  *
  301.  * @return string The gallery style filter, with the styles themselves removed.
  302.  */
  303. function appaqua_remove_gallery_css( $css ) {
  304.     return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  305. }
  306. // Backwards compatibility with WordPress 3.0.
  307. if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
  308.     add_filter( 'gallery_style', 'appaqua_remove_gallery_css' );
  309.  
  310. if ( ! function_exists( 'appaqua_comment' ) ) :
  311. /**
  312.  * Template for comments and pingbacks.
  313.  *
  314.  * To override this walker in a child theme without modifying the comments template
  315.  * simply create your own appaqua_comment(), and that function will be used instead.
  316.  *
  317.  * Used as a callback by wp_list_comments() for displaying the comments.
  318.  *
  319.  * @since Appartamenti Acquario 1.0
  320.  */
  321. function appaqua_comment( $comment, $args, $depth ) {
  322.     $GLOBALS['comment'] = $comment;
  323.     switch ( $comment->comment_type ) :
  324.         case '' :
  325.     ?>
  326.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  327.         <div id="comment-<?php comment_ID(); ?>">
  328.         <div class="comment-author vcard">
  329.             <?php echo get_avatar( $comment, 40 ); ?>
  330.             <?php printf( __( '%s <span class="says">says:</span>', 'appaqua' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  331.         </div><!-- .comment-author .vcard -->
  332.         <?php if ( $comment->comment_approved == '0' ) : ?>
  333.             <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'appaqua' ); ?></em>
  334.             <br />
  335.         <?php endif; ?>
  336.  
  337.         <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  338.             <?php
  339.                 /* translators: 1: date, 2: time */
  340.                 printf( __( '%1$s at %2$s', 'appaqua' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'appaqua' ), ' ' );
  341.             ?>
  342.         </div><!-- .comment-meta .commentmetadata -->
  343.  
  344.         <div class="comment-body"><?php comment_text(); ?></div>
  345.  
  346.         <div class="reply">
  347.             <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  348.         </div><!-- .reply -->
  349.     </div><!-- #comment-##  -->
  350.  
  351.     <?php
  352.             break;
  353.         case 'pingback'  :
  354.         case 'trackback' :
  355.     ?>
  356.     <li class="post pingback">
  357.         <p><?php _e( 'Pingback:', 'appaqua' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'appaqua' ), ' ' ); ?></p>
  358.     <?php
  359.             break;
  360.     endswitch;
  361. }
  362. endif;
  363. /** Here we register the sidebars **/
  364. include (TEMPLATEPATH .'/functions/regsidebar.php');
  365.  
  366. /**
  367.  * Removes the default styles that are packaged with the Recent Comments widget.
  368.  *
  369.  * To override this in a child theme, remove the filter and optionally add your own
  370.  * function tied to the widgets_init action hook.
  371.  *
  372.  * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
  373.  * to remove the default style. Using Appartamenti Acquario 1.2 in WordPress 3.0 will show the styles,
  374.  * but they won't have any effect on the widget in default Appartamenti Acquario styling.
  375.  *
  376.  * @since Appartamenti Acquario 1.0
  377.  */
  378. function appaqua_remove_recent_comments_style() {
  379.     add_filter( 'show_recent_comments_widget_style', '__return_false' );
  380. }
  381. add_action( 'widgets_init', 'appaqua_remove_recent_comments_style' );
  382.  
  383. if ( ! function_exists( 'appaqua_posted_on' ) ) :
  384. /**
  385.  * Prints HTML with meta information for the current post-date/time and author.
  386.  *
  387.  * @since Appartamenti Acquario 1.0
  388.  */
  389. function appaqua_posted_on() {
  390.     printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'appaqua' ),
  391.         'meta-prep meta-prep-author',
  392.         sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
  393.             get_permalink(),
  394.             esc_attr( get_the_time() ),
  395.             get_the_date()
  396.         ),
  397.         sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  398.             get_author_posts_url( get_the_author_meta( 'ID' ) ),
  399.             sprintf( esc_attr__( 'View all posts by %s', 'appaqua' ), get_the_author() ),
  400.             get_the_author()
  401.         )
  402.     );
  403. }
  404. endif;
  405.  
  406. if ( ! function_exists( 'appaqua_posted_in' ) ) :
  407. /**
  408.  * Prints HTML with meta information for the current post (category, tags and permalink).
  409.  *
  410.  * @since Appartamenti Acquario 1.0
  411.  */
  412. function appaqua_posted_in() {
  413.     // Retrieves tag list of current post, separated by commas.
  414.     $tag_list = get_the_tag_list( '', ', ' );
  415.     if ( $tag_list ) {
  416.         $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>.', 'appaqua' );
  417.     } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  418.         $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'appaqua' );
  419.     } else {
  420.         $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'appaqua' );
  421.     }
  422.     // Prints the string, replacing the placeholders.
  423.     printf(
  424.         $posted_in,
  425.         get_the_category_list( ', ' ),
  426.         $tag_list,
  427.         get_permalink(),
  428.         the_title_attribute( 'echo=0' )
  429.     );
  430. }
  431. endif;
  432. ?>
  433. <!-- Qui inizia il pannello di controllo del template -- Here Starts Theme Control Panel -->
  434. <? include (TEMPLATEPATH .'/functions/cpanelfunction.php');?>
  435. <!-- Here we show the thumbnails - Funzione per mostrare la prima immagine nel loop Inizio -->
  436. <?php include ('functions/firstimage.php');?>
  437. <!-- Scritta nel footer del pannello di controllo inizio-->
  438. <?php include ('functions/adminfoot.php');?>
  439. <!-- Per avere i post in visualizzazione Drop Down -->
  440. <?php include('functions/postdropdown.php');?>
  441. <?php /**____________________
  442. Per usare la funzione qui sopra bisogna copiare ed incollare questa stringa dove necessario:
  443.  
  444. <?php
  445. if(function_exists('display_post_selectbox'))
  446. {
  447.   echo display_post_selectbox();
  448. }
  449. ?>
  450. **/
  451. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement