Guest User

functions.php, WPBoot 1.3 http://wordpress.org/themes/wpboot

a guest
Feb 17th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.38 KB | None | 0 0
  1. <?php
  2. /**
  3.  * wpboot functions and definitions
  4.  *
  5.  * @package wpboot
  6.  */
  7.  
  8.  
  9. if (! function_exists(wpboot_theme_setup)) {
  10.     function wpboot_theme_setup() {
  11.         global $content_width;
  12.         /* Set the $content_width for things such as video embeds. */
  13.         if ( !isset( $content_width ) )
  14.         $content_width = 617;  
  15.        
  16.         add_theme_support( 'title-tag' );
  17.        
  18.         /* Add theme support for automatic feed links. */
  19.         add_theme_support( 'automatic-feed-links' );
  20.  
  21.         add_theme_support( 'custom-background', array(
  22.             'default-color' => 'ffffff',
  23.         ) );
  24.  
  25.         /* Add theme support for post thumbnails (featured images). */
  26.         add_theme_support( 'post-thumbnails' );
  27.         add_image_size( 'big-thumb', 617, 9999);
  28.     }
  29.     add_action( 'after_setup_theme', 'wpboot_theme_setup' );
  30. }
  31.  
  32. if (! function_exists(wpboot_register_menus)) {
  33.     // Add menu features
  34.     function wpboot_register_menus() {
  35.         register_nav_menus(array('primary'=>__( 'Primary Menu' ), ));
  36.     }
  37.     /* Add your nav menus function to the 'init' action hook. */
  38.     add_action( 'init', 'wpboot_register_menus' );
  39. }
  40.  
  41. if (! function_exists(wpboot_page_menu_args)) {
  42.     // Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  43.     function wpboot_page_menu_args( $args ) {
  44.         $args['show_home'] = true;
  45.         return $args;
  46.     }
  47.     add_filter( 'wp_page_menu_args', 'wpboot_page_menu_args' );
  48. }
  49.  
  50. if ( ! function_exists( '_wp_render_title_tag' ) ) {
  51.     function wpboot_render_title() {
  52. ?>
  53.     <title><?php wp_title( '|', true, 'right' ); ?></title>
  54. <?php
  55.     }
  56.     add_action( 'wp_head', 'wpboot_render_title' );
  57. }
  58.  
  59. if (! function_exists(wpboot_register_sidebars)) {
  60.     function wpboot_register_sidebars() {
  61.         register_sidebar(
  62.             array(
  63.                 'id' => 'primary',
  64.                 'name' => __( 'Primary Sidebar', 'wpboot' ),
  65.                 'description' => __( 'The following widgets will appear in the main sidebar div.', 'wpboot' ),
  66.                 'before_widget' => '<div id="%1$s" class="sidebar-module widget %2$s">',
  67.                 'after_widget' => '</div>',
  68.                 'before_title' => '<h4>',
  69.                 'after_title' => '</h4>'
  70.             )
  71.         );
  72.     }
  73.     /* Add custom actions. */
  74.     add_action( 'widgets_init', 'wpboot_register_sidebars' );
  75. }
  76.  
  77. if (! function_exists(wpboot_scripts)) {
  78.     function wpboot_scripts() {
  79.         wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', null, '3.0.0' );
  80.         wp_enqueue_style( 'style', get_stylesheet_uri() );
  81.         if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  82.             wp_enqueue_script( 'comment-reply' );
  83.         }
  84.     }
  85.     add_action( 'wp_enqueue_scripts', 'wpboot_scripts' );
  86. }
  87.  
  88. if (! function_exists(wpboot_wp_title)) {
  89.     //Set up title if SEO plugin is not used.
  90.     function wpboot_wp_title( $title, $sep ) {
  91.         global $paged, $page;
  92.  
  93.         if ( is_feed() )
  94.             return $title;
  95.  
  96.         // Add the site name.
  97.         $title .= get_bloginfo( 'name' );
  98.  
  99.         // Add the site description for the home/front page.
  100.         $site_description = get_bloginfo( 'description', 'display' );
  101.         if ( $site_description && ( is_home() || is_front_page() ) )
  102.             $title = "$title $sep $site_description";
  103.  
  104.         // Add a page number if necessary.
  105.         if ( $paged >= 2 || $page >= 2 )
  106.             $title = "$title $sep " . sprintf( __( 'Page %s', 'wpboot' ), max( $paged, $page ) );
  107.  
  108.         return $title;
  109.     }
  110.     add_filter( 'wp_title', 'wpboot_wp_title', 10, 2 );
  111. }
  112.  
  113. if (! function_exists(wpboot_excerpt_length)) {
  114.     function wpboot_excerpt_length( $length ) {
  115.         return 40;
  116.     }
  117.     add_filter( 'excerpt_length', 'wpboot_excerpt_length', 999 );
  118. }
  119.  
  120. if (! function_exists(wpboot_excerpt_more)) {
  121.     function wpboot_excerpt_more($more) {
  122.         global $post;
  123.         return '... <span class="read-more"><a href="'. get_permalink($post->ID) . '">Continue Reading &rarr;</a></span>';
  124.     }
  125.     add_filter('excerpt_more', 'wpboot_excerpt_more');
  126. }
  127.  
  128. if (! function_exists(wpboot_register_required_plugins)) {
  129.     /**
  130.      * Include the TGM_Plugin_Activation class.
  131.      */
  132.     require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php';
  133.  
  134.     /**
  135.      * Register the required plugins for this theme.
  136.      *
  137.      * In this example, we register two plugins - one included with the TGMPA library
  138.      * and one from the .org repo.
  139.      *
  140.      * The variable passed to tgmpa_register_plugins() should be an array of plugin
  141.      * arrays.
  142.      *
  143.      * This function is hooked into tgmpa_init, which is fired within the
  144.      * TGM_Plugin_Activation class constructor.
  145.      */
  146.     function wpboot_register_required_plugins() {
  147.      
  148.         /**
  149.          * Array of plugin arrays. Required keys are name and slug.
  150.          * If the source is NOT from the .org repo, then source is also required.
  151.          */
  152.         $plugins = array(
  153.      
  154.             // Include WP Product Review plugin from the WordPress Plugin Repository.
  155.             array(
  156.                 'name'      => 'WP Product Review',
  157.                 'slug'      => 'wp-product-review',
  158.                 'required'  => false,
  159.             ),
  160.            
  161.             // Include Revive Old Post plugin from the WordPress Plugin Repository.
  162.             array(
  163.                 'name'      => 'Revive Old Post',
  164.                 'slug'      => 'tweet-old-post',
  165.                 'required'  => false,
  166.             ),
  167.      
  168.         );
  169.      
  170.         /**
  171.          * Array of configuration settings. Amend each line as needed.
  172.          * If you want the default strings to be available under your own theme domain,
  173.          * leave the strings uncommented.
  174.          * Some of the strings are added into a sprintf, so see the comments at the
  175.          * end of each line for what each argument will be.
  176.          */
  177.         $config = array(
  178.             'default_path' => '',                      // Default absolute path to pre-packaged plugins.
  179.             'menu'         => 'tgmpa-install-plugins', // Menu slug.
  180.             'has_notices'  => true,                    // Show admin notices or not.
  181.             'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
  182.             'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
  183.             'is_automatic' => false,                   // Automatically activate plugins after installation or not.
  184.             'message'      => '',                      // Message to output right before the plugins table.
  185.             'strings'      => array(
  186.                 'page_title'                      => __( 'Install Required Plugins', 'tgmpa' ),
  187.                 'menu_title'                      => __( 'Install Plugins', 'tgmpa' ),
  188.                 'installing'                      => __( 'Installing Plugin: %s', 'tgmpa' ), // %s = plugin name.
  189.                 'oops'                            => __( 'Something went wrong with the plugin API.', 'tgmpa' ),
  190.                 'notice_can_install_required'     => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s).
  191.                 'notice_can_install_recommended'  => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s).
  192.                 'notice_cannot_install'           => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s).
  193.                 'notice_can_activate_required'    => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
  194.                 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
  195.                 'notice_cannot_activate'          => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s).
  196.                 'notice_ask_to_update'            => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s).
  197.                 'notice_cannot_update'            => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s).
  198.                 'install_link'                    => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
  199.                 'activate_link'                   => _n_noop( 'Begin activating plugin', 'Begin activating plugins' ),
  200.                 'return'                          => __( 'Return to Required Plugins Installer', 'tgmpa' ),
  201.                 'plugin_activated'                => __( 'Plugin activated successfully.', 'tgmpa' ),
  202.                 'complete'                        => __( 'All plugins installed and activated successfully. %s', 'tgmpa' ), // %s = dashboard link.
  203.                 'nag_type'                        => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
  204.             )
  205.         );
  206.      
  207.         tgmpa( $plugins, $config );
  208.      
  209.     }
  210.     add_action( 'tgmpa_register', 'wpboot_register_required_plugins' );
  211. }
  212.  
  213. ?>
Add Comment
Please, Sign In to add comment