| @@ -4,16 +4,24 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Tableberg\Patterns\RegisterPatterns; |
| 6 | 6 | |
| 7 | 7 | class Assets { |
| 8 | + /** | |
| 9 | + * The frontend view script gates pro features (sorting/search/pagination) | |
| 10 | + * on TABLEBERG_CFG.IS_PRO, so the config must exist on the frontend too. | |
| 11 | + */ | |
| 12 | + public function register_frontend_assets() { | |
| 13 | + self::pass_data_to_js('tableberg-table-view-script'); | |
| 14 | + } | |
| 15 | + | |
| 8 | 16 | public function register_blocks_assets() { |
| 9 | - self::pass_data_to_js('tableberg-script'); | |
| 17 | + self::pass_data_to_js('tableberg-table-editor-script'); | |
| 10 | 18 | |
| 11 | 19 | $tableberg_patterns = RegisterPatterns::get_all_registered_tableberg_patterns(); |
| 12 | 20 | $tableberg_pattern_categories = RegisterPatterns::get_all_registered_tableberg_pattern_categories(); |
| 13 | 21 | |
| 14 | - wp_localize_script('tableberg-script', 'tablebergPatterns', $tableberg_patterns); | |
| 15 | - wp_localize_script('tableberg-script', 'tablebergPatternCategories', $tableberg_pattern_categories); | |
| 22 | + wp_localize_script('tableberg-table-editor-script', 'tablebergPatterns', $tableberg_patterns); | |
| 23 | + wp_localize_script('tableberg-table-editor-script', 'tablebergPatternCategories', $tableberg_pattern_categories); | |
| 16 | 24 | |
| 17 | 25 | } |
| 18 | 26 | |
| 19 | 27 | public function register_admin_assets() { |
| @@ -51,15 +59,15 @@ | ||
| 51 | 59 | |
| 52 | 60 | private static function pass_data_to_js(string $handle) { |
| 53 | 61 | $data = [ |
| 54 | 62 | 'plugin_url' => TABLEBERG_URL, |
| 63 | + // Pro marks this true only after its licence check succeeds and | |
| 64 | + // its runtime extensions actually boot. The version constant only | |
| 65 | + // proves that the add-on PHP file was loaded. | |
| 66 | + 'IS_PRO' => (bool) apply_filters( | |
| 67 | + 'tableberg/is_pro_runtime_active', | |
| 68 | + false | |
| 69 | + ), | |
| 55 | 70 | ]; |
| 56 | - global $tp_fs; | |
| 57 | - if (isset($tp_fs)) { | |
| 58 | - $data['IS_PRO'] = $tp_fs->is__premium_only() | |
| 59 | - && $tp_fs->can_use_premium_code(); | |
| 60 | - } else { | |
| 61 | - $data['IS_PRO'] = false; | |
| 62 | - } | |
| 63 | 71 | wp_localize_script($handle, 'TABLEBERG_CFG', $data); |
| 64 | 72 | } |
| 65 | 73 | } |