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. * * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu(). register_nav_menus( array( 'primary-nav' => __( 'Primary Navigation', 'broad' ), 'secondary-nav' => __( 'Secondary Navigation', 'broad' ) ) ); /* * 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. */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat', ) ); // Declare WooCommerce support add_theme_support( 'woocommerce' ); // Setup the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'broad_custom_background_args', array( 'default-color' => '#f8f8f8', 'default-image' => '', ) ) ); } endif; // broad_setup add_action( 'after_setup_theme', 'broad_setup' ); function create_broad_db_table() { global $wpdb; $table = $wpdb->prefix . "broad_options"; $query = "CREATE TABLE IF NOT EXISTS $table ( option_id int(255) NOT NULL auto_increment, option_name varchar(200) NOT NULL, option_value longtext NOT NULL, option_activate varchar(200) NOT NULL default '1', primary KEY (option_id) ) ENGINE=InnoDB"; $query = $wpdb->query($query); // Dumping data for table wp_broad_options if ($query) { $query = $wpdb->get_var("SELECT option_name FROM $table WHERE option_id = 1"); if (! $query ) { $logo = get_template_directory_uri() . '/images/broad.png'; $social_links = 'http://facebook.com, http://twitter.com, http://googleplus.com, http://linkedin.com'; $adverts = get_template_directory_uri() . '/images/advert1.gif' . ', ' . get_template_directory_uri() . '/images/advert1.gif'; $post_layout = maybe_serialize( array( "default" => "Default (List)", "masonry" => "Masonry" ) ); $footer_background_image = get_template_directory_uri() . '/images/bg.png'; $query = "INSERT INTO $table (option_id, option_name, option_value, option_activate) VALUES (NULL, 'site_logo', '$logo', 1), (NULL, 'social_links', '$social_links', 1), (NULL, 'navigation_bar', '', 1), (NULL, 'featured_posts', '', 0), (NULL, 'adverts', '$adverts', 1), (NULL, 'post_layout', '$post_layout', 'default'), (NULL, 'sidebar', '', 1), (NULL, 'footer_background_image', '$footer_background_image', 0)"; $query = $wpdb->query($query); } } } add_action('after_setup_theme', 'create_broad_db_table'); /** * Registers a widget area. * * @since Broad 1.0 */ function broad_widgets_init() { $before_title = '
+
- '; $after_title = ' -
'; register_sidebar( array( 'name' => __( 'Sidebar1', 'broad' ), 'id' => 'sidebar1', 'description' => __( 'Add widgets here to appear in your sidebar.', 'broad' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => $before_title, 'after_title' => $after_title, ) ); register_sidebar( array( 'name' => __( 'Footer Copyright Widget', 'broad' ), 'id' => 'copyright', 'description' => __( 'Add widgets here to appear in your footer.', 'broad' ), 'before_widget' => '
', 'before_title' => '', 'after_title' => '', ) ); register_sidebar( array( 'name' => __( 'Footer Widget 1', 'broad' ), 'id' => 'footer1', 'description' => __( 'Add widgets here to appear in your footer.', 'broad' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '
', 'after_title' => '
', ) ); register_sidebar( array( 'name' => __( 'Footer Widget 2', 'broad' ), 'id' => 'footer2', 'description' => __( 'Add widgets here to appear in your footer.', 'broad' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '
', 'after_title' => '
', ) ); register_sidebar( array( 'name' => __( 'Footer Widget 3', 'broad' ), 'id' => 'footer3', 'description' => __( 'Add widgets here to appear in your footer.', 'broad' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '
', 'after_title' => '
', ) ); register_sidebar( array( 'name' => __( 'Footer Widget 4', 'broad' ), 'id' => 'footer4', 'description' => __( 'Add widgets here to appear in your footer.', 'broad' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '
', 'after_title' => '
', ) ); register_sidebar( array( 'name' => __( 'Footer Widget 5', 'broad' ), 'id' => 'footer5', 'description' => __( 'Add widgets here to appear in your footer.', 'broad' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '
', 'after_title' => '
', ) ); } add_action( 'widgets_init', 'broad_widgets_init' ); /** * Create Broad options page * * @since Broad 1.0 * */ function create_broad_option_page() { /** * Broad theme panel. */ require_once(get_template_directory() . '/inc/broad-option-page.php'); add_theme_page('Broad Panel', 'Broad Panel', 'manage_options', 'broad-theme-panel', 'broad_theme_panel'); add_theme_page("Overview", "Overview", 'manage_options', 'broad-overview' , 'broad_overview'); add_theme_page("Contact", "Contact", 'manage_options', 'broad-contact' , 'broad_contact'); } if (is_admin()) { add_action("admin_menu", "create_broad_option_page"); } function broad_admin_tabs( $current = 'header' ) { $content = ''; $tabs = array( 'header' => 'Header', 'body' => 'Body', 'footer' => 'Footer' ); foreach( $tabs as $tab => $name ) { $class = ( $tab == $current ) ? 'class=active' : ''; $content .= "
  • $name
  • "; } return ''; } function broad_get_option_data($for) { if ( empty($for) || ! isset($for) ) return; global $wpdb; $table = $wpdb->prefix . "broad_options"; $query = "SELECT * FROM $table WHERE option_name = "; switch( $for ) { case 'theme_data': return $wpdb->get_row($query . "'$for'"); break; case 'site_logo': return $wpdb->get_row($query . "'$for'"); break; case 'social_links' : return $wpdb->get_row($query . "'$for'"); break; case 'navigation_bar': return $wpdb->get_row($query . "'$for'"); break; case 'featured_posts': return $wpdb->get_row($query . "'$for'"); break; case 'adverts': return $wpdb->get_row($query . "'$for'"); break; case 'post_layout': return $wpdb->get_row($query . "'$for'"); break; case 'sidebar': return $wpdb->get_row($query . "'$for'"); break; case 'footer_background_image': return $wpdb->get_row($query . "'$for'"); break; default : return false; break; } } function broad_update_option_data($for, $data = array()) { if ( empty($for) || ! isset($for) || !is_array($data) || empty($data) ) return; global $wpdb; $table = $wpdb->prefix . "broad_options"; switch( $for ) { case 'site_logo': return($wpdb->update($table, $data, array('option_name' => 'site_logo'))); break; case 'social_links' : return $wpdb->update($table, $data, array('option_name' => 'social_links')); break; case 'navigation_bar': return $wpdb->update($table, $data, array('option_name' => 'navigation_bar')); break; case 'featured_posts': return $wpdb->update($table, $data, array('option_name' => 'featured_posts')); break; case 'adverts': return $wpdb->update($table, $data, array('option_name' => 'adverts')); break; case 'post_layout': return $wpdb->update($table, $data, array('option_name' => 'post_layout')); break; case 'sidebar': return $wpdb->update($table, $data, array('option_name' => 'sidebar')); break; case 'footer_background_image': return $wpdb->update($table, $data, array('option_name' => 'footer_background_image')); break; default : return false; break; } } /** * Check to see if a variable is set and not empty. * * @param $data . The data to scan * * @return mixed * if array, returns true if all is set & not empty otherwise return the keys(as array values) that are not set. * if (other data type) returns true if is set & not empty otherwise return false. * * @since Broad 1.0 */ function broad_verify_data( $data ) { if ( is_array($data) ) { $return = ''; while ( $value = current($data) ) { if ( $value !== '' ) { next($data); } elseif ( $value === '' || $value === ' ' ) { $return[] = key($data); } } return $return; } else { return (isset($data) && !empty($data)) ? true : false; } } /** * Handles JavaScript detection. * * Adds a `js` class to the root `` element when JavaScript is detected. * * @since Broad 1.0 */ function broad_javascript_detection() { echo "\n"; } add_action( 'wp_head', 'broad_javascript_detection', 0 ); /** * Enqueues General(backend & backend) scripts and styles. * * @since Broad 1.0 */ function broad_scripts() { // Enqueue the styles. wp_enqueue_style( 'normalize', get_template_directory_uri() . '/css/normalize.css', array(), '3.0.2' ); wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.4' ); // Enqueue the scripts wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery.js', array(), '1.11.1', true); wp_enqueue_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '3.3.4', true); } /** * Enqueues frontend scripts and style. * * @since Broad 1.0 */ function broad_frontend_scripts() { broad_scripts(); // Enqueue the style. wp_enqueue_style( 'broad-custom-style', get_stylesheet_directory_uri() . '/style.css' ); wp_enqueue_style( 'broad-frontend', get_template_directory_uri() . '/css/broad-frontend.css', array('normalize', 'bootstrap'), '1.0' ); $post_layout = broad_get_option_data('post_layout'); if ( $post_layout->option_activate == 'masonry' && !is_singular() ) { wp_enqueue_style( 'broad-frontend-masonry', get_template_directory_uri() . '/css/broad-frontend-masonry.css', array('normalize', 'bootstrap'), '1.0' ); } // Enqueue the scripts wp_enqueue_script('html5', get_template_directory_uri() . '/js/html5.js', array(), '3.7.0'); wp_script_add_data( 'html5', 'conditional', 'lt IE 9' ); wp_enqueue_script('broad-frontend', get_template_directory_uri() . '/js/broad-frontend.js', array('jquery', 'bootstrap'), '1.0', true); wp_enqueue_script('masonry', get_template_directory_uri() . '/js/masonry.js', array('jquery', 'bootstrap'), '3.3.2', true); } add_action( 'wp_enqueue_scripts', 'broad_frontend_scripts' ); /** * Enqueues Backend script and style. * * @since Broad 1.0 */ function broad_backend_scripts($hook) { if ($hook == 'appearance_page_broad-theme-panel') { broad_scripts(); // Enqueue the style. wp_enqueue_style( 'broad-backend', get_template_directory_uri() . '/css/broad-backend.css', array('normalize', 'bootstrap'), '1.0' ); // Enqueue the script wp_enqueue_script('broad-backend', get_template_directory_uri() . '/js/broad-backend.js', array('jquery', 'bootstrap'), '1.0'); } } add_action( 'admin_enqueue_scripts', 'broad_backend_scripts' ); /** * Broad classes. */ require get_template_directory() . '/inc/broad-classes.php'; /** * Broad template tags. */ require get_template_directory() . '/inc/template-tags.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * WooCommerce support */ require get_template_directory() . '/inc/broad-woocommerce.php'; function broad_header() { $site_logo = broad_get_option_data('site_logo'); $social_links = broad_get_option_data('social_links'); list($fb, $tw, $gp, $in) = explode(', ', $social_links->option_value); ?>
    option_activate == 1 && !empty($site_logo->option_value) ) : ?> %1$s %2$s', get_bloginfo('name'), get_bloginfo('description') ); endif; ?>
    option_activate == 1) : ?> fb tw gp in
    option_activate == 0) return; $args = array( 'menu' => 'primary-nav', 'container' => 'div', 'container_class' => 'collapse navbar-collapse col-lg-12', 'container_id' => 'broad-navbar-collapse1', 'menu_class' => 'nav navbar-nav copperplateb', 'echo' => true, 'fallback_cb' => 'wp_bootstrap_navwalker::fallback', 'depth' => 2, 'walker' => new wp_bootstrap_navwalker(), 'theme_location' => 'primary-nav' ); ?> option_activate == 0) return; $args = array( 'menu' => 'secondary-nav', 'container' => 'div', 'container_class' => 'collapse navbar-collapse col-lg-12', 'container_id' => 'broad-navbar-collapse2', 'menu_class' => 'nav navbar-nav copperplateb', 'echo' => true, 'fallback_cb' => 'wp_bootstrap_navwalker::fallback', 'depth' => 2, 'walker' => new wp_bootstrap_navwalker(), 'theme_location' => 'secondary-nav' ); ?> option_activate == 0) return; list($advert1, $advert2) = explode(', ', $adverts->option_value); ?>
    Home %2$s %3$s %4$s', home_url(), ' | ', $cat, the_title('', '', false) ); echo '
    '; printf( the_tags( null, ', ') ); } function broad_comment_template() { // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; } function broad_comment_form( $args = array() ) { $post_id = get_the_ID(); $commenter = wp_get_current_commenter(); $user = wp_get_current_user(); $user_identity = $user->exists() ? $user->display_name : ''; $args = wp_parse_args( $args ); if ( ! isset( $args['format'] ) ) $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); $html_req = ( $req ? " required='required'" : '' ); $html5 = 'html5' === $args['format']; $fields = array( 'author' => '
    ' . '
    ', 'email' => '
    ' . '
    ', 'url' => '
    ' . '
    ', ); $required_text = sprintf( ' ' . __( 'Required fields are marked %s', 'broad' ), '*' ); $fields = apply_filters( 'comment_form_default_fields', $fields ); $args = array( 'fields' => $fields, 'comment_field' => '
    ', 'must_log_in' => '

    ' . sprintf( __( 'You must be logged in to post a comment.', 'broad' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

    ', 'logged_in_as' => '

    ' . sprintf( __( 'Logged in as %2$s. Log out?', 'broad' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

    ', 'comment_notes_before' => '

    ' . __( 'Your email address will not be published.', 'broad' ) . ''. ( $req ? $required_text : '' ) . '

    ', 'comment_notes_after' => '
    ' . sprintf( __( 'You may use these HTML tags and attributes: %s', 'broad' ), ' ' . allowed_tags() . '' ) . '
    ', 'id_form' => 'commentform', 'id_submit' => 'submit', 'class_submit' => 'btn btn-primary pull-right', 'name_submit' => 'submit', 'title_reply' => __( 'Leave a Reply', 'broad' ), 'title_reply_to' => __( 'Leave a Reply to %s', 'broad' ), 'cancel_reply_link' => __( 'Cancel reply', 'broad' ), 'label_submit' => __( 'Post Comment', 'broad' ), 'submit_button' => '', 'submit_field' => '
    %1$s %2$s
    ', 'format' => 'xhtml', ); comment_form($args); } ?>