0) { $r = array_slice($r, $options['strip']); } // discard $ir = 1; // row number counter $ic = 1; // column number counter // Prepend a space character onto the 'class' value, if one exists. if (!empty($options['class'])) { $options['class'] = " {$options['class']}"; } $html = ""; if (!empty($caption)) { $html .= ""; } $html .= "evenOrOdd($ir) . "\">"; $ir++; $table_head = array_shift($r); foreach ($table_head as $v) { $html .= ""; $ic++; } $html .= ""; foreach ($r as $v) { $html .= "evenOrOdd($ir) . "\">"; $ir++; $ic = 1; // reset column counting foreach ($v as $td) { $html .= ""; $ic++; } $html .= ""; } $html .= '
$caption
evenOrOdd($ic) . "\">
$v
evenOrOdd($ic) . "\">$td
'; return $html; } function evenOrOdd ($x) { return ((int) $x % 2) ? 'odd' : 'even'; // cast to integer just in case } /** * WordPress Shortcode handler. */ function displayShortcode ($atts, $content = null) { $x = shortcode_atts(array( 'key' => false, // Google Doc ID 'class' => '', // Container element's custom class value 'gid' => false, // Sheet ID for a Google Spreadsheet, if only one 'summary' => 'Google Spreadsheet', // If spreadsheet, value for summary attribute 'strip' => 0 // If spreadsheet, how many rows to omit from top ), $atts); return $this->csvToHtml($x, $content); } } $inline_gdoc_viewer = new InlineGoogleSpreadsheetViewerPlugin(); add_shortcode('gdoc', array($inline_gdoc_viewer, 'displayShortcode'));