Last active
December 15, 2015 19:48
-
-
Save montrealist/5313565 to your computer and use it in GitHub Desktop.
Table shortcode generation bug in the Wordpress Quare theme (http://quare.themeple.co/) - only first table row gets properly wrapped with a `<tr>`, the rest of them do not. Check the revisions to see how it's fixed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!function_exists('themeple_str_lreplace')){ | |
function themeple_str_lreplace($search, $replace, $subject) | |
{ | |
$pos = strrpos($subject, $search); | |
if($pos !== false) | |
{ | |
$subject = substr_replace($subject, $replace, $pos, strlen($search)); | |
} | |
return $subject; | |
} | |
} | |
if(!function_exists('themeple_simple_table')){ | |
function themeple_simple_table( $atts ) { | |
extract( shortcode_atts( array('cols' => 'none', 'data' => 'none' ), $atts ) ); | |
$cols = explode(',',$cols); | |
$data = explode(',',$data); | |
$total = count($cols); | |
$output='<div class="themeple_sc">'; | |
$output .= '<table class="table table-bordered"><tr class="th">'; | |
foreach($cols as $col): | |
$output .= '<td>'.$col.'</td>'; | |
endforeach; | |
$output .= '</tr><tr>'; | |
$counter = 1; | |
foreach($data as $datum): | |
$output .= '<td>'.$datum.'</td>'; | |
if($counter%$total==0): | |
$output .= '</tr><tr>'; | |
endif; | |
$counter++; | |
endforeach; | |
$output = themeple_str_lreplace('<tr>','',$output); | |
$output .= '</table></div>'; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment