Making WordPress.org

Changeset 5826


Ignore:
Timestamp:
08/21/2017 02:08:26 PM (7 years ago)
Author:
danielbachhuber
Message:

phpunit-test-reporter: Use full width template when available

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/phpunit-test-reporter.php

    r5805 r5826  
    2525add_action( 'init', array( 'PTR\Content_Model', 'action_init_register_role' ) );
    2626add_action( 'init', array( 'PTR\Display', 'action_init_register_shortcode' ) );
     27add_action( 'get_post_metadata', array( 'PTR\Display', 'filter_get_post_metadata' ), 10, 4 );
     28add_action( 'body_class', array( 'PTR\Display', 'filter_body_class' ) );
    2729add_action( 'post_class', array( 'PTR\Display', 'filter_post_class' ) );
    2830add_action( 'the_content', array( 'PTR\Display', 'filter_the_content' ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-display.php

    r5823 r5826  
    1212    public static function action_init_register_shortcode() {
    1313        add_shortcode( 'ptr-results', array( __CLASS__, 'render_results' ) );
     14    }
     15
     16    /**
     17     * Use the full width template by default when available
     18     */
     19    public static function filter_get_post_metadata( $check, $object_id, $meta_key, $single ) {
     20        if ( 'result' !== get_post_type( $object_id )
     21            || '_wp_page_template' !== $meta_key ) {
     22            return $check;
     23        }
     24        $template = 'page-templates/full-width.php';
     25        $full_width = get_stylesheet_directory() . '/' . $template;
     26        if ( ! file_exists( $full_width ) ) {
     27            return $check;
     28        }
     29        return $single ? $template : array( $template );
     30    }
     31
     32    /**
     33     * Filter body classes
     34     */
     35    public static function filter_body_class( $classes ) {
     36        if ( in_array( 'result-template-full-width', $classes, true ) ) {
     37            $classes[] = 'page-template-full-width';
     38        }
     39        return $classes;
    1440    }
    1541
Note: See TracChangeset for help on using the changeset viewer.