Making WordPress.org

Ticket #353: 353.patch

File 353.patch, 3.4 KB (added by nvwd, 11 years ago)

Add data-* attribute to table cells for use with media queries and the css to break the table for small screen viewing

  • wp-content/plugins/wc-post-types/css/wc-session-table.css

     
     1@media screen and ( max-width: 700px ) {
     2        .wcpt-schedule {
     3                border: none;
     4                width: 100%;
     5        }
     6        .wcpt-schedule thead {
     7                display: none;
     8        }
     9        .wcpt-schedule tbody,
     10        .wcpt-schedule tr,
     11        .wcpt-schedule th,
     12        .wcpt-schedule td {
     13                display: block;
     14        }
     15        .wcpt-schedule tr {
     16                border: 1px solid #464646;
     17                margin-bottom: 16px;
     18        }
     19        .wcpt-schedule td {
     20                border: none;
     21        }
     22        .wcpt-time {
     23                background-color: #464646;
     24                color: #d54e21;
     25                font-size: 22px;
     26                padding: 0 16px;
     27        }
     28        .wcpt-session-type-session {
     29                line-height: 1.4;
     30                margin-bottom: 16px;
     31        }
     32        .wcpt-session-type-session:before {
     33                color: #757575;
     34                content: attr( data-track-title );
     35                border-bottom: 1px dashed #cccccc;
     36                border-top: 1px dashed #cccccc;
     37                display: block;
     38                font-size: 110%;
     39                line-height: 1;
     40                margin-bottom: 8px;
     41                padding: 3px 10px;
     42        }
     43        .global-session .wcpt-session-type-session:before {
     44                display: none;
     45        }
     46        .wcpt-session-title {
     47                display: block;
     48                padding: 10px;
     49        }
     50        span.wcpt-session-speakers {
     51                display: block;
     52                padding-left: 20px;
     53        }
     54        span.wcpt-session-speakers:before {
     55                color: #464646;
     56                content: "Speaker: ";
     57                font-style: italic;
     58        }
     59        span.wcpt-session-speakers a {
     60                color: #21759b;
     61        }
     62}
  • wp-content/plugins/wc-post-types/wc-post-types.php

     
    2121                add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    2222                add_action( 'admin_print_styles', array( $this, 'admin_css' ) );
    2323                add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
     24                add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
    2425
    2526                add_action( 'save_post', array( $this, 'save_post_speaker' ), 10, 2 );
    2627                add_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 );
     
    189190        function admin_enqueue_scripts() {
    190191                wp_enqueue_style( 'campicons', plugins_url( 'fonts/campicons.css', __FILE__ ), array(), 1 );
    191192        }
     193       
     194        function wp_enqueue_scripts() {
     195                wp_enqueue_style( 'wc_session_table', plugins_url( 'css/wc-session-table.css', __FILE__ ), array(), 1 );
     196        }
    192197
    193198        /**
    194199         * Runs during admin_print_styles, does some CSS things.
     
    507512                                $colspan = 1;
    508513                                $classes = array();
    509514                                $session = get_post( $entry[ $term_id ] );
     515                                $session_tracks = wp_get_post_terms( $session->ID, 'wcb_track' );
     516                                $session_track_titles = implode( ', ', wp_list_pluck( $session_tracks, 'name' ) );
    510517                                $session_title = apply_filters( 'the_title', $session->post_title );
    511518                                $session_type = get_post_meta( $session->ID, '_wcpt_session_type', true );
    512519
     
    568575                                        }
    569576                                }
    570577
    571                                 $columns_html .= sprintf( '<td colspan="%d" class="%s">%s</td>', $colspan, esc_attr( implode( ' ', $classes ) ), $content );
     578                                $columns_html .= sprintf( '<td colspan="%d" class="%s" data-track-title="%s">%s</td>', $colspan, esc_attr( implode( ' ', $classes ) ), $session_track_titles, $content );
    572579                        }
    573580
    574581                        $global_session = $colspan == count( $columns ) ? ' global-session' : '';