PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.2.0
Kubio AI Page Builder v2.2.0
2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / customizer / index.php
kubio / lib / customizer Last commit date
index.php 2 years ago
index.php
99 lines
1 <?php
2
3 use Kubio\Core\Utils;
4
5 function kubio_set_admin_bar_menu_customize_to_kubio_editor( WP_Admin_Bar &$admin_bar ) {
6
7 if ( ! is_user_logged_in() || ! kubio_theme_has_kubio_block_support() ) {
8 return;
9 }
10
11 $url = kubio_frontend_get_editor_url();
12 $appearanceNode = $admin_bar->get_node( 'customize' );
13 if ( ! $appearanceNode ) {
14 return;
15 }
16 $appearanceNode->href = $url;
17 $admin_bar->add_node( $appearanceNode );
18 }
19
20 function kubio_set_admin_bar_customize_to_kubio_editor() {
21 if ( ! kubio_theme_has_kubio_block_support() ) {
22 return;
23 }
24 global $submenu;
25 if ( ! isset( $submenu['themes.php'] ) ) {
26 return;
27 }
28
29 foreach ( $submenu['themes.php'] as $key => $theme_submenu ) {
30 $slug = $theme_submenu[1];
31 if ( $slug !== 'customize' ) {
32 continue;
33 }
34 $submenu['themes.php'][ $key ][2] = 'admin.php?page=kubio';
35 }
36
37 }
38
39 function kubio_update_theme_page_customize_url( $prepared_themes ) {
40 if ( ! kubio_theme_has_kubio_block_support() ) {
41 return $prepared_themes;
42 }
43 foreach ( $prepared_themes as $key => $theme ) {
44 if ( $theme['active'] === true ) {
45 $prepared_themes[ $key ]['actions']['customize'] = Utils::kubioGetEditorURL();
46 }
47 }
48
49 return $prepared_themes;
50 }
51
52 function kubio_update_dashboard_customizer_url() {
53
54
55 $request_uri = $_SERVER['REQUEST_URI'];
56 $is_dashboard_admin_or_theme = str_contains( $request_uri, 'wp-admin/index.php' ) || str_contains( $request_uri, 'wp-admin/themes.php' );
57
58 //Dashboard page or theme page
59 if ( ! $is_dashboard_admin_or_theme ) {
60 return;
61 }
62
63 $kubio_url = Utils::kubioGetEditorURL();
64 ob_start();
65 ?>
66 <script>
67 (function($) {
68 $(document).ready(function(){
69
70 <?php if ( kubio_theme_has_kubio_block_support() ) : ?>
71 var customizeLink = document.querySelector('a.load-customize');
72 if(customizeLink) {
73 customizeLink.setAttribute('href', <?php echo wp_json_encode( $kubio_url ); ?>);
74 }
75 <?php endif; ?>
76
77
78 //in the active theme page replace the edit with kubio link
79 var themeSingleTemplate = document.querySelector('#tmpl-theme-single')
80 if(themeSingleTemplate) {
81 let innerHtml = themeSingleTemplate.innerHTML;
82 let newInnerHtml = innerHtml.replace(/href='([^']*page=kubio)'/, "href='" + <?php echo wp_json_encode( $kubio_url ); ?> + "'");
83 themeSingleTemplate.innerHTML = newInnerHtml;
84 }
85 })
86 })(jQuery)
87 </script>
88 <?php
89 $script = strip_tags( ob_get_clean() );
90 wp_add_inline_script( 'jquery', $script );
91 return;
92 }
93
94 add_filter( 'admin_init', 'kubio_update_dashboard_customizer_url' );
95 add_action( 'wp_prepare_themes_for_js', 'kubio_update_theme_page_customize_url', 1000 );
96 add_action( 'admin_bar_menu', 'kubio_set_admin_bar_menu_customize_to_kubio_editor', 1000 );
97 add_action( 'admin_menu', 'kubio_set_admin_bar_customize_to_kubio_editor', 1000 );
98
99