/* Register sidebars and widgetized areas */ function arphabet_widgets_init() {register_sidebar( array( 'name' => 'Sidebar Widget', 'id' => 'sidebar_widget', 'before_widget' => ' <div class="widget-inner">', 'after_widget' => ' </div>', 'before_title' => ' <h4 class="uppercase">', 'after_title' => ' </h4>', ) ); } add_action( 'widgets_init', 'arphabet_widgets_init' ); /* Clean Format Widget */ add_action('widgets_init', create_function('', 'register_widget("clean_markup_widget");')); class Clean_Markup_Widget extends WP_Widget { function __construct() { parent::WP_Widget('clean_markup_widget', 'Clean markup widget', array('description'=>'Simple widget for well-formatted markup &amp; text')); } function widget($args, $instance) { extract($args); $markup = $instance['markup']; if ($markup) echo $markup; } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['markup'] = $new_instance['markup']; return $instance; } function form($instance) { if ($instance) $markup = esc_attr($instance['markup']); else $markup = __('&lt;p&gt;Clean, well-formatted markup.&lt;/p&gt;', 'markup_widget'); ?> <p> <label for="<?php echo $this->get_field_id('markup'); ?>"><?php _e('Markup/text'); ?></label><br /> <textarea class="widefat" id="<?php echo $this->get_field_id('markup'); ?>" name="<?php echo $this->get_field_name('markup'); ?>" type="text" rows="16" cols="20" value="<?php echo $markup; ?>"><?php echo $markup; ?></textarea> </p> <?php } } /* Register Menus */ add_action( 'after_setup_theme', 'wpt_setup' ); if ( ! function_exists( 'wpt_setup' ) ): function wpt_setup() { register_nav_menu( 'primary', __( ' Primary navigation', 'wptuts' ) ); register_nav_menu( 'footer', __( ' Footer navigation', 'wptuts' ) ); } endif; /* Remove Menu UL Class */ function remove_ul ( $menu ){ return preg_replace( array( '#^<ul[^>]*>#', '#</ul>$#' ), '', $menu ); } add_filter( 'wp_nav_menu', 'remove_ul' ); /* Custom Post Types */ /*Homes Post Type*/ function prefix_register_post_type_homes() { register_post_type( 'homes', array( 'labels' => array( 'name' => __('Homes', 'text_domain'), 'singular_name' => __('Homes', 'text_domain'), 'menu_name' => __('Homes', 'text_domain'), 'name_admin_bar' => __('Homes Home', 'text_domain'), 'all_items' => __('All Homes', 'text_domain'), 'add_new' => _x('Add New', 'homes', 'text_domain'), 'add_new_item' => __('Add New Home', 'text_domain'), 'edit_item' => __('Edit Home', 'text_domain'), 'new_item' => __('New Home', 'text_domain'), 'view_item' => __('View Home', 'text_domain'), 'search_items' => __('Search Homes', 'text_domain'), 'not_found' => __('No items found.', 'text_domain'), 'not_found_in_trash' => __('No items found in Trash.', 'text_domain'), 'parent_item_colon' => __('Parent Homes:', 'text_domain'), ), 'public' => true, 'menu_position' => 4, 'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions', 'excerpt', 'author' ), 'taxonomies' => array( 'homes_categories', 'post_tag', ), 'has_archive' => true, 'menu_icon' => 'dashicons-admin-home', 'rewrite' => array( 'slug' => 'homes', ), ) ); } add_action('init', 'prefix_register_post_type_homes'); function prefix_register_taxonomy_homes() { register_taxonomy( 'homes_categories', array( 'homes', ), array( 'labels' => array( 'name' => _x('Regions', 'homes', 'text_domain'), 'singular_name' => _x('Region', 'homes', 'text_domain'), 'menu_name' => __('Regions', 'text_domain'), 'all_items' => __('All Regions', 'text_domain'), 'edit_item' => __('Edit Region', 'text_domain'), 'view_item' => __('View Region', 'text_domain'), 'update_item' => __('Update Region', 'text_domain'), 'add_new_item' => __('Add New Region', 'text_domain'), 'new_item_name' => __('New Region Name', 'text_domain'), 'parent_item' => __('Parent Region', 'text_domain'), 'parent_item_colon' => __('Parent Region:', 'text_domain'), 'search_items' => __('Search Regions', 'text_domain'), ), 'show_admin_column' => true, 'hierarchical' => true, 'rewrite' => array( 'slug' => 'homes/region', ), ) ); } add_action('init', 'prefix_register_taxonomy_homes', 0); /*Filter by category*/ add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy_homes'); function tsm_filter_post_type_by_taxonomy_homes() { global $typenow; $post_type = 'homes'; $taxonomy = 'homes_categories'; if ($typenow == $post_type) { $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; $info_taxonomy = get_taxonomy($taxonomy); wp_dropdown_categories(array( 'show_option_all' => __("Show All {$info_taxonomy->label}"), 'taxonomy' => $taxonomy, 'name' => $taxonomy, 'orderby' => 'name', 'selected' => $selected, 'show_count' => true, 'hide_empty' => true, )); }; } add_filter('parse_query', 'tsm_convert_id_to_term_in_query_homes'); function tsm_convert_id_to_term_in_query_homes($query) { global $pagenow; $post_type = 'homes'; $taxonomy = 'homes_categories'; $q_vars = &$query->query_vars; if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) { $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy); $q_vars[$taxonomy] = $term->slug; } } /* End Homes Post Type */ /*Builders Post Type*/ function prefix_register_post_type_builders() { register_post_type( 'builders', array( 'labels' => array( 'name' => __('Builders', 'text_domain'), 'singular_name' => __('Builders', 'text_domain'), 'menu_name' => __('Builders', 'text_domain'), 'name_admin_bar' => __('Builders Builder', 'text_domain'), 'all_items' => __('All Builders', 'text_domain'), 'add_new' => _x('Add New', 'builders', 'text_domain'), 'add_new_item' => __('Add New Builder', 'text_domain'), 'edit_item' => __('Edit Builder', 'text_domain'), 'new_item' => __('New Builder', 'text_domain'), 'view_item' => __('View Builder', 'text_domain'), 'search_items' => __('Search Builders', 'text_domain'), 'not_found' => __('No items found.', 'text_domain'), 'not_found_in_trash' => __('No items found in Trash.', 'text_domain'), 'parent_item_colon' => __('Parent Builders:', 'text_domain'), ), 'public' => true, 'menu_position' => 4, 'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions', 'excerpt', 'author' ), 'taxonomies' => array( 'builders_categories', 'post_tag', ), 'has_archive' => true, 'menu_icon' => 'dashicons-hammer', 'rewrite' => array( 'slug' => 'builders', ), ) ); } add_action('init', 'prefix_register_post_type_builders'); function prefix_register_taxonomy_builders() { register_taxonomy( 'builders_categories', array( 'builders', ), array( 'labels' => array( 'name' => _x('Builder Categories', 'builders', 'text_domain'), 'singular_name' => _x('Builder Category', 'builders', 'text_domain'), 'menu_name' => __('Builder Categories', 'text_domain'), 'all_items' => __('All Builder Categories', 'text_domain'), 'edit_item' => __('Edit Builder Category', 'text_domain'), 'view_item' => __('View Builder Category', 'text_domain'), 'update_item' => __('Update Builder Category', 'text_domain'), 'add_new_item' => __('Add New Builder Category', 'text_domain'), 'new_item_name' => __('New Builder Category Name', 'text_domain'), 'parent_item' => __('Parent Builder Category', 'text_domain'), 'parent_item_colon' => __('Parent Builder Category:', 'text_domain'), 'search_items' => __('Search Builder Categories', 'text_domain'), ), 'show_admin_column' => true, 'hierarchical' => true, 'rewrite' => array( 'slug' => 'builders/category', ), ) ); } add_action('init', 'prefix_register_taxonomy_builders', 0); /*Filter by category*/ add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy_builders'); function tsm_filter_post_type_by_taxonomy_builders() { global $typenow; $post_type = 'builders'; $taxonomy = 'builders_categories'; if ($typenow == $post_type) { $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; $info_taxonomy = get_taxonomy($taxonomy); wp_dropdown_categories(array( 'show_option_all' => __("Show All {$info_taxonomy->label}"), 'taxonomy' => $taxonomy, 'name' => $taxonomy, 'orderby' => 'name', 'selected' => $selected, 'show_count' => true, 'hide_empty' => true, )); }; } add_filter('parse_query', 'tsm_convert_id_to_term_in_query_builders'); function tsm_convert_id_to_term_in_query_builders($query) { global $pagenow; $post_type = 'builders'; $taxonomy = 'builders_categories'; $q_vars = &$query->query_vars; if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) { $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy); $q_vars[$taxonomy] = $term->slug; } } /* End Builders Post Type */ /*Communities Post Type*/ function prefix_register_post_type_communities() { register_post_type( 'communities', array( 'labels' => array( 'name' => __('Communities', 'text_domain'), 'singular_name' => __('Communities', 'text_domain'), 'menu_name' => __('Communities', 'text_domain'), 'name_admin_bar' => __('Communities Community', 'text_domain'), 'all_items' => __('All Communities', 'text_domain'), 'add_new' => _x('Add New', 'communities', 'text_domain'), 'add_new_item' => __('Add New Community', 'text_domain'), 'edit_item' => __('Edit Community', 'text_domain'), 'new_item' => __('New Community', 'text_domain'), 'view_item' => __('View Community', 'text_domain'), 'search_items' => __('Search Communities', 'text_domain'), 'not_found' => __('No items found.', 'text_domain'), 'not_found_in_trash' => __('No items found in Trash.', 'text_domain'), 'parent_item_colon' => __('Parent Communities:', 'text_domain'), ), 'public' => true, 'menu_position' => 4, 'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions', 'excerpt', 'author' ), 'taxonomies' => array( 'communities_categories', 'post_tag', ), 'has_archive' => true, 'menu_icon' => 'dashicons-location-alt', 'rewrite' => array( 'slug' => 'communities', ), ) ); } add_action('init', 'prefix_register_post_type_communities'); function prefix_register_taxonomy_communities() { register_taxonomy( 'communities_categories', array( 'communities', ), array( 'labels' => array( 'name' => _x('Community Categories', 'communities', 'text_domain'), 'singular_name' => _x('Community Category', 'communities', 'text_domain'), 'menu_name' => __('Community Categories', 'text_domain'), 'all_items' => __('All Community Categories', 'text_domain'), 'edit_item' => __('Edit Community Category', 'text_domain'), 'view_item' => __('View Community Category', 'text_domain'), 'update_item' => __('Update Community Category', 'text_domain'), 'add_new_item' => __('Add New Community Category', 'text_domain'), 'new_item_name' => __('New Community Category Name', 'text_domain'), 'parent_item' => __('Parent Community Category', 'text_domain'), 'parent_item_colon' => __('Parent Community Category:', 'text_domain'), 'search_items' => __('Search Community Categories', 'text_domain'), ), 'show_admin_column' => true, 'hierarchical' => true, 'rewrite' => array( 'slug' => 'communities/category', ), ) ); } add_action('init', 'prefix_register_taxonomy_communities', 0); /*Filter by category*/ add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy_communities'); function tsm_filter_post_type_by_taxonomy_communities() { global $typenow; $post_type = 'communities'; $taxonomy = 'communities_categories'; if ($typenow == $post_type) { $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; $info_taxonomy = get_taxonomy($taxonomy); wp_dropdown_categories(array( 'show_option_all' => __("Show All {$info_taxonomy->label}"), 'taxonomy' => $taxonomy, 'name' => $taxonomy, 'orderby' => 'name', 'selected' => $selected, 'show_count' => true, 'hide_empty' => true, )); }; } add_filter('parse_query', 'tsm_convert_id_to_term_in_query_communities'); function tsm_convert_id_to_term_in_query_communities($query) { global $pagenow; $post_type = 'communities'; $taxonomy = 'communities_categories'; $q_vars = &$query->query_vars; if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) { $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy); $q_vars[$taxonomy] = $term->slug; } } /* End Communities Post Type */ /*FAQs Post Type*/ function prefix_register_post_type_faqs() { register_post_type( 'faqs', array( 'labels' => array( 'name' => __('FAQs', 'text_domain'), 'singular_name' => __('FAQs', 'text_domain'), 'menu_name' => __('FAQs', 'text_domain'), 'name_admin_bar' => __('FAQs FAQ', 'text_domain'), 'all_items' => __('All FAQs', 'text_domain'), 'add_new' => _x('Add New', 'faqs', 'text_domain'), 'add_new_item' => __('Add New FAQ', 'text_domain'), 'edit_item' => __('Edit FAQ', 'text_domain'), 'new_item' => __('New FAQ', 'text_domain'), 'view_item' => __('View FAQ', 'text_domain'), 'search_items' => __('Search FAQs', 'text_domain'), 'not_found' => __('No items found.', 'text_domain'), 'not_found_in_trash' => __('No items found in Trash.', 'text_domain'), 'parent_item_colon' => __('Parent FAQs:', 'text_domain'), ), 'public' => true, 'menu_position' => 4, 'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions', 'excerpt', 'author' ), 'taxonomies' => array( 'faqs_categories', 'post_tag', ), 'has_archive' => true, 'menu_icon' => 'dashicons-editor-help', 'rewrite' => array( 'slug' => 'faqs', ), ) ); } add_action('init', 'prefix_register_post_type_faqs'); function prefix_register_taxonomy_faqs() { register_taxonomy( 'faqs_categories', array( 'faqs', ), array( 'labels' => array( 'name' => _x('FAQ Categories', 'faqs', 'text_domain'), 'singular_name' => _x('FAQ Category', 'faqs', 'text_domain'), 'menu_name' => __('FAQ Categories', 'text_domain'), 'all_items' => __('All FAQ Categories', 'text_domain'), 'edit_item' => __('Edit FAQ Category', 'text_domain'), 'view_item' => __('View FAQ Category', 'text_domain'), 'update_item' => __('Update FAQ Category', 'text_domain'), 'add_new_item' => __('Add New FAQ Category', 'text_domain'), 'new_item_name' => __('New FAQ Category Name', 'text_domain'), 'parent_item' => __('Parent FAQ Category', 'text_domain'), 'parent_item_colon' => __('Parent FAQ Category:', 'text_domain'), 'search_items' => __('Search FAQ Categories', 'text_domain'), ), 'show_admin_column' => true, 'hierarchical' => true, 'rewrite' => array( 'slug' => 'faqs/category', ), ) ); } add_action('init', 'prefix_register_taxonomy_faqs', 0); /*Filter by category*/ add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy_faqs'); function tsm_filter_post_type_by_taxonomy_faqs() { global $typenow; $post_type = 'faqs'; $taxonomy = 'faqs_categories'; if ($typenow == $post_type) { $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; $info_taxonomy = get_taxonomy($taxonomy); wp_dropdown_categories(array( 'show_option_all' => __("Show All {$info_taxonomy->label}"), 'taxonomy' => $taxonomy, 'name' => $taxonomy, 'orderby' => 'name', 'selected' => $selected, 'show_count' => true, 'hide_empty' => true, )); }; } add_filter('parse_query', 'tsm_convert_id_to_term_in_query_faqs'); function tsm_convert_id_to_term_in_query_faqs($query) { global $pagenow; $post_type = 'faqs'; $taxonomy = 'faqs_categories'; $q_vars = &$query->query_vars; if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) { $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy); $q_vars[$taxonomy] = $term->slug; } } /* End FAQs Post Type */ /* Clean up for custom post types */ function prefix_flush_rewrite_rules() { flush_rewrite_rules(); } add_action('after_switch_theme', 'prefix_flush_rewrite_rules'); function add_custom_types_to_tax( $query ) { if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { $post_types = get_post_types(); $query->set( 'post_type', $post_types ); return $query; } } add_filter( 'pre_get_posts', 'add_custom_types_to_tax' ); /* End Custom Post Type */