| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The file register assets for the plugin |
| 5 |
* |
| 6 |
* @package Tableberg |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace Tableberg; |
| 10 |
|
| 11 |
/** |
| 12 |
* Handle plugin assets |
| 13 |
*/ |
| 14 |
class Assets |
| 15 |
{ |
| 16 |
/** |
| 17 |
* Register block assets for frontend. |
| 18 |
* I.e. dynamic responsiveness |
| 19 |
*/ |
| 20 |
public function register_frontend_assets() |
| 21 |
{ |
| 22 |
wp_enqueue_script( |
| 23 |
'tableberg-frontend-script', |
| 24 |
TABLEBERG_URL . 'includes/assets/js/frontend.js', |
| 25 |
[], |
| 26 |
Constants::plugin_version(), |
| 27 |
true |
| 28 |
); |
| 29 |
} |
| 30 |
/** |
| 31 |
* Register blocks assets |
| 32 |
*/ |
| 33 |
public function register_blocks_assets() |
| 34 |
{ |
| 35 |
wp_register_script( |
| 36 |
'tableberg-script', |
| 37 |
TABLEBERG_URL . 'build/tableberg.build.js', |
| 38 |
array( |
| 39 |
'lodash', |
| 40 |
'react', |
| 41 |
'wp-block-editor', |
| 42 |
'wp-blocks', |
| 43 |
'wp-components', |
| 44 |
'wp-data', |
| 45 |
'wp-element', |
| 46 |
'wp-i18n', |
| 47 |
'wp-primitives', |
| 48 |
), |
| 49 |
Constants::plugin_version(), |
| 50 |
false |
| 51 |
); |
| 52 |
wp_register_style( |
| 53 |
'tableberg-editor-style', |
| 54 |
TABLEBERG_URL . 'build/tableberg-editor-style.css', |
| 55 |
array(), |
| 56 |
Constants::plugin_version(), |
| 57 |
false |
| 58 |
); |
| 59 |
wp_register_style( |
| 60 |
'tableberg-style', |
| 61 |
TABLEBERG_URL . 'build/tableberg-frontend-style.css', |
| 62 |
array(), |
| 63 |
Constants::plugin_version(), |
| 64 |
false |
| 65 |
); |
| 66 |
} |
| 67 |
/** |
| 68 |
* Enqueue Admin assets |
| 69 |
*/ |
| 70 |
public function register_admin_assets() |
| 71 |
{ |
| 72 |
wp_enqueue_script( |
| 73 |
'tableberg-admin-script', |
| 74 |
TABLEBERG_URL . 'build/tableberg-admin.build.js', |
| 75 |
array( |
| 76 |
'lodash', |
| 77 |
'react', |
| 78 |
'wp-block-editor', |
| 79 |
'wp-blocks', |
| 80 |
'wp-components', |
| 81 |
'wp-data', |
| 82 |
'wp-element', |
| 83 |
'wp-i18n', |
| 84 |
'wp-primitives', |
| 85 |
), |
| 86 |
Constants::plugin_version(), |
| 87 |
true |
| 88 |
); |
| 89 |
wp_enqueue_script( |
| 90 |
'tableberg-preview-device-change-observer', |
| 91 |
TABLEBERG_URL . 'includes/assets/js/PreviewDeviceChangeObserver.js', |
| 92 |
[], |
| 93 |
Constants::plugin_version(), |
| 94 |
true |
| 95 |
); |
| 96 |
$frontend_script_data = apply_filters('tableberg/filter/admin_settings_menu_data', array()); |
| 97 |
wp_localize_script('tableberg-admin-script', 'tablebergAdminMenuData', $frontend_script_data); |
| 98 |
wp_enqueue_style( |
| 99 |
'tableberg-admin-style', |
| 100 |
TABLEBERG_URL . 'build/tableberg-admin-style.css', |
| 101 |
array(), |
| 102 |
Constants::plugin_version(), |
| 103 |
'all' |
| 104 |
); |
| 105 |
} |
| 106 |
} |
| 107 |
|