<?php
/**
* Slightly Modified Options Framework
*/
require_once ('admin/index.php');
if ( ! isset( $content_width ) ) $content_width = 900;
function at_scripts()
{
// Register Scripts
wp_register_script( 'plugins', get_template_directory_uri() . '/js/plugins.js' );
wp_register_script( 'custom-script', get_template_directory_uri() . '/js/custom.js' );
//Enqueue Scripts
wp_enqueue_script('jquery');
wp_enqueue_script('plugins');
wp_enqueue_script( 'custom-script' );
if ( (!is_admin()) && is_singular() && comments_open() && get_option('thread_comments') ){
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'at_scripts', 5 );
// This theme uses wp_nav_menu() in one location.
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array(
'main-menu' => __( 'Main Menu','overlay' )
)
);
}
add_action( 'init', 'create_my_menus' );
function create_my_menus(){
wp_create_nav_menu( 'Main Menu', array( 'slug' => 'main-menu' ) );
}
// Custom Post Types.
add_action('init', 'custom_post_register');
function custom_post_register() {
$args = array(
'label' => __('Portfolio','overlay'),
'singular_label' => __('Portfolio','overlay'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title' , 'thumbnail'),
);
$args2 = array(
'label' => __('Services','overlay'),
'singular_label' => __('Service','overlay'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title' , 'thumbnail','editor'),
);
register_post_type( 'portfolio' , $args );
register_post_type( 'services' , $args2 );
flush_rewrite_rules( false );
}
// 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' );
add_image_size( 'portfolio-image', 150, 140, false); // for use on portfolio
add_image_size( 'service-image', 30, 30, false); // for use on services
/**
* Output the favicon
*/
function at_custom_favicon() {
global $data;
if($data['custom_favicon'])
echo '<link rel="shortcut icon" href="'. $data['custom_favicon'] .'" />' . "\n";
}
add_action( 'wp_head', 'at_custom_favicon' );
function at_tracking_code() {
global $data;
if($data['google_analytics'])
echo stripslashes($data['google_analytics']);
}
add_action( 'wp_footer', 'at_tracking_code' );
add_action( 'wp_head','at_custom_styling' ); // Add custom styling to HEAD
function at_custom_styling() {
global $data;
$output = '';
// Add CSS to output
if ($data['background-color']) {
$output .= 'html {background-color:'.$data['background-color'].'}' . "\n";
}
if ($data['custom_bg'])
$output .= 'html {background-image:url(' . $data['custom_bg'].')}' . "\n";
if ($data['uploaded_bg'])
$output .= 'html {background-image:url(' . $data['uploaded_bg'].')}' . "\n";
if ($data['custom_bg'] && $data['bg_repeat'] && $data['bg_position'])
$output .= 'html {background-repeat:'.$data['bg_repeat'].'}' . "\n";
if ($data['custom_bg'] && $data['bg_position'])
$output .= 'html {background-position:'.$data['bg_position'].'}' . "\n";
if ($data['custom_bg'])
$output .= 'html {background-attachment:'.$data['bg_attachment'].'}' . "\n";
if($data['custom_css']){
$output .= stripslashes($data['custom_css']) . "\n";
}
// Output styles
if (isset($output) && $output != '') {
$output = strip_tags($output);
$output = "<!-- at Custom Styling -->\n<style type=\"text/css\">\n" . $output . "</style>\n";
echo $output;
}
}
if ( !function_exists('at_remove_autop') ) {
function at_remove_autop($content) {
$content = do_shortcode( shortcode_unautop($content) );
$content = preg_replace( '#^<\/p>|^<br \/>|<p>$#', '', $content );
return $content;
}
}
add_shortcode('highlight', 'at_highlight');
function at_highlight($atts, $content = null) {
$content = at_remove_autop($content);
$output = '<span>' . $content . '</span>';
return do_shortcode($output);
}
if (!is_admin()) add_action( 'wp_footer','atf_other_javascript' );
if (!function_exists('atf_other_javascript')) {
function atf_other_javascript( ) {
global $data;
$slides = $data['nivo_slider']; //get the slides array
$slides_no = count(array_keys($slides),1);
if ( (is_home() || is_front_page()) && !is_paged() ) {
$speed = $data['ani_speed'];
$pause = $data['ani_pause'];
$slices = $data['ani_slices'];
$columns = $data['ani_bc'];
$rows = $data['ani_br'];
$effect = $data['animation'];
$arrows = $data['slider_arrows'];
echo '<script type="text/javascript">
jQuery(window).load(function() {
jQuery("#slider").nivoSlider({
effect:\'' . $effect . '\',
animSpeed:' . $speed . ', //Slide transition speed
pauseTime:' .$pause . ',
slices:' . $slices . ', // For slice animations
boxCols:' . $columns .', // For box animations
boxRows:' . $rows .', // For box animations
pauseOnHover:true,
directionNav:' . $arrows . ', //Next And Prev
directionNavHide:true,
controlNav:true, //1,2,3...
controlNavThumbs:false,
captionOpacity:0.7 //Universal caption opacity
}
);
});
</script>';
}
}
}
/************* COMMENTS HOOK *************/
function at_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; ?>
<div <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<?php echo get_avatar( $comment, $size='40', $default='<path_to_url>' ); ?>
<div class="comment-info">
<?php printf( __( '<cite class="fn">%s</cite>' ), get_comment_author_link() ) ?>
<span><?php printf( __( '%1$s at %2$s', 'shopitpress' ), get_comment_date(), get_comment_time() ) ?></span>
<?php edit_comment_link( __( '(Edit)', 'shopitpress' ), ' ', '' ) ?>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'shopitpress' ) ?></em>
<?php endif; ?>
<?php comment_text() ?>
<?php if ( $args['max_depth']!=$depth ):?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) ?>
</div>
<?php endif ?>
</div>
<?php
}
if ( !function_exists('at_pagination') ) {
function at_pagination($pages = '', $range = 2){
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class='pagination'>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>";
echo "</div>\n";
}
}
}