HEX
Server: Apache
System: Linux webd003.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: slyfwmm (169339)
PHP: 8.1.34
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/slyfwmm/incastiglionfiorentino/wp-content/themes/amplify/functions.php
<?php

/* @package WordPress ***********************************************
 * @subpackage Amplify **********************************************
 
   index 

   - misc
   - shortcodes
   - theme options
   - custom write panels for post
   - custom write panels for page
   - register sidebars & widgets

*/
/*** MISC **********************************************************/
function my_init() {
	if (!is_admin()) {
		// comment out the next two lines to load the local copy of jQuery
		wp_deregister_script('jquery');
		wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js', false, '1.6.0');
		wp_enqueue_script('jquery');
	}
}
add_action('init', 'my_init');



/* The following takes care of the mysterious disappearing content bug that happens when too many shortcodes are used on a page. Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553 */
@ini_set('pcre.backtrack_limit', 500000);

/* The following code removes the automatic <br> and <p> tags that wordpress automatically inserts around shortcodes without disrupting the rest of the tags generated in the post boxes */
if ( !function_exists('webtreats_formatter') ) :

function webtreats_formatter($content) {
	$new_content = '';
	
	/* Matches the contents and the open and closing tags */
	$pattern_full = '{(\[raw\].*?\[/raw\])}is';
	
	/* Matches just the contents */
	$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
	
	/* Divide content into pieces */
	$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
	
	/* Loop over pieces */
	foreach ($pieces as $piece) {
		/* Look for presence of the shortcode */
		if (preg_match($pattern_contents, $piece, $matches)) {
			
			/* Append to content (no formatting) */
			$new_content .= $matches[1];
		} else {
			
			/* Format and append to content */
			$new_content .= wptexturize(wpautop($piece));		
		}
	}
	
	return $new_content;
}

// Remove the 2 main auto-formatters
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');

// Before displaying for viewing, apply this function
add_filter('the_content', 'webtreats_formatter', 99);
add_filter('widget_text', 'webtreats_formatter', 99);

endif;
/* end formatting */

// Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu
function add_menuclass($ulclass) {
return preg_replace('/<ul>/', '<ul class="reset dropdown">', $ulclass, 1);
}
add_filter('wp_page_menu','add_menuclass');

/** Customize Excerpt **/
/** Returns a "Continue Reading" link **/
function my_continue_reading_link() {
  return '<br /><a class="more-link" href="'.get_permalink().'">'
    .__('<span><!--:it-->Leggi Tutto<!--:--><!--:en-->Continue Reading<!--:--></span>')
    .'</a>';
}

/** Adds custom "Continue Reading" link to custom post excerpts **/
function my_custom_excerpt_more($output) {
  if (has_excerpt() && !is_attachment()) {
    $output.=my_continue_reading_link();
  }
  return $output;
}
add_filter('get_the_excerpt', 'my_custom_excerpt_more' );

/* custom nav menus */
add_theme_support( 'menus' );

/* 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 = 600;

/* Functions and definitions
 * Sets up the theme and provides some helper functions. Some helper functions
 * The first function, bb_setup(), sets up the theme by registering support 
   for various features in WordPress, such as post thumbnails, navigation menus, and the like. */

/* Tell WordPress to run bb_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'bb_setup' );

if ( ! function_exists( 'bb_setup' ) ):

function bb_setup() {

	// This theme styles the visual editor with editor-style.css to match the theme style.
	add_editor_style();

	// 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( 'amplify', 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', 'amplify' ),
	) );

}
endif;

function wpb_custom_new_menu() {
	register_nav_menus(
	array(
	'my-custom-menu' => __( 'My Custom Menu' ),
	'extra-menu' => __( 'Extra Menu' )
	)
);
}
add_action( 'init', 'wpb_custom_new_menu' );

/* Makes some changes to the <title> tag, by filtering the output of wp_title(). */
function amplify_filter_wp_title( $title, $separator ) {
	// Don't affect wp_title() calls in feeds.
	if ( is_feed() )
		return $title;

	// The $paged global variable contains the page number of a listing of posts.
	// The $page global variable contains the page number of a single post that is paged.
	// We'll display whichever one applies, if we're not looking at the first page.
	global $paged, $page;

	if ( is_search() ) {
		// If we're a search, let's start over:
		$title = sprintf( __( 'Search results for %s', 'amplify' ), '"' . get_search_query() . '"' );
		// Add a page number if we're on page 2 or more:
		if ( $paged >= 2 )
			$title .= " $separator " . sprintf( __( 'Page %s', 'amplify' ), $paged );
		// Add the site name to the end:
		$title .= " $separator " . get_bloginfo( 'name', 'display' );
		// We're done. Let's send the new title back to wp_title():
		return $title;
	}

	// Otherwise, let's start by adding the site name to the end:
	$title .= get_bloginfo( 'name', 'display' );

	// If we have a site description and we're on the home/front page, add the description:
	$site_description = get_bloginfo( 'description', 'display' );
	if ( $site_description && ( is_home() || is_front_page() ) )
		$title .= " $separator " . $site_description;

	// Add a page number if necessary:
	if ( $paged >= 2 || $page >= 2 )
		$title .= " $separator " . sprintf( __( 'Page %s', 'amplify' ), max( $paged, $page ) );

	// Return the new title to wp_title():
	return $title;
}
add_filter( 'wp_title', 'amplify_filter_wp_title', 10, 2 );

