Description
Create a Responsive Pricing Table (RPT) using bw_table/bw_csv logic converted to use divsSo where with bw_csv we have [bw_csv]Field,Single,Multi,Unlimited Price,9,19,29 Buy now,link 1,link 2,link3 [/bw_csv] we would have the same source but use the [bw_rpt] shortcode We create a series of divs rather than table cells. We build the whole table and then take each column and convert it into a div. The labels in the first column are used to create the CSS class name for each row The headings in the first row are currently ignored
Usage
bw_rpt( $atts, $content, $tag );Parameters
- $atts
- ( mixed ) optional –
- $content
- ( mixed ) optional –
- $tag
- ( mixed ) optional –
Returns
voidSource
File name: oik-bob-bing-wide/shortcodes/oik-pricing-table.phpLines:
1 to 46 of 46
function bw_rpt( $atts=null, $content=null, $tag=null ) { oik_require( "classes/class-oik-tables.php", "oik-bob-bing-wide" ); $table = new OIK_table(); if ( $content ) { $table->load_table( $content ); } else { $src = bw_array_get_from( $atts, "src,0", null ); if ( $src ) { if ( is_numeric( $src ) ) { $src = wp_get_attachment_url( $src ); } $table->load_table_from_file( $src ); } else { p( "Invalid use of bw_rpt. src= parameter not set" ); } } $columns = $table->columns(); //echo "Cols: $columns" ; $labels = bw_array_get( $atts, "labels", false ); if ( $labels ) { $start_column = 0; } else { $start_column = 1; } $responsive_column_class = bw_responsive_column_class( $columns - $start_column, $start_column, $atts ); $columns--; $rows = $table->rows(); //echo "Rows: $rows" ; $rows--; $class = bw_array_get( $atts, "class", null ); sdiv( "bw_rpt $class" ); for ( $column = $start_column; $column <= $columns; $column++ ) { sdiv( "bw_rpt_cols_$columns bw_rpt_c_$column $responsive_column_class" ); for ( $row=1; $row <= $rows; $row++ ) { $label = bw_label_namify( $table->cell( $row, 0 )); sdiv( "bw_rpt_{$column}_{$row} bw_rpt_$label" ); e( $table->cell( $row, $column ) ); ediv(); } ediv(); } ediv(); return( bw_ret() ); }View on GitHub
Called by
Invoked by
Calls
1 to 6 of 6
- bw_label_namify() – Namify the label so that it can be used for a CSS class
- bw_responsive_column_class() – Create a responsive table column class definition
- bw_ret() – Use bw_ret() to return the contents of $bwecho, leaving the global value as NULL
- ediv() – End a div
- p() – Output a paragraph of translatable text
- sdiv() – Start a div
Call hooks
API Letters:
