Background
1 year ago
Blocks
1 year ago
GlobalElements
3 years ago
Layout
4 years ago
License
2 years ago
Separators
4 years ago
StyleManager
1 year ago
Styles
4 years ago
Activation.php
1 year ago
Backup.php
4 years ago
CustomizerImporter.php
1 year ago
Deactivation.php
4 years ago
EditInKubioCustomizerPanel.php
4 years ago
Element.php
2 years ago
ElementBase.php
4 years ago
Importer.php
2 years ago
InnerBlocks.php
4 years ago
LodashBasic.php
2 years ago
Registry.php
3 years ago
Utils.php
1 year ago
EditInKubioCustomizerPanel.php
101 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kubio\Core; |
| 4 | |
| 5 | class EditInKubioCustomizerPanel extends \WP_Customize_Panel { |
| 6 | |
| 7 | |
| 8 | public function __construct( $manager, $id, $args = array() ) { |
| 9 | |
| 10 | $manager->add_section( |
| 11 | "{$id}-section", |
| 12 | array( 'panel' => $id ) |
| 13 | ); |
| 14 | |
| 15 | $manager->add_control( |
| 16 | "{$id}-control", |
| 17 | array( |
| 18 | 'section' => "{$id}-section", |
| 19 | 'settings' => array(), |
| 20 | 'type' => 'button', |
| 21 | 'capability' => 'manage_options', |
| 22 | ) |
| 23 | ); |
| 24 | |
| 25 | add_action( 'customize_controls_print_footer_scripts', array( $this, 'printScripts' ) ); |
| 26 | parent::__construct( $manager, $id, $args ); |
| 27 | } |
| 28 | |
| 29 | public function printScripts() { |
| 30 | ?> |
| 31 | <style> |
| 32 | .kubio-customizer-panel { |
| 33 | margin: 15px; |
| 34 | border: none !important; |
| 35 | } |
| 36 | |
| 37 | .kubio-customizer-panel .accordion-section-title { |
| 38 | cursor: default; |
| 39 | border: 1px solid #ddd !important; |
| 40 | box-shadow: none !important; |
| 41 | } |
| 42 | |
| 43 | .kubio-customizer-panel .accordion-section-title:after { |
| 44 | display: none; |
| 45 | } |
| 46 | |
| 47 | .kubio-customizer-panel p { |
| 48 | font-weight: normal; |
| 49 | font-size: 13px; |
| 50 | margin: 0 0 10px 0; |
| 51 | } |
| 52 | |
| 53 | .kubio-customizer-panel .button.button-primary svg { |
| 54 | fill: currentColor; |
| 55 | width: 1em; |
| 56 | height: 1em; |
| 57 | margin-right: 0.5em; |
| 58 | } |
| 59 | |
| 60 | .kubio-customizer-panel .button.button-primary { |
| 61 | align-items: center; |
| 62 | width: 100%; |
| 63 | display: flex; |
| 64 | justify-content: center; |
| 65 | padding: 5px 10px; |
| 66 | } |
| 67 | </style> |
| 68 | <?php |
| 69 | } |
| 70 | |
| 71 | protected function render() { |
| 72 | |
| 73 | $message = __( 'After installing the Kubio builder, all page contents editing will be done using the WordPress block editor instead of the Customizer.', 'kubio' ); |
| 74 | |
| 75 | if ( kubio_theme_has_block_templates_support() ) { |
| 76 | $message = __( 'After installing the Kubio builder, all site editing will be done using the WordPress block editor instead of the Customizer.', 'kubio' ); |
| 77 | } |
| 78 | |
| 79 | ?> |
| 80 | <li class="accordion-section kubio-customizer-panel"> |
| 81 | <div class="accordion-section-title"> |
| 82 | <p><?php echo esc_html( $message ); ?></p> |
| 83 | <p><?php esc_html_e( ' Please use the button below to open the Kubio editor.', 'kubio' ); ?></p> |
| 84 | <button class="button button-primary kubio-open-editor-panel-button"> |
| 85 | <?php echo wp_kses_post( KUBIO_LOGO_SVG ); ?> |
| 86 | <span><?php esc_html_e( 'Open Kubio Editor', 'kubio' ); ?></span> |
| 87 | </button> |
| 88 | <script> |
| 89 | (function () { |
| 90 | document.querySelector('.kubio-open-editor-panel-button').addEventListener('click', function () { |
| 91 | window.location = '<?php echo esc_url( add_query_arg( 'page', 'kubio', admin_url( 'admin.php' ) ) ); ?>'; |
| 92 | }) |
| 93 | })(); |
| 94 | </script> |
| 95 | </div> |
| 96 | </li> |
| 97 | <?php |
| 98 | } |
| 99 | |
| 100 | } |
| 101 |