__( 'Top Menu', 'boatdealer' ), ) ); // Support Woocommerce add_action( 'after_setup_theme', 'boatdealer_woocommerce_support' ); function boatdealer_woocommerce_support() { add_theme_support( 'woocommerce' ); } add_action('widgets_init', 'boatdealer_new_widget_init'); function boatdealer_new_widget_init() { register_sidebar(array( 'name' => 'Header Widget', 'id' => 'header_widget_left', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => 'Header Widget Right', 'id' => 'header_widget_right', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => 'First Footer Widget', 'id' => '1-footer', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => 'Second Footer Widget', 'id' => '2-footer', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => 'Third Footer Widget', 'id' => '3-footer', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } add_action('widgets_init', 'boatdealer_new_widget_init'); ////////////////////////////////////////////////////////////////////// /** * Set the content width based on the theme's design and stylesheet. * * @since boatdealer 1.0 */ if ( ! isset( $content_width ) ) { $content_width = 660; } /** * boatdealer menu only works in WordPress 4.1 or later. */ if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) { require get_template_directory() . '/inc/back-compat.php'; } if ( ! function_exists( 'boatdealer_setup' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. * * @since boatdealer 1.0 */ function boatdealer_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on boatdealer, use a find and replace * to change 'boatdealer' to the name of your theme in all the template files */ load_theme_textdomain( 'boatdealer', get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 825, 510, true ); // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'boatdealer' ), 'social' => __( 'Social Links Menu', 'boatdealer' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) ); /* * Enable support for Post Formats. * * See: https://codex.wordpress.org/Post_Formats */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat' ) ); $color_scheme = boatdealer_get_color_scheme(); $default_color = trim( $color_scheme[0], '#' ); // Setup the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'boatdealer_custom_background_args', array( 'default-color' => $default_color, 'default-attachment' => 'fixed', ) ) ); /* * This theme styles the visual editor to resemble the theme style, * specifically font, colors, icons, and column width. */ add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css') ); } endif; // boatdealer_setup add_action( 'after_setup_theme', 'boatdealer_setup' ); /** * Register widget area. * * @since boatdealer 1.0 * * @link https://codex.wordpress.org/Function_Reference/register_sidebar */ function boatdealer_widgets_init() { register_sidebar( array( 'name' => __( 'Widget Area', 'boatdealer' ), 'id' => 'sidebar-1', 'description' => __( 'Add widgets here to appear in your sidebar.', 'boatdealer' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'boatdealer_widgets_init' ); /** * JavaScript Detection. * * Adds a `js` class to the root `<html>` element when JavaScript is detected. * * @since boatdealer menu 1.1 */ function boatdealer_javascript_detection() { echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n"; } add_action( 'wp_head', 'boatdealer_javascript_detection', 0 ); /** * Enqueue scripts and styles. * * @since boatdealer 1.0 */ function boatdealer_scripts() { // Add custom fonts, used in the main stylesheet. // wp_enqueue_style( 'boatdealer-fonts', boatdealer_fonts_url(), array(), null ); // Add Genericons, used in the main stylesheet. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.2' ); // Load our main stylesheet. wp_enqueue_style( 'boatdealer-style', get_stylesheet_uri() ); // Load the Internet Explorer specific stylesheet. wp_enqueue_style( 'boatdealer-ie', get_template_directory_uri() . '/css/ie.css', array( 'boatdealer-style' ), '20141010' ); wp_style_add_data( 'boatdealer-ie', 'conditional', 'lt IE 9' ); // Load the Internet Explorer 7 specific stylesheet. wp_enqueue_style( 'boatdealer-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'boatdealer-style' ), '20141010' ); wp_style_add_data( 'boatdealer-ie7', 'conditional', 'lt IE 8' ); wp_enqueue_script( 'boatdealer-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20141010', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } if ( is_singular() && wp_attachment_is_image() ) { wp_enqueue_script( 'boatdealer-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141010' ); } wp_enqueue_script( 'boatdealer-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150330', true ); wp_localize_script( 'boatdealer-script', 'screenReaderText', array( 'expand' => '<span class="screen-reader-text">' . __( 'expand child menu', 'boatdealer' ) . '</span>', 'collapse' => '<span class="screen-reader-text">' . __( 'collapse child menu', 'boatdealer' ) . '</span>', ) ); } add_action( 'wp_enqueue_scripts', 'boatdealer_scripts' ); /** * Add featured image as background image to post navigation elements. * * @since boatdealer 1.0 * * @see wp_add_inline_style() */ function boatdealer_post_nav_background() { if ( ! is_single() ) { return; } $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); $css = ''; if ( is_attachment() && 'attachment' == $previous->post_type ) { return; } if ( $previous && has_post_thumbnail( $previous->ID ) ) { $prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'post-thumbnail' ); $css .= ' .post-navigation .nav-previous { background-image: url(' . esc_url( $prevthumb[0] ) . '); } .post-navigation .nav-previous .post-title, .post-navigation .nav-previous a:hover .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; } .post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); } '; } if ( $next && has_post_thumbnail( $next->ID ) ) { $nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'post-thumbnail' ); $css .= ' .post-navigation .nav-next { background-image: url(' . esc_url( $nextthumb[0] ) . '); border-top: 0; } .post-navigation .nav-next .post-title, .post-navigation .nav-next a:hover .post-title, .post-navigation .nav-next .meta-nav { color: #fff; } .post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); } '; } wp_add_inline_style( 'boatdealer-style', $css ); } add_action( 'wp_enqueue_scripts', 'boatdealer_post_nav_background' ); /** * Display descriptions in main navigation. * * @since boatdealer 1.0 * * @param string $item_output The menu item output. * @param WP_Post $item Menu item object. * @param int $depth Depth of the menu. * @param array $args wp_nav_menu() arguments. * @return string Menu item with possible description. */ function boatdealer_nav_description( $item_output, $item, $depth, $args ) { if ( 'primary' == $args->theme_location && $item->description ) { $item_output = str_replace( $args->link_after . '</a>', '<div class="menu-item-description">' . $item->description . '</div>' . $args->link_after . '</a>', $item_output ); } return $item_output; } add_filter( 'walker_nav_menu_start_el', 'boatdealer_nav_description', 10, 4 ); /** * Add a `screen-reader-text` class to the search form's submit button. * * @since boatdealer 1.0 * * @param string $html Search form HTML. * @return string Modified search form HTML. */ function boatdealer_search_form_modify( $html ) { return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html ); } add_filter( 'get_search_form', 'boatdealer_search_form_modify' ); /** * Implement the Custom Header feature. * * @since boatdealer 1.0 */ require get_template_directory() . '/inc/custom-header.php'; /** * Custom template tags for this theme. * * @since boatdealer 1.0 */ require get_template_directory() . '/inc/template-tags.php'; /** * Customizer additions. * * @since boatdealer 1.0 */ require get_template_directory() . '/inc/customizer.php'; /// Widget class boatdealer_my_phone_widget extends WP_Widget { public function __construct() { parent::__construct( 'boatdealer_my_phone_widget', // Widget name will appear in UI __( 'My Phone, Email and Business Hours Widget', 'boatdealer' ), array( 'description' => __( 'Widget to Add Your Email, Phone and Business Hours', 'boatdealer' ), ) ); } // Creating widget front-end public function widget( $args, $instance ) { $phone = apply_filters( 'widget_title', $instance['phone'] ); $email = apply_filters( 'widget_title', $instance['email'] ); $time = apply_filters( 'widget_title', $instance['time'] ); // before and after widget arguments are defined by themes echo $args['before_widget']; $output = ''; if(! empty($phone)) { $output.= '<img alt="my phone" src="'.get_template_directory_uri().'/images/icon_small_phone.png" />'; $output .= ' '.$phone; } if(! empty($email)) { $output .= '   <img alt="my email" src="'.get_template_directory_uri().'/images/email-icon.png" />'; $output .= ' '.$email; } if(! empty($time)) { $output .= '   <img alt="my time" src="'.get_template_directory_uri().'/images/clock-icon.png" />'; $output .= ' '.$time; echo $output; } echo $args['after_widget']; } // Widget Backend public function form( $instance ) { if ( isset( $instance[ 'phone' ] ) ) { $phone = $instance[ 'phone' ]; } else { $phone = ''; } if ( isset( $instance[ 'email' ] ) ) { $email = $instance[ 'email' ]; } else { $email = ''; } if ( isset( $instance[ 'time' ] ) ) { $time = $instance[ 'time' ]; } else { $time = ''; } // Widget admin form ?> <label> <?php echo __( 'Your Phone Number', 'boatdealer' ) ?>'</label> <input class="widefat" id="<?php echo $this->get_field_id( 'phone' ); ?>" name="<?php echo $this->get_field_name( 'phone' ); ?>" type="text" value="<?php echo esc_attr( $phone ); ?>" /> <label> <?php echo __( 'Your email', 'boatdealer' ) ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'email' ); ?>" name="<?php echo $this->get_field_name( 'email' ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>" /> <label> <?php echo __( 'Your Business Hours', 'boatdealer' ) ?> </label> <input class="widefat" id="<?php echo $this->get_field_id( 'time' ); ?>" name="<?php echo $this->get_field_name( 'time' ); ?>" type="text" value="<?php echo esc_attr( $time ); ?>" /> </p> <?php } // Updating widget replacing old instances with new public function update( $new_instance, $old_instance ) { $instance = array(); $instance['phone'] = ( ! empty( $new_instance['phone'] ) ) ? strip_tags( $new_instance['phone'] ) : ''; //$instance = array(); $instance['email'] = ( ! empty( $new_instance['email'] ) ) ? strip_tags( $new_instance['email'] ) : ''; //$instance = array(); $instance['time'] = ( ! empty( $new_instance['time'] ) ) ? strip_tags( $new_instance['time'] ) : ''; return $instance; } } // Class wpb_widget ends here // Register and load the widget function boatdealer_my_phone_load_widget() { register_widget( 'boatdealer_my_phone_widget' ); } add_action( 'widgets_init', 'boatdealer_my_phone_load_widget' ); function boatdealer_loadLastScripts() { wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/modernizr.min.js', array(), '2.6.2', true ); wp_enqueue_script ( 'slickjs' , get_template_directory_uri() . '/slick/js/jquery.slicknav.min.js', array( 'jquery' ), '1.0.4', false ); wp_enqueue_style( 'slicknav', get_template_directory_uri() . '/slick/css/slicknav.css' ); wp_enqueue_style( 'slicknav', get_template_directory_uri() . '/slick/css/demo.css' ); wp_enqueue_script('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js', array('jquery'), '1.8.6'); } add_action( 'wp_enqueue_scripts','boatdealer_loadLastScripts' );