| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
add_action( 'admin_enqueue_scripts', 'bppiv_custom_admin_style' ); |
| 7 |
add_action('admin_menu', 'bppiv_add_submenu_page'); |
| 8 |
add_action( 'admin_enqueue_scripts', 'bppiv_adminEnqueueScripts' ); |
| 9 |
|
| 10 |
function bppiv_custom_admin_style() { |
| 11 |
$current = function_exists('get_current_screen') ? get_current_screen() : null; |
| 12 |
$post_type = $current && isset($current->post_type) ? $current->post_type : ''; |
| 13 |
$screen_id = $current && isset($current->id) ? $current->id : ''; |
| 14 |
|
| 15 |
$is_bppiv_screen = ( strpos( $screen_id, 'bppiv-image-viewer' ) !== false ) || in_array( $post_type, ['bppiv-image-viewer', 'virtual_tour', 'product_spot'], true ); |
| 16 |
|
| 17 |
if ( $is_bppiv_screen ) { |
| 18 |
wp_register_style( 'bppiv_admin_custom_css', plugin_dir_url(__FILE__) . 'style.css', false, BPPIV_VERSION ); |
| 19 |
wp_enqueue_style( 'bppiv_admin_custom_css' ); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
function bppiv_add_submenu_page(){ |
| 24 |
add_submenu_page( |
| 25 |
'edit.php?post_type=bppiv-image-viewer', |
| 26 |
'Help & Demos', |
| 27 |
'<span style="color: #f18500; font-weight: 600;">Help & Demos</span>', |
| 28 |
'manage_options', |
| 29 |
'bppiv-support', |
| 30 |
'bppiv_dashboard_page' |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
function bppiv_dashboard_page(){ ?> |
| 35 |
<div |
| 36 |
id='bppivCurrentDashboard' |
| 37 |
data-info='<?php echo esc_attr( wp_json_encode( [ |
| 38 |
'version' => BPPIV_VERSION, |
| 39 |
'isPremium' => false, |
| 40 |
'hasPro' => false, |
| 41 |
'adminUrl' => admin_url(), |
| 42 |
'deleteDataOnUninstall' => (bool) get_option( 'bppiv_delete_data_on_uninstall', false ), |
| 43 |
'uninstallNonce' => wp_create_nonce( 'bppiv_uninstall_nonce' ), |
| 44 |
] ) ); ?>' |
| 45 |
></div> |
| 46 |
<?php } |
| 47 |
|
| 48 |
function bppiv_adminEnqueueScripts( $screen ) { |
| 49 |
|
| 50 |
if( $screen == 'bppiv-image-viewer_page_bppiv-support'){ |
| 51 |
wp_enqueue_style( 'current-admin-dashboard-style', BPPIV_PLUGIN_DIR . 'build/style-admin-dashboard.css', [], BPPIV_VERSION ); |
| 52 |
wp_enqueue_style( 'current-admin-dashboard', BPPIV_PLUGIN_DIR . 'build/admin-dashboard.css', [], BPPIV_VERSION ); |
| 53 |
wp_enqueue_script( 'current-admin-dashboard', BPPIV_PLUGIN_DIR . 'build/admin-dashboard.js', [ 'react', 'react-dom', 'wp-util' ], BPPIV_VERSION, true ); |
| 54 |
} |
| 55 |
|
| 56 |
$current = function_exists('get_current_screen') ? get_current_screen() : null; |
| 57 |
$post_type = $current && isset($current->post_type) ? $current->post_type : ''; |
| 58 |
|
| 59 |
if ( in_array( $post_type, ['bppiv-image-viewer', 'virtual_tour', 'product_spot', 'product'], true ) ) { |
| 60 |
wp_enqueue_script('current-admin-post', BPPIV_PLUGIN_DIR . 'build/admin-post.js', [], BPPIV_VERSION, true); |
| 61 |
wp_enqueue_style('current-admin-post', BPPIV_PLUGIN_DIR . 'build/admin-post.css', [], BPPIV_VERSION); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|