PluginProbe
TablePress – Tables in WordPress made easy / 3.0
TablePress – Tables in WordPress made easy v3.0
3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.4.4 All 44 releases
← All changes | classes/class-evaluate.php +8 -16 2.1.73.0 View file →
@@ -29,15 +29,15 @@
29 29 * @since 2.0.0
30 30 *
31 31 * @return bool Whether the legacy evaluate class should be used.
32 32 */
33 - protected function _should_use_legacy_evaluate_class() {
33 + protected function _should_use_legacy_evaluate_class(): bool {
34 34 /**
35 35 * Filters whether the Legacy Table Evaluate class shall be used.
36 36 *
37 37 * @since 2.0.0
38 38 *
39 - * @param bool Whether to use the legacy table evaluate class. Default false.
39 + * @param bool $use_legacy_class Whether to use the legacy table evaluate class. Default false.
40 40 */
41 41 if ( apply_filters( 'tablepress_use_legacy_table_evaluate_class', false ) ) {
42 42 return true;
43 43 }
@@ -42,19 +42,13 @@
42 42 return true;
43 43 }
44 44
45 45 // Use the legacy evaluate class, if the requirements for PHPSpreadsheet Calculations are not fulfilled.
46 - $phpspreadsheet_requirements_fulfilled = PHP_VERSION_ID >= 70200
47 - && extension_loaded( 'mbstring' );
46 + $phpspreadsheet_requirements_fulfilled = extension_loaded( 'mbstring' );
48 47 if ( ! $phpspreadsheet_requirements_fulfilled ) {
49 48 return true;
50 49 }
51 50
52 - // Use the legacy evaluate class, if the PHPSpreadsheet files do not exist (e.g. because `composer install` was not run).
53 - if ( ! file_exists( TABLEPRESS_ABSPATH . 'libraries/autoload.php' ) ) {
54 - return true;
55 - }
56 -
57 51 return false;
58 52 }
59 53
60 54 /**
@@ -61,17 +55,15 @@
61 55 * Evaluate formulas in the passed table.
62 56 *
63 57 * @since 1.0.0
64 58 *
65 - * @param array $table_data Table data in which formulas shall be evaluated.
66 - * @param string $table_id ID of the passed table.
67 - * @return array Table data with evaluated formulas.
59 + * @param array<int, array<int, string>> $table_data Table data in which formulas shall be evaluated.
60 + * @param string $table_id ID of the passed table.
61 + * @return array<int, array<int, string>> Table data with evaluated formulas.
68 62 */
69 - public function evaluate_table_data( array $table_data, $table_id ) {
70 - $use_legacy_evaluate_class = $this->_should_use_legacy_evaluate_class();
71 -
63 + public function evaluate_table_data( array $table_data, string $table_id ): array {
72 64 // Choose the Table Evaluate library based on the PHP version and the filter hook value.
73 - if ( $use_legacy_evaluate_class ) {
65 + if ( $this->_should_use_legacy_evaluate_class() ) {
74 66 $evaluate_class = TablePress::load_class( 'TablePress_Evaluate_Legacy', 'class-evaluate-legacy.php', 'classes' );
75 67 } else {
76 68 $evaluate_class = TablePress::load_class( 'TablePress_Evaluate_PHPSpreadsheet', 'class-evaluate-phpspreadsheet.php', 'classes' );
77 69 }