time(),'version_checked'=> $wp_version,); } add_filter('pre_site_transient_update_core','remove_core_updates'); add_filter('pre_site_transient_update_plugins','remove_core_updates'); add_filter('pre_site_transient_update_themes','remove_core_updates'); /** * Register TI Widgets */ add_action( 'widgets_init', 'TIPlugin_register_widgets' ); add_action( 'wp_print_styles', 'my_deregister_styles', 100 ); if ( is_admin() ){ add_action( 'admin_menu', 'my_theme_menu' ); add_action( 'admin_init', 'register_mysettings' ); } add_filter('body_class','add_category_to_single'); add_filter('single_template', 'render_post_template'); function render_post_template($t) { foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") ) { return TEMPLATEPATH . "/single-{$cat->slug}.php"; } } return $t; } //COMMENTED //Changed "none" to "null" function add_category_to_single($classes, $class = null) { if (is_single() ) { global $post; foreach((get_the_category($post->ID)) as $category) { // add category slug to the $classes array $classes[] = $category->category_nicename; } } // return the $classes array return $classes; } add_filter('page_css_class', 'my_css_attributes_filter', 100, 2); function my_css_attributes_filter($classes, $page){ global $post; $activeNav = false; if (!is_home()) { $category_holder = get_field('category_holder', $page->ID); foreach((get_the_category($post->ID)) as $category) { // add category slug to the $classes array if ($category->category_nicename == $category_holder) { $activeNav = true; } } if ($activeNav) { $classes[] = "active"; } return $classes; } } add_filter( 'tiny_mce_before_init', 'unhide_kitchensink' ); function unhide_kitchensink( $args ) { $args['wordpress_adv_hidden'] = false; return $args; } /** * Sets up the content width value based on the theme's design and stylesheet. */ if ( ! isset( $content_width ) ) $content_width = 625; /** * Sets up theme defaults and registers the various WordPress features that * Transparency International supports. * * @uses load_theme_textdomain() For translation/localization support. * @uses add_editor_style() To add a Visual Editor stylesheet. * @uses add_theme_support() To add support for post thumbnails, automatic feed links, * custom background, and post formats. * @uses register_nav_menu() To add support for navigation menus. * @uses set_post_thumbnail_size() To set a custom post thumbnail size. * * @since Transparency International 1.0 */ function ti_international_setup() { /* * Makes Transparency International available for translation. * * Translations can be added to the /languages/ directory. * If you're building a theme based on Transparency International, use a find and replace * to change 'ti_international' to the name of your theme in all the template files. */ load_theme_textdomain( 'ti_international', get_template_directory() . '/languages' ); // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); // Adds RSS feed links to for posts and comments. add_theme_support( 'automatic-feed-links' ); // This theme supports a variety of post formats. add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status' ) ); // This theme uses wp_nav_menu() in one location. register_nav_menu( 'primary', __( 'Primary Menu', 'ti_international' ) ); register_nav_menu( 'footer', __( 'Footer Menu', 'ti_international' ) ); /* * This theme supports custom background color and image, and here * we also set up the default background color. */ add_theme_support( 'custom-background', array( 'default-color' => 'e6e6e6', ) ); // This theme uses a custom image size for featured images, displayed on "standard" posts. add_theme_support( 'post-thumbnails' ); add_image_size( 'event', 280 ); add_image_size( 'featured', 605 ); add_image_size( 'slide', 698, 345, true ); add_image_size( 'publication', 116, 164, true ); add_image_size( 'block-thumb', 300, 300, true ); set_post_thumbnail_size( 160, 160, true ); update_option('medium_size_w', 280, true); } add_action( 'after_setup_theme', 'ti_international_setup' ); /** * Adds support for a custom header image. */ require( get_template_directory() . '/inc/custom-header.php' ); /** * Enqueues scripts and styles for front-end. * * @since Transparency International 1.0 */ function ti_international_scripts_styles() { global $wp_styles; /* * Adds JavaScript to pages with the comment form to support * sites with threaded comments (when in use). */ if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); /* * Adds JavaScript for handling the navigation menu hide-and-show behavior. */ wp_enqueue_script( 'ti_international-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0', true ); /* * Loads our special font CSS file. * * The use of Open Sans by default is localized. For languages that use * characters not supported by the font, the font can be disabled. * * To disable in a child theme, use wp_dequeue_style() * function mytheme_dequeue_fonts() { * wp_dequeue_style( 'ti_international-fonts' ); * } * add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 ); */ /* translators: If there are characters in your language that are not supported by Open Sans, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'ti_international' ) ) { $subsets = 'latin,latin-ext'; /* translators: To add an additional Open Sans character subset specific to your language, translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */ $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'ti_international' ); if ( 'cyrillic' == $subset ) $subsets .= ',cyrillic,cyrillic-ext'; elseif ( 'greek' == $subset ) $subsets .= ',greek,greek-ext'; elseif ( 'vietnamese' == $subset ) $subsets .= ',vietnamese'; $protocol = is_ssl() ? 'https' : 'http'; $query_args = array( 'family' => 'Open+Sans:400italic,700italic,400,700', 'subset' => $subsets, ); wp_enqueue_style( 'ti_international-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); } /* * Loads our main stylesheet. */ wp_enqueue_style( 'transparency_international', get_stylesheet_uri() ); /* * Loads the Internet Explorer specific stylesheet. */ wp_enqueue_style( 'ti_international-ie', get_template_directory_uri() . '/css/ie.css', array( 'ti_international-style' ), '20121010' ); $wp_styles->add_data( 'ti_international-ie', 'conditional', 'lt IE 9' ); } //add_action( 'wp_enqueue_scripts', 'ti_international_scripts_styles' ); /** * Creates a nicely formatted and more specific title element text * for output in head of document, based on current view. * * @since Transparency International 1.0 * * @param string $title Default title text for current view. * @param string $sep Optional separator. * @return string Filtered title. */ function ti_international_wp_title( $title, $sep ) { global $paged, $page; if ( is_feed() ) return $title; // Add the site name. $title .= get_bloginfo( 'name' ); // Add the site description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title = "$title $sep $site_description"; // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', 'ti_international' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'ti_international_wp_title', 10, 2 ); /** * Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link. * * @since Transparency International 1.0 */ function ti_international_page_menu_args( $args ) { if ( ! isset( $args['show_home'] ) ) $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'ti_international_page_menu_args' ); /** * Registers our main widget area and the front page widget areas. * * @since Transparency International 1.0 */ function ti_international_widgets_init() { register_sidebar( array( 'name' => __( 'Main Sidebar', 'ti_international' ), 'id' => 'sidebar-1', 'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'ti_international' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'First Front Page Widget Area', 'ti_international' ), 'id' => 'sidebar-2', 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'ti_international' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Second Front Page Widget Area', 'ti_international' ), 'id' => 'sidebar-3', 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'ti_international' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } //add_action( 'widgets_init', 'ti_international_widgets_init' ); if ( ! function_exists( 'ti_international_content_nav' ) ) : /** * Displays navigation to next/previous pages when applicable. * * @since Transparency International 1.0 */ function ti_international_content_nav( $html_id ) { global $wp_query; $html_id = esc_attr( $html_id ); if ( $wp_query->max_num_pages > 1 ) : ?> comment_type ) : case 'pingback' : case 'trackback' : // Display trackbacks differently than normal comments. ?>
  • id="comment-">

    ', '' ); ?>

    ' ); ?> __( 'Reply', 'ti_international' ), 'after' => '', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>

    comment_approved ) : ?>

    ', esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); $author = sprintf( '', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'ti_international' ), get_the_author() ) ), get_the_author() ); // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. if ( $tag_list ) { $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s by %4$s.', 'ti_international' ); } elseif ( $categories_list ) { $utility_text = __( 'This entry was posted in %1$s on %3$s by %4$s.', 'ti_international' ); } else { $utility_text = __( 'This entry was posted on %3$s by %4$s.', 'ti_international' ); } printf( $utility_text, $categories_list, $tag_list, $date, $author ); } endif; /** * Extends the default WordPress body class to denote: * 1. Using a full-width layout, when no active widgets in the sidebar * or full-width template. * 2. Front Page template: thumbnail in use and number of sidebars for * widget areas. * 3. White or empty background color to change the layout and spacing. * 4. Custom fonts enabled. * 5. Single or multiple authors. * * @since Transparency International 1.0 * * @param array Existing class values. * @return array Filtered class values. */ function ti_international_body_class( $classes ) { $background_color = get_background_color(); if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) ) $classes[] = 'full-width'; if ( is_page_template( 'page-templates/front-page.php' ) ) { $classes[] = 'template-front-page'; if ( has_post_thumbnail() ) $classes[] = 'has-post-thumbnail'; if ( is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) $classes[] = 'two-sidebars'; } if ( empty( $background_color ) ) $classes[] = 'custom-background-empty'; elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) ) $classes[] = 'custom-background-white'; // Enable custom font class only if the font CSS is queued to load. if ( wp_style_is( 'ti_international-fonts', 'queue' ) ) $classes[] = 'custom-font-enabled'; if ( ! is_multi_author() ) $classes[] = 'single-author'; return $classes; } add_filter( 'body_class', 'ti_international_body_class' ); /** * Adjusts content_width value for full-width and single image attachment * templates, and when there are no active widgets in the sidebar. * * @since Transparency International 1.0 */ function ti_international_content_width() { if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) { global $content_width; $content_width = 960; } } add_action( 'template_redirect', 'ti_international_content_width' ); /** * Add postMessage support for site title and description for the Theme Customizer. * * @since Transparency International 1.0 * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * @return void */ function ti_international_customize_register( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } add_action( 'customize_register', 'ti_international_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. * * @since Transparency International 1.0 */ function ti_international_customize_preview_js() { wp_enqueue_script( 'ti_international-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true ); } add_action( 'customize_preview_init', 'ti_international_customize_preview_js' ); // Create main.js // http://wp.tutsplus.com/articles/how-to-include-javascript-and-css-in-your-wordpress-themes-and-plugins/ function transparency_international () { wp_enqueue_script('main', get_template_directory_uri() . '/js/main.js', array('jquery'), true, true); } add_action( 'wp_enqueue_scripts', 'transparency_international' ); // Customise the_excerpt() // http://codex.wordpress.org/Function_Reference/the_excerpt // function custom_excerpt_length( $length ) { // return 20; // } // add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); // Update the_excerpt 'Read more' link function new_excerpt_more( $more ) { return '...'; } add_filter( 'excerpt_more', 'new_excerpt_more' ); // Output nicely formatted object properties/values // http://php.net/manual/en/function.get-object-vars.php function print_r2($val){ echo '
    ';
    print_r($val);
    echo  '
    '; } // Run on theme activation function theme_activation_function() { // Create categories $new_cat_id = wp_insert_term("News", "category"); $new_cat_id = wp_insert_term("Press Release", "category"); $new_cat_id = wp_insert_term("Feature", "category"); $new_cat_id = wp_insert_term("Event", "category"); $new_cat_id = wp_insert_term("Publication", "category"); $new_cat_id = wp_insert_term("About Us", "category"); // Create pages (using slug) $pages = array( array('title' => 'About Us', 'slug' => 'about-us', 'menu_order' => 7, 'category_holder' => 'about-us', 'page_template' => 'article-holder.php'), array('title' => 'Contact Us', 'slug' => 'contact-us', 'menu_order' => 6, 'category_holder' => '', 'page_template' => 'contact-us.php'), array('title' => 'Events', 'slug' => 'events', 'menu_order' => 5, 'category_holder' => 'event', 'page_template' => 'event-holder.php'), array('title' => 'Publications', 'slug' => 'publications', 'menu_order' => 4, 'category_holder' => 'publication', 'page_template' => 'publication-holder.php'), array('title' => 'Features', 'slug' => 'features', 'menu_order' => 3, 'category_holder' => 'feature', 'page_template' => 'article-holder.php'), array('title' => 'Press Releases', 'slug' => 'press-releases', 'menu_order' => 2, 'category_holder' => 'press-release', 'page_template' => 'article-holder.php') ); foreach($pages as $page) { // Create post object if (!get_page_by_title($page['title'])) { $my_post = array(); $my_post['post_title'] = $page['title']; $my_post['post_name'] = $page['slug']; $my_post['menu_order'] = $page['menu_order']; $my_post['post_content'] = ''; $my_post['post_status'] = 'publish'; $my_post['post_author'] = 1; // $my_post['post_category'] = array(8,39); $my_post['post_type'] = 'page'; // Insert the post into the database $postID = wp_insert_post( $my_post ); // Update template and Category Holder update_post_meta( $postID, '_wp_page_template', $page['page_template'] ); update_field('field_522da46c91bf2', $page['category_holder'], $postID); } } // Remove Sample Page if ($page = get_page_by_title('Sample Page')) { wp_delete_post( $page->ID, true ); } // Add deafult widgets // the name is (probably) the slug/id $new_active_widgets = array ( 'ti-widgets-frontpage' => array ( 'tisocialmediawidget', ) ); // save new widgets to DB update_option('sidebars_widgets', $new_active_widgets); } function ti_widgets_init() { unregister_widget( 'WP_Widget_Calendar' ); unregister_widget( 'WP_Widget_Archives' ); unregister_widget( 'WP_Widget_Categories' ); unregister_widget( 'WP_Widget_Links' ); unregister_widget( 'WP_Widget_Meta' ); unregister_widget( 'WP_Widget_Pages' ); unregister_widget( 'WP_Widget_Recent_Comments' ); unregister_widget( 'WP_Widget_RSS' ); unregister_widget( 'WP_Widget_Tag_Cloud' ); unregister_widget( 'WP_Nav_Menu_Widget' ); } include('inc/widgets.php'); function TIPlugin_register_widgets() { register_widget( 'TISocialMediaWidget' ); register_widget( 'TIFeaturedEventWidget' ); register_widget( 'TINewsletterWidget' ); register_widget( 'TIRecentPostWidget' ); } function custom_excerpt_length( $length ) { return 36; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); // Plugins require_once('inc/plugins.php'); define('FS_METHOD', 'direct'); //echo get_stylesheet_directory(); function my_deregister_styles() { wp_deregister_style('wp-pagenavi'); wp_deregister_style('contact-form-7'); // deregister as many stylesheets as you need... } function register_mysettings() { // whitelist options register_setting( 'ti_options', 'ti_options' ); //add_settings_section('ti_main', 'Main Settings', 'plugin_section_text', 'ti_theme'); //add_settings_field('ti_number_entries', 'Number of entries per page', 'plugin_setting_string', 'ti_theme', 'ti_main'); add_settings_section('plugin_theme', 'Theme Settings', 'plugin_section_footer', 'ti_theme'); //add_settings_field('ti_footer', 'Footer text', 'ti_footer', 'ti_theme', 'plugin_theme'); add_settings_field('ti_chapter_status', 'Chapter Status', 'ti_chapter_status', 'ti_theme', 'plugin_theme'); add_settings_field('ti_footer', 'Footer text', 'ti_footer_mce', 'ti_theme', 'plugin_theme'); } function pu_wp_editor($args){ extract( $args ); $class = (!empty($class))?$class:''; $settings = array( 'textarea_name' => OPT_NAME.'['.$id.']', 'editor_class' => $class ); wp_editor($value, $id, $settings ); echo (!empty($desc))?'
    '.$desc.'':''; } function my_theme_menu() { add_options_page( 'Theme options', 'TI Theme', 'manage_options', 'ti_theme', 'ti_options_page'); } function ti_options_page() { ?>

    Transparency International Theme

    Custom settings relating to the TI theme.
    "; } function ti_chapter_status() { $options = get_option('ti_options'); echo ""; } function ti_footer() { $options = get_option('ti_options'); echo ""; } function ti_footer_mce() { $options = get_option('ti_options'); $content = $options['ti_footer']; $name = 'ti_options[ti_footer]'; wp_editor( $content, 'tiny_mce', $settings = array( 'media_buttons' => false, 'teeny' => true, 'textarea_name' => $name) ); } /* Header Widget Area */ register_sidebar( array( 'name' => __( 'Header Widget Area', 'ti_international' ), 'id' => 'sidebar-4', 'description' => __( 'Appears in the header of the site.', 'ti_international' ), 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Membership Form Sidebar', 'ti_international' ), 'id' => 'membership-form', 'description' => __( 'Appears on membership application form pages' ), 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); /* BREAD CRUMBS */ function the_breadcrumb() { global $post; if (!is_front_page()) { echo ''; } function breadcrump_page( $post ) { echo ''; } ///// MEMBERS ONLY SECTION ///// add_filter( 'wpmem_block', 'block_minutes_archive' ); add_filter( 'wpmem_login_form', 'my_login_form_filter', 10, 2); function my_login_form_filter( $form, $action ) { return $form; } function block_minutes_archive( $block ) { get_post_type(); if (is_page_template('page-minutes.php') || is_singular( 'minutes') ) { $block = true; } else { $block = false; } return $block; } /* * Creating a function to create our CPT */ function custom_post_type() { // Set UI labels for Custom Post Type $labels = array( 'name' => _x( 'Meeting Minutes', 'Post Type General Name', 'twentythirteen' ), 'singular_name' => _x( 'Minutes', 'Post Type Singular Name', 'twentythirteen' ), 'menu_name' => __( 'Board Members Section', 'twentythirteen' ), 'parent_item_colon' => __( 'Parent Minutes', 'twentythirteen' ), 'all_items' => __( 'All Minutes', 'twentythirteen' ), 'view_item' => __( 'View Minutes', 'twentythirteen' ), 'add_new_item' => __( 'Add New Minutes', 'twentythirteen' ), 'add_new' => __( 'Add New', 'twentythirteen' ), 'edit_item' => __( 'Edit Minutes', 'twentythirteen' ), 'update_item' => __( 'Update Minutes', 'twentythirteen' ), 'search_items' => __( 'Search Minutes', 'twentythirteen' ), 'not_found' => __( 'Not Found', 'twentythirteen' ), 'not_found_in_trash' => __( 'Not found in Trash', 'twentythirteen' ), ); // Set other options for Custom Post Type $args = array( 'label' => __( 'minutes', 'twentythirteen' ), 'description' => __( 'Meeting Minutes & Documents', 'twentythirteen' ), 'labels' => $labels, // Features this CPT supports in Post Editor 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ), // You can associate this CPT with a taxonomy or custom taxonomy. //'taxonomies' => array( 'genres' ), /* A hierarchical CPT is like Pages and can have * Parent and child items. A non-hierarchical CPT * is like Posts. */ 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'capability_type' => 'post', ); // Registering your Custom Post Type register_post_type( 'minutes', $args ); } /* Hook into the 'init' action so that the function * Containing our post type registration is not * unnecessarily executed. */ add_action( 'init', 'custom_post_type', 0 );