Plugin Directory

Changeset 757292

Timestamp:
08/16/2013 07:27:29 PM (11 years ago)
Author:
tmoorewp
Message:

Separate theme tools to its own file. Build a forward-thinking way of including tools files. Add requirement for the random-redirect plugin.

Location:
jetpack/trunk/modules
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/modules/module-extras.php

    r753600 r757292  
    55 */
    66
    7 /**
    8  * INFINITE SCROLL
    9  */
     7// Happy Holidays!
     8require_once( dirname( __FILE__ ) . '/holiday-snow.php' );
    109
    11 /**
    12  * Load theme's infinite scroll annotation file, if present in the IS plugin.
    13  * The `setup_theme` action is used because the annotation files should be using `after_setup_theme` to register support for IS.
    14  *
    15  * As released in Jetpack 2.0, a child theme's parent wasn't checked for in the plugin's bundled support, hence the convoluted way the parent is checked for now.
    16  *
    17  * @uses is_admin, wp_get_theme, get_theme, get_current_theme, apply_filters
    18  * @action setup_theme
    19  * @return null
    20  */
    21 function jetpack_load_infinite_scroll_annotation() {
    22     if ( is_admin() && isset( $_GET['page'] ) && 'jetpack' == $_GET['page'] ) {
    23         $theme = function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_theme( get_current_theme() );
     10// Include extra tools that aren't modules, in a filterable way
     11$jetpack_tools_to_include = apply_filters( 'jetpack-tools-to-include', array( 'theme-tools.php' ) );
    2412
    25         if ( ! is_a( $theme, 'WP_Theme' ) && ! is_array( $theme ) )
    26             return;
    27 
    28         $customization_file = apply_filters( 'infinite_scroll_customization_file', dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Stylesheet']}.php", $theme['Stylesheet'] );
    29 
    30         if ( is_readable( $customization_file ) ) {
    31             require_once( $customization_file );
    32         }
    33         elseif ( ! empty( $theme['Template'] ) ) {
    34             $customization_file = dirname( __FILE__ ) . "/infinite-scroll/themes/{$theme['Template']}.php";
    35 
    36             if ( is_readable( $customization_file ) )
    37                 require_once( $customization_file );
     13if ( ! empty( $jetpack_tools_to_include ) ) {
     14    foreach ( $jetpack_tools_to_include as $tool ) {
     15        if ( file_exists( JETPACK__PLUGIN_DIR . '/modules/' . $tool ) ) {
     16            require_once( JETPACK__PLUGIN_DIR . '/modules/' . $tool );
    3817        }
    3918    }
    4019}
    41 add_action( 'setup_theme', 'jetpack_load_infinite_scroll_annotation' );
    42 
    43 /**
    44  * Prevent IS from being activated if theme doesn't support it
    45  *
    46  * @param bool $can_activate
    47  * @filter jetpack_can_activate_infinite-scroll
    48  * @return bool
    49  */
    50 function jetpack_can_activate_infinite_scroll( $can_activate ) {
    51     return (bool) current_theme_supports( 'infinite-scroll' );
    52 }
    53 add_filter( 'jetpack_can_activate_infinite-scroll', 'jetpack_can_activate_infinite_scroll' );
    54 
    55 // Happy Holidays!
    56 require_once( dirname( __FILE__ ) . '/holiday-snow.php' );
    57 
    58 require_once( dirname( __FILE__ ) . '/featured-content/featured-content.php' );
    59 
    60 require_once( dirname( __FILE__ ) . '/social-links.php' );
    61 
    62 // Custom Post Types - we don't want a module card for these (yet)
    63 require_once( dirname( __FILE__ ) . '/custom-post-types/comics.php' );
    64 require_once( dirname( __FILE__ ) . '/custom-post-types/testimonial.php' );
Note: See TracChangeset for help on using the changeset viewer.