| 1 |
<?php |
| 2 |
/** |
| 3 |
* Frontend Template Tag functions, only available when the Frontend Controller is loaded. |
| 4 |
* |
| 5 |
* @package TablePress |
| 6 |
* @subpackage Frontend Template Tag functions |
| 7 |
* @author Tobias Bäthge |
| 8 |
* @since 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* Provides template tag functionality for the "table" Shortcode, to be used anywhere in the template, returns the table HTML. |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
* |
| 16 |
* @param string|array<string, mixed> $table_query Query-string-like list or array of parameters for Shortcode "table" rendering. |
| 17 |
* @return string HTML of the rendered table. |
| 18 |
*/ |
| 19 |
function tablepress_get_table( /* string|array */ $table_query ): string { |
| 20 |
if ( is_array( $table_query ) ) { |
| 21 |
$atts = $table_query; |
| 22 |
} else { |
| 23 |
parse_str( (string) $table_query, $atts ); |
| 24 |
} |
| 25 |
return TablePress::$controller->shortcode_table( $atts ); // @phpstan-ignore argument.type |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Provides template tag functionality for the "table" Shortcode, to be used anywhere in the template, echoes the table HTML. |
| 30 |
* |
| 31 |
* @since 1.0.0 |
| 32 |
* |
| 33 |
* @see tablepress_get_table() |
| 34 |
* |
| 35 |
* @param string|array<string, mixed> $table_query Query-string-like list or array of parameters for Shortcode "table" rendering. |
| 36 |
*/ |
| 37 |
function tablepress_print_table( /* string|array */ $table_query ): void { |
| 38 |
echo tablepress_get_table( $table_query ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Provides template tag functionality for the "table-info" Shortcode, to be used anywhere in the template, returns the info. |
| 43 |
* |
| 44 |
* @since 1.0.0 |
| 45 |
* |
| 46 |
* @param string|array<string, mixed> $table_query Query-string-like list or array of parameters for Shortcode "table-info" rendering. |
| 47 |
* @return string Desired table information. |
| 48 |
*/ |
| 49 |
function tablepress_get_table_info( /* string|array */ $table_query ): string { |
| 50 |
if ( is_array( $table_query ) ) { |
| 51 |
$atts = $table_query; |
| 52 |
} else { |
| 53 |
parse_str( (string) $table_query, $atts ); |
| 54 |
} |
| 55 |
return TablePress::$controller->shortcode_table_info( $atts ); // @phpstan-ignore argument.type |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Provides template tag functionality for the "table-info" Shortcode, to be used anywhere in the template, echoes the info. |
| 60 |
* |
| 61 |
* @since 1.0.0 |
| 62 |
* |
| 63 |
* @see tablepress_get_table_info() |
| 64 |
* |
| 65 |
* @param string|array<string, mixed> $table_query Query-string-like list or array of parameters for Shortcode "table-info" rendering. |
| 66 |
*/ |
| 67 |
function tablepress_print_table_info( /* string|array */ $table_query ): void { |
| 68 |
echo tablepress_get_table_info( $table_query ); |
| 69 |
} |
| 70 |
|