/*** END MISC ******************************************************/


/*** SHORTCODES BEGIN **********************************************/
function alert_green($atts, $content = null) {
	return'<div class="alert_green">' . $content . '</div>';
}
add_shortcode('alert_green', 'alert_green');

function alert_blue($atts, $content = null) {
	return'<div class="alert_blue">' . $content . '</div>';
}
add_shortcode('alert_blue', 'alert_blue');

function alert_yellow($atts, $content = null) {
	return'<div class="alert_yellow">' . $content . '</div>';
}
add_shortcode('alert_yellow', 'alert_yellow');

function alert_red($atts, $content = null) {
	return'<div class="alert_red">' . $content . '</div>';
}
add_shortcode('alert_red', 'alert_red');

function button_small($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" => 'https://'
	), $atts));
	return'<div class="button_small"><h5 class="regcase"><a href="' . $href . '" title="button">' . $content . '</a></h5></div>';
}
add_shortcode('button_small', 'button_small');

function button($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" => 'https://'
	), $atts));
	return'<div class="button"><h5 class="regcase"><a href="' . $href . '" title="button">' . $content . '</a></h5></div>';
}
add_shortcode('button', 'button');

function button_large($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" => 'https://'
	), $atts));
	return'<div class="button_large"><h5 class="regcase"><a href="' . $href . '" title="button">' . $content . '</a></h5></div>';
}
add_shortcode('button_large', 'button_large');

function highlight_yellow($atts, $content = null) {
	return'<span class="highlight_yellow">' . $content . '</span>';
}
add_shortcode('highlight_yellow', 'highlight_yellow');

function highlight_green($atts, $content = null) {
	return'<span class="highlight_green">' . $content . '</span>';
}
add_shortcode('highlight_green', 'highlight_green');

function highlight_blue($atts, $content = null) {
	return'<span class="highlight_blue">' . $content . '</span>';
}
add_shortcode('highlight_blue', 'highlight_blue');

function highlight_gray($atts, $content = null) {
	return'<span class="highlight_gray">' . $content . '</span>';
}
add_shortcode('highlight_gray', 'highlight_gray');

function highlight_black($atts, $content = null) {
	return'<span class="highlight_black">' . $content . '</span>';
}
add_shortcode('highlight_black', 'highlight_black');

function dropcapcircle($atts, $content = null) {
	return'<span class="dropcapcircle">' . $content . '</span>';
}
add_shortcode('dropcapcircle', 'dropcapcircle');

function dropcap($atts, $content = null) {
	return'<span class="dropcap">' . $content . '</span>';
}
add_shortcode('dropcap', 'dropcap');

function checklist($atts, $content = null) {
	return'<ul class="check">' . $content . '</ul>';
}
add_shortcode('checklist', 'checklist');

function bigarrow($atts, $content = null) {
	return'<ul class="bigarrow">' . $content . '</ul>';
}
add_shortcode('bigarrow', 'bigarrow');

function tinyarrow($atts, $content = null) {
	return'<ul class="tinyarrow">' . $content . '</ul>';
}
add_shortcode('tinyarrow', 'tinyarrow');

function wedge($atts, $content = null) {
	return'<ul class="wedge">' . $content . '</ul>';
}
add_shortcode('wedge', 'wedge');

function dot($atts, $content = null) {
	return'<ul class="dot">' . $content . '</ul>';
}
add_shortcode('dot', 'dot');

function pullright($atts, $content = null) {
	return'<span class="pullright">' . $content . '</span>';
}
add_shortcode('pullright', 'pullright');

function pullleft($atts, $content = null) {
	return'<span class="pullleft">' . $content . '</span>';
}
add_shortcode('pullleft', 'pullleft');

function magnify($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" => 'https://'
	), $atts));
	return '<div class="mag"><a href="' . $href . '" rel="example1"><img src="' . $content . '" alt="magnify image" /></a></div>';
}
add_shortcode('magnify', 'magnify');

function imageright($atts, $content = null) {
	return '<img class="imageright" src="' . $content . '" alt="image right" />';
}
add_shortcode('imageright', 'imageright');

function imageleft($atts, $content = null) {
	return '<img class="imageleft" src="' . $content . '" alt="image left" />';
}
add_shortcode('imageleft', 'imageleft');

function captionleft($atts, $content = null) {
	extract(shortcode_atts(array(
		"caption" => ''
	), $atts));
	return '<div class="blockleft"><img src="' . $content . '" alt="image with caption" /><p class="caption">' . $caption . '</p></div>';
}
add_shortcode('captionleft', 'captionleft');

function captionleftlink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" => '',
		"caption" => ''
	), $atts));
	return '<div class="blockleft"><a href="' . $href . '" rel="example1" title="image"><img src="' . $content . '" alt="image with caption" /></a><p class="caption">' . $caption . '</p></div>';
}
add_shortcode('captionleftlink', 'captionleftlink');

function captionright($atts, $content = null) {
	extract(shortcode_atts(array(
		"caption" => ''
	), $atts));
	return '<div class="blockright"><img src="' . $content . '" alt="image with caption" /><p class="caption">' . $caption . '</p></div>';
}
add_shortcode('captionright', 'captionright');

function captionrightlink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" => '',
		"caption" => ''
	), $atts));
	return '<div class="blockright"><a href="' . $href . '" rel="example1" title="image"><img src="' . $content . '" alt="image with caption" /></a><p class="caption">' . $caption . '</p></div>';
}
add_shortcode('captionrightlink', 'captionrightlink');


/** Column Shortcodes **/

function box_3_4($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_3_4 ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_3_4', 'box_3_4');

function box_half($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_half ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_half', 'box_half');

function box_2_3($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_2_3 ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_2_3', 'box_2_3');

function box_2_5($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_2_5 ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_2_5', 'box_2_5');

function box_third($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_third ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_third', 'box_third');

function box_quarter($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_quarter ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_quarter', 'box_quarter');

function box_fifth($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_fifth ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_fifth', 'box_fifth');

function box_sixth($atts, $content = null) {
	extract(shortcode_atts(array(
		"class" => ''
	), $atts));
	return '<div class="box_sixth ' . $class . '">' . $content . '</div>';
}
add_shortcode('box_sixth', 'box_sixth');

function clear($atts, $content = null) {
	return '<div class="clear"></div>';
}
add_shortcode('clear', 'clear');

/*** END SHORTCODES **********************************************************/


/*** THEME OPTIONS BEGIN **********************************************/
$themename = "Amplify";
$shortname = "bb";

$categories = get_categories('hide_empty=0&orderby=name');
$wp_cats = array();
foreach ($categories as $category_list ) {
       $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
}
array_unshift($wp_cats, "Choose a category"); 

$options = array (
 
array( "name" => $themename." Options",
	"type" => "title"),
 

array( "name" => "General",
	"type" => "section"),
array( "type" => "open"),
 
array( "name" => "Color Scheme",
	"desc" => "Select the color scheme for the theme",
	"id" => $shortname."_color_scheme",
	"type" => "select",
	"options" => array("chrome", "blackberry", "bold", "charcoal", "coffee", "cracked", "dark", "forest", "minimal", "navy", "olive", "orange", "pavement", "plum", "seafoam", "slate", "white"),
	"std" => "charcoal"),

array( "name" => "Logo Url",
	"desc" => "This will overwrite the logo that comes with amplify in header.php",
	"id" => $shortname."_logo_url",
	"type" => "text",
	"std" => ""),

array( "name" => "Footer Logo Url",
	"desc" => "This will overwrite the logo that comes with amplify in footer.php",
	"id" => $shortname."_footer_logo_url",
	"type" => "text",
	"std" => ""),
	
array( "name" => "Portfolio Type",
	"desc" => "Select the portfolio type to use",
	"id" => $shortname."_portfolio",
	"type" => "select",
	"options" => array("medium", "small", "large"),
	"std" => "medium"),
	
array( "name" => "Portfolio Category",
	"desc" => "Enter the category name that will be used in the portfolio. ex: 'portfolio' is used by default.",
	"id" => $shortname."_portfolio_cat",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),
	
array( "name" => "Blog Exclude Categories",
	"desc" => "Set categories to be hidden from the blog. List categories by id# followed by comma. ex: '1,4,8'.  Category # can be found by going to the categoies page under 'Posts', clicking the category and looking at the end of the url which reads 'ID='",
	"id" => $shortname."_exclude_cat",
	"type" => "text",
	"std" => ""),
	
array( "name" => "Blog Posts Per Page",
	"desc" => "The number of posts per page on the blog (default is 5)",
	"id" => $shortname."_blog_posts",
	"type" => "text",
	"std" => ""),

array( "name" => "Enable PrettyPhoto?",
	"desc" => "Would you like to enable PrettyPhoto?",
	"id" => $shortname."_enable_prettyphoto",
	"type" => "select",
	"options" => array("yes", "no"),
	"std" => "yes"),
	
array( "name" => "Google Analytics Code",
	"desc" => "You can paste your Google Analytics or other tracking code in this box. This will be automatically added to the footer.",
	"id" => $shortname."_analytics",
	"type" => "textarea",
	"std" => ""),
	
array( "name" => "Custom Favicon",
	"desc" => "A favicon is a 16x16 pixel icon that represents your site; paste the URL to a .ico image that you want to use as the image",
	"id" => $shortname."_favicon",
	"type" => "text",
	"std" => get_bloginfo('url') ."/favicon.ico"),
	
array( "name" => "Footer Copyright Text",
	"desc" => "Enter text used in the left side of the footer. It can be HTML",
	"id" => $shortname."_footer_text",
	"type" => "text",
	"std" => ""),

	
array( "type" => "close"),
array( "name" => "Homepage",
	"type" => "section"),
array( "type" => "open"),

array( "name" => "Show Featured Area 1",
	"desc" => "Do you want to show this area? (on by default)",
	"id" => $shortname."_show_feature_1",
	"type" => "select",
	"options" => array("yes", "no"),
	"std" => "yes"),
	
array( "name" => "Show Featured Area 2",
	"desc" => "Do you want to show this area? (on by default)",
	"id" => $shortname."_show_feature_2",
	"type" => "select",
	"options" => array("yes", "no"),
	"std" => "yes"),
	
array( "name" => "Show Headline on Home Page?",
	"desc" => "This is the area that reads 'You can expect a theme crafted with attention to detail and studio polish.'",
	"id" => $shortname."_show_homepage_headline",
	"type" => "select",
	"options" => array("yes", "no"),
	"std" => "yes"),
	
array( "name" => "Show Carousel on Home Page?",
	"desc" => "Do you want to show this area? (off by default)",
	"id" => $shortname."_show_carousel",
	"type" => "select",
	"options" => array("no", "yes"),
	"std" => "yes"),
	
array( "name" => "Featured 1 Post Category",
	"desc" => "Category to use for the featured 1 area. ('Featured1' by default)",
	"id" => $shortname."_featured_1_cat",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),
	
array( "name" => "Featured 2 Post Category",
	"desc" => "Category to use for the featured 2 area. ('Featured2' by default)",
	"id" => $shortname."_featured_2_cat",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),
	
array( "name" => "Carousel Post Category",
	"desc" => "Category to use for the carousel. ('Carousel' by default)",
	"id" => $shortname."_carousel_cat",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),
	
array( "name" => "Homepage Headline",
	"desc" => "This will replace where is reads 'You can expect a theme crafted with attention to detail and studio polish.'",
	"id" => $shortname."_homepage_headline",
	"type" => "text",
	"std" => ""),
	
array( "name" => "Homepage Page Name",
	"desc" => "This will replace the area under the slider on the left where it says 'Welcome'",
	"id" => $shortname."_homepage_page_name",
	"type" => "text",
	"std" => ""),
	
array( "name" => "Homepage Page Description",
	"desc" => "This will replace the area under the slider on the left where it says 'This headline can be set in the theme options panel.'",
	"id" => $shortname."_homepage_page_description",
	"type" => "text",
	"std" => ""),
	
array( "type" => "close"),

array( "name" => "Slider",
	"type" => "section"),
array( "type" => "open"),
	
array( "name" => "Show Slider",
	"desc" => "Do you want to show this area? (on by default)",
	"id" => $shortname."_show_slider",
	"type" => "select",
	"options" => array("yes", "no"),
	"std" => "yes"),
	
array( "name" => "Slider Style",
	"desc" => "Select the slider type to use",
	"id" => $shortname."_slider",
	"type" => "select",
	"options" => array("contentslider", "accordionslider", "nivoslider"),
	"std" => "full_content_slider"),

array( "name" => "Show Slider on Blog",
	"desc" => "Do you want to show this area? (off by default)",
	"id" => $shortname."_blog_slider",
	"type" => "select",
	"options" => array("no", "yes"),
	"std" => "yes"),
	
array( "name" => "Full Content Slider Category",
	"desc" => "Enter the category name that will be used in the full content slider. ex: 'slider' is used by default.",
	"id" => $shortname."_full_content_cat",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),
	
array( "name" => "Accordion Slider Category",
	"desc" => "Enter the category name that will be used in the accordion slider. ex: 'slider' is used by default.",
	"id" => $shortname."_accordion_cat",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),
	
array( "name" => "Nivo Slider Category",
	"desc" => "Enter the category name that will be used in the nivo slider. ex: 'slider' is used by default.",
	"id" => $shortname."_nivo_cat",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),

 
array( "type" => "close"),

array( "name" => "Fonts",
	"type" => "section"),
array( "type" => "open"),

array( "name" => "Enable Cufon?",
	"desc" => "Would you like to load a cufon font?",
	"id" => $shortname."_enable_cufon",
	"type" => "select",
	"options" => array("yes", "no"),
	"std" => "yes"),
	
array( "name" => "Cufon Font 1",
	"desc" => "Choose the cufon font you would like to load.  You can set the elements to use this font on in the next option.",
	"id" => $shortname."_cufon_font1",
	"type" => "select",
	"options" => array("arial", "atfant", "babelsans", "dayroman", "dejavu sans condensed", "delicious", "manksans", "union", "none"),
	"std" => "arial"),

array( "name" => "Assign Cufon 1 Elements",
	"desc" => "Assign this cufon font to any elements you would like to use it on.  Default setting for font 1 is 'h1, h2, h3, h4, h5, h6, th, .arial, .form label, .comment cite, form#commentform label'.",
	"id" => $shortname."_cufon_font1_elements",
	"type" => "text",
	"std" => "h1, h2, h3, h4, h5, h6, th, .arial, .form label, .comment cite, form#commentform label"),

array( "name" => "Cufon Font 2",
	"desc" => "Choose the cufon font you would like to load.  You can set the elements to use this font on in the next option.",
	"id" => $shortname."_cufon_font2",
	"type" => "select",
	"options" => array("atfant", "arial", "babelsans", "dayroman", "DejaVu Sans Condensed", "delicious", "manksans", "union", "none"),
	"std" => "atfant"),

array( "name" => "Assign Cufon 2 Elements",
	"desc" => "Assign this cufon font to any elements you would like to use it on.  Default setting for font 1 is '.atfant, div.contentWrap h1'.",
	"id" => $shortname."_cufon_font2_elements",
	"type" => "text",
	"std" => ".atfant, div.contentWrap h1"),

array( "name" => "Cufon Font 3",
	"desc" => "Choose the cufon font you would like to load.  You can set the elements to use this font on in the next option.",
	"id" => $shortname."_cufon_font3",
	"type" => "select",
	"options" => array("none", "arial", "atfant", "babelsans", "dayroman", "DejaVu Sans Condensed", "delicious", "manksans", "union"),
	"std" => "none"),

array( "name" => "Assign Cufon 3 Elements",
	"desc" => "Assign this cufon font to any elements you would like to use it on.  For example, to assign it to the h4 tag enter 'h4'.  To assign it to the class cufon1 and the h4 tag enter '.cufon1, h4''",
	"id" => $shortname."_cufon_font3_elements",
	"type" => "text",
	"std" => ""),

array( "name" => "Enable @font-face?",
	"desc" => "Would you like to load an @font-face font?",
	"id" => $shortname."_enable_fontface",
	"type" => "select",
	"options" => array("no", "yes"),
	"std" => "no"),
	
array( "name" => "Which @font-face?",
	"desc" => "Choose the @font-face font you would like to load.  This can be used on any text by including the font's name as a 'style' on the element.",
	"id" => $shortname."_fontface_name",
	"type" => "select",
	"options" => array("bebas", "comfortaa", "dayroman", "droid", "qlassik", "goudy"),
	"std" => ""),

array( "type" => "close")
 
);


function mytheme_add_admin() {
 
global $themename, $shortname, $options;
 
if ( $_GET['page'] == basename(__FILE__) ) {
 
	if ( 'save' == $_REQUEST['action'] ) {
 
		foreach ($options as $value) {
		update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
 
foreach ($options as $value) {
	if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
 
	header("Location: admin.php?page=functions.php&saved=true");
die;
 
} 
else if( 'reset' == $_REQUEST['action'] ) {
 
	foreach ($options as $value) {
		delete_option( $value['id'] ); }
 
	header("Location: admin.php?page=functions.php&reset=true");
die;
 
}
}
 
add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');
}

function mytheme_add_init() {

$file_dir=get_bloginfo('template_directory');
wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
wp_enqueue_script("rm_script", $file_dir."/functions/rm_script.js", false, "1.0");

}

/* Theme Options Display */
function mytheme_admin() {
 
global $themename, $shortname, $options;
$i=0;
 
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
 
?>
<div class="wrap rm_wrap">
<img style="margin-top:10px;" src="<?php echo get_template_directory_uri()?>/functions/images/logo.png" alt="<?php echo $themename; ?> Settings" />
 
<div class="rm_opts">
<form method="post">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
 
case "open":
?>
 
<?php break;
 
case "close":
?>
 
</div>
</div>
<br />

 
<?php break;
 
case "title":
?>
<p><?php echo $themename;?> theme settings.  Click to expand / hide menu elements.</p>

 
<?php break;
 
case 'text':
?>

<div class="rm_input rm_text">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
 	<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if (get_option($value['id']) != "") { echo stripslashes(get_option($value['id'])  ); } else { echo $value['std']; } ?>" />
 <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
 
 </div>
<?php
break;
 
case 'textarea':
?>

<div class="rm_input rm_textarea">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
 	<textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_option($value['id']) != "") { echo stripslashes(get_option($value['id']) ); } else { echo $value['std']; } ?></textarea>
 <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
 
 </div>
  
<?php
break;
 
case 'select':
?>

<div class="rm_input rm_select">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
	
<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
		<option <?php if (get_option($value['id']) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>
</select>

	<small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
</div>
<?php
break;
 
case "checkbox":
?>

<div class="rm_input rm_checkbox">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
	
<?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />


	<small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
 </div>
<?php break; 
case "section":

$i++;

?>

<div class="rm_section">
<div class="rm_title"><h3><img src="<?php echo get_template_directory_uri()?>/functions/images/trans.gif" class="inactive" alt="""><?php echo $value['name']; ?></h3><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="Save changes" />
</span><div class="clearfix"></div></div>
<div class="rm_options">

 
<?php break;
 
}
}
?>
 
<input type="hidden" name="action" value="save" />
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
<div style="font-size:9px; margin-bottom:10px;">Icons: <a href="http://www.woothemes.com/2009/09/woofunction/">WooFunction</a></div>
 </div> 
 

<?php
}
?>
<?php
add_action('admin_init', 'mytheme_add_init');
add_action('admin_menu', 'mytheme_add_admin');

/*** END THEME OPTIONS ***********************************************/


/* CUSTOM WRITE BOXES FOR POST **********************************************/
/* adds custom field write panels to post template */

$new_meta_boxes =
array(
"external_link" => array(
"name" => "external_link",
"std" => "",
"title" => "External Link",
"description" => "Overwrite wordpress and link to any page you want (on or off your domain). Works for slider, blog, featured1 and featured2, and carousel."),

"large_image" => array(
"name" => "large_image",
"std" => "",
"title" => "Large Image (960x340)",
"description" => "Resized for all smaller images and used in full content and nivo sliders"),

"fullsize" => array(
"name" => "fullsize",
"std" => "",
"title" => "Full Sized Image",
"description" => "For pop up, used on featured content posts"),

"accordion_image" => array(
"name" => "accordion_image",
"std" => "",
"title" => "Accordion Slider (650x340)",
"description" => "Used only in the accordion slider"),

"vimeo_embed" => array(
"name" => "vimeo_embed",
"std" => "",
"title" => "Vimeo Embed",
"description" => "Simply paste the url from a video such as Youtube or Vimeo in order post a video to the slider or portfolio.  If this item is a slider or portfolio item, this will overwrite the image feature."),

"youtube_embed" => array(
"name" => "youtube_embed",
"std" => "",
"title" => "Youtube Embed",
"description" => "Simply paste the url from a video such as Youtube or Vimeo in order post a video to the slider or portfolio.  If this item is a slider or portfolio item, this will overwrite the image feature."),

"slider_short_title" => array(
"name" => "slider_short_title",
"std" => "",
"title" => "Short slider title",
"description" => "Short title for accordion and full content slider posts"),

"accordion_desc" => array(
"name" => "accordion_desc",
"std" => "",
"title" => "Accordion slider description",
"description" => "Description for accordion slider posts when not hovered"),

"slider_desc" => array(
"name" => "slider_desc",
"std" => "",
"title" => "Long slider description",
"description" => "Description for full content slider and extended description for accordion slider posts when hovered"),

"portfolio_description" => array(
"name" => "portfolio_description",
"std" => "",
"title" => "'portfolio_single.php' item description",
"description" => "Short description for portfolio items only.  Appears on the right column under the title."),

"portfolio_details" => array(
"name" => "portfolio_details",
"std" => "",
"title" => "'portfolio_single.php' item details",
"description" => "Link to live project or more details. Enter url only. Appears on the right column under the title.")
);

function new_meta_boxes() {
global $post, $new_meta_boxes;

foreach($new_meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);

if($meta_box_value == "")
$meta_box_value = $meta_box['std'];

if ($meta_box['title'] == "Short slider title" || $meta_box['title'] == "'portfolio_single.php' item description") {
echo '<div style="display:block;width:100%;height:1px;background:#dedede;margin:20px 0 10px 0;"></div>';
} else if ($meta_box['title'] == "Large Image (960x340)") {
echo '';
} else {
echo '<div style="display:block;width:100%;height:1px;background:#fff;margin:5px 0 5px 0;"></div>';
}

if ($meta_box['title'] == "External Link") {
echo '<h2 style="color:#333;font-size:14px;font-family:arial;font-style:normal;font-weight:bold;letter-spacing:.5px;margin:5px 0 0 0;padding-left:3px;padding-bottom:0;">GENERAL SETTINGS</h2>';
}else if ($meta_box['title'] == "Large Image (960x340)") {
echo '<h2 style="color:#333;font-size:14px;font-family:arial;font-style:normal;font-weight:bold;letter-spacing:.5px;margin:5px 0 0 0;padding-left:3px;padding-bottom:0;">IMAGE SETTINGS</h2>';
} else if ($meta_box['title'] == "Short slider title") {
echo '<h2 style="color:#333;font-size:14px;font-family:arial;font-style:normal;font-weight:bold;letter-spacing:.5px;margin:5px 0 0 0;padding-left:3px;padding-bottom:0;">SLIDER TEXT SETTINGS</h2>';
} else if ($meta_box['title'] == "'portfolio_single.php' item description") {
echo '<h2 style="color:#333;font-size:14px;font-family:arial;font-style:normal;font-weight:bold;letter-spacing:.5px;margin:5px 0 0 0;padding-left:3px;padding-bottom:0;">PORTFOLIO SETTINGS</h2>';
}

echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';

echo'<h2 style="color:#777;font-size:12px;font-weight:bold;font-family:arial;line-height:27px;margin-top:0px; margin-bottom:0px;padding-left:5px;padding-bottom:0;font-style:normal;">'.$meta_box['title'].'</h2>';

echo'<p style="color:#777;margin:0 0 6px 4px;"><label for="'.$meta_box['name'].'_value">'.$meta_box['description'].'</label></p>';

echo'<input style="color:#777;" type="text" name="'.$meta_box['name'].'_value" value="'.$meta_box_value.'" size="55" /><div style="clear:both;display:block;font-size:0;height:0;line-height:0;width:100%;"></div>';
}
}

function create_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'new-meta-boxes', 'Amplify Post Settings', 'new_meta_boxes', 'post', 'normal', 'high' );
}
}

function save_postdata( $post_id ) {
global $post, $new_meta_boxes;

foreach($new_meta_boxes as $meta_box) {
// Verify
if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}

if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ))
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;
}

$data = $_POST[$meta_box['name'].'_value'];

if(get_post_meta($post_id, $meta_box['name'].'_value') == "")
add_post_meta($post_id, $meta_box['name'].'_value', $data, true);
elseif($data != get_post_meta($post_id, $meta_box['name'].'_value', true))
update_post_meta($post_id, $meta_box['name'].'_value', $data);
elseif($data == "")
delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true));
}
}

add_action('admin_menu', 'create_meta_box');
add_action('save_post', 'save_postdata');

/* END CUSTOM WRITE BOXES FOR POST **********************************************/


/* CUSTOM WRITE BOXES FOR PAGE **************************************************/

$page_meta_boxes =
array(
"headline" => array(
"name" => "headline",
"std" => "",
"title" => "Headline",
"description" => "Located under logo area. Page name is used in headling if left empty."),

"headline_description" => array(
"name" => "headline_description",
"std" => "",
"title" => "Headline Description",
"description" => "Displayed to the right of the headline.  Blank by default."),

"custom_sidebar" => array(
"name" => "custom_sidebar",
"std" => "",
"title" => "Custom Sidebar Location",
"description" => "Enter the full url of a .php file to use it as a custom sidebar. See sidebar.php for sidebar structure.")
);

function page_meta_boxes() {
global $post, $page_meta_boxes;

foreach($page_meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);

if($meta_box_value == "")
$meta_box_value = $meta_box['std'];

if ($meta_box['title'] == "Headline") {
echo '<h2 style="color:#333;font-size:14px;font-family:arial;font-style:normal;font-weight:bold;letter-spacing:.5px;margin:5px 0 0 0;padding-left:3px;padding-bottom:0;">PAGE SETTINGS</h2>';
} else {
echo '<div style="display:block;width:100%;height:1px;background:#fff;margin:5px 0 5px 0;"></div>';
}

echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';

echo'<h2 style="color:#777;font-size:12px;font-weight:bold;font-family:arial;line-height:27px;margin-top:0px; margin-bottom:0px;padding-left:5px;padding-bottom:0;font-style:normal;">'.$meta_box['title'].'</h2>';

echo'<p style="color:#777;margin:0 0 6px 4px;"><label for="'.$meta_box['name'].'_value">'.$meta_box['description'].'</label></p>';

echo'<input style="color:#777;" type="text" name="'.$meta_box['name'].'_value" value="'.$meta_box_value.'" size="55" /><div style="clear:both;display:block;font-size:0;height:0;line-height:0;width:100%;"></div>';
}
}

function create_page_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'new-meta-boxes', 'Amplify Post Settings', 'page_meta_boxes', 'page', 'normal', 'high' );
}
}

function save_pagedata( $post_id ) {
global $post, $page_meta_boxes;

foreach($page_meta_boxes as $meta_box) {
// Verify
if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}

if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ))
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;
}

$data = $_POST[$meta_box['name'].'_value'];

if(get_post_meta($post_id, $meta_box['name'].'_value') == "")
add_post_meta($post_id, $meta_box['name'].'_value', $data, true);
elseif($data != get_post_meta($post_id, $meta_box['name'].'_value', true))
update_post_meta($post_id, $meta_box['name'].'_value', $data);
elseif($data == "")
delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true));
}
}

add_action('admin_menu', 'create_page_meta_box');
add_action('save_post', 'save_pagedata');

/* END CUSTOM WRITE BOXES FOR PAGE **********************************************/

/* REGISTER WIDGETS *************************************************************/
/* two sidebars and four widget-ready columns in the footer. */

function amplify_widgets_init() {
	// Area 1, located at the top of the sidebar.
	register_sidebar( array(
		'name' => __( 'Primary Widget Area', 'amplify' ),
		'id' => 'primary-widget-area',
		'description' => __( 'The primary widget area', 'amplify' ),
		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );

	// Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
	register_sidebar( array(
		'name' => __( 'Secondary Widget Area', 'amplify' ),
		'id' => 'secondary-widget-area',
		'description' => __( 'The secondary widget area', 'amplify' ),
		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );

	// Area 3, located in the footer
	register_sidebar( array(
		'name' => __( 'First Footer Widget Area', 'amplify' ),
		'id' => 'first-footer-widget-area',
		'description' => __( 'The first footer widget area', 'amplify' ),
		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );

	// Area 4, located in the footer
	register_sidebar( array(
		'name' => __( 'Second Footer Widget Area', 'amplify' ),
		'id' => 'second-footer-widget-area',
		'description' => __( 'The second footer widget area', 'amplify' ),
		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );

	// Area 5, located in the footer
	register_sidebar( array(
		'name' => __( 'Third Footer Widget Area', 'amplify' ),
		'id' => 'third-footer-widget-area',
		'description' => __( 'The third footer widget area', 'amplify' ),
		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );

	// Area 6, located in the footer
	register_sidebar( array(
		'name' => __( 'Fourth Footer Widget Area', 'amplify' ),
		'id' => 'fourth-footer-widget-area',
		'description' => __( 'The fourth footer widget area', 'amplify' ),
		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
}
/** Register sidebars by running amplify_widgets_init() on the widgets_init hook. */
add_action( 'widgets_init', 'amplify_widgets_init' );
/* END REGISTER WIDGETS **********************************************/


function create_taxonomies() {
	// create a new taxonomy
	register_taxonomy(
		'inserzione',
		'page',
		array(
			'label' => __( 'Inserzione' ),
			'sort' => true,
			'args' => array( 'orderby' => 'term_order' ),
			'rewrite' => array( 'slug' => 'inserzione' ),
			'hierarchical' => true

		)
	);
	
	register_taxonomy(
		'locazione',
		'page',
		array(
			'label' => __( 'Locazione' ),
			'sort' => true,
			'args' => array( 'orderby' => 'term_order' ),
			'rewrite' => array( 'slug' => 'locazione' ),
			'hierarchical' => true

		)
	);
	
	register_taxonomy(
		'servizi',
		'page',
		array(
			'label' => __( 'Servizi' ),
			'sort' => true,
			'args' => array( 'orderby' => 'term_order' ),
			'rewrite' => array( 'slug' => 'servizi' ),
			'hierarchical' => true

		)
	);
	
	register_taxonomy(
		'aziende',
		'page',
		array(
			'label' => __( 'Attivit&agrave;' ),
			'sort' => true,
			'args' => array( 'orderby' => 'term_order' ),
			'rewrite' => array( 'slug' => 'aziende' ),
			'hierarchical' => true

		)
	);

	
}
add_action( 'init', 'create_taxonomies' );


function SearchFilter($query) {
if ($query->is_search) {
$query->set('cat','-1,-5,-6,-7,-9');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');



//Funzione per limitare visualizzazione dei post, ora si possono vedere solo i post di cui si รจ autori, eccezion fatta per l'Amministratore

function posts_for_current_author($query) {
	global $user_level;

	if($query->is_admin && $user_level < 5) {
		global $user_ID;
		$query->set('author',  $user_ID);
		unset($user_ID);
	}
	unset($user_level);

	return $query;
}
add_filter('pre_get_posts', 'posts_for_current_author');