|
109 | 109 | initEditor() { |
110 | 110 | console.log( 'PP Guided Tour: Initializing editor context', config ); |
111 | 111 |
|
| 112 | + // Close Extendify AI assistant for YourHosting (branding ID 5159). |
| 113 | + if ( config.brandingId && config.brandingId === 5159 ) { |
| 114 | + this.closeExtendifyAssistant(); |
| 115 | + } |
| 116 | + |
112 | 117 | // Wait for editor to be ready. |
113 | 118 | if ( typeof wp !== 'undefined' && wp.domReady ) { |
114 | 119 | wp.domReady( () => { |
115 | 120 | console.log( 'PP Guided Tour: wp.domReady fired' ); |
| 121 | + |
| 122 | + // Close Extendify editor sidebar for YourHosting. |
| 123 | + if ( config.brandingId && config.brandingId === 5159 ) { |
| 124 | + this.closeExtendifyEditorSidebar(); |
| 125 | + } |
| 126 | + |
116 | 127 | // Open Progress Planner sidebar. |
117 | 128 | this.openProgressPlannerSidebar(); |
118 | 129 | // Wait for driver.js and editor to be ready. |
|
123 | 134 | } else { |
124 | 135 | // Fallback. |
125 | 136 | console.log( 'PP Guided Tour: Using fallback timeout' ); |
| 137 | + |
| 138 | + // Close Extendify editor sidebar for YourHosting. |
| 139 | + if ( config.brandingId && config.brandingId === 5159 ) { |
| 140 | + this.closeExtendifyEditorSidebar(); |
| 141 | + } |
| 142 | + |
126 | 143 | this.openProgressPlannerSidebar(); |
127 | 144 | this.waitForDriver( () => { |
128 | 145 | setTimeout( () => this.resumeEditorTour(), 2000 ); |
129 | 146 | } ); |
130 | 147 | } |
131 | 148 | }, |
132 | 149 |
|
| 150 | + /** |
| 151 | + * Close the Extendify editor sidebar (AI Tools button). |
| 152 | + * Used for YourHosting installations to show PP sidebar instead. |
| 153 | + */ |
| 154 | + closeExtendifyEditorSidebar() { |
| 155 | + try { |
| 156 | + // Find the Extendify AI Tools button. |
| 157 | + const extendifyButton = document.querySelector( |
| 158 | + 'button[aria-controls^="extendify-draft"]' |
| 159 | + ); |
| 160 | + |
| 161 | + if ( ! extendifyButton ) { |
| 162 | + // Button not found yet, retry after a short delay. |
| 163 | + setTimeout( () => this.closeExtendifyEditorSidebar(), 500 ); |
| 164 | + return; |
| 165 | + } |
| 166 | + |
| 167 | + // Check if sidebar is open. |
| 168 | + if ( extendifyButton.getAttribute( 'aria-expanded' ) === 'true' ) { |
| 169 | + // Click to close the sidebar. |
| 170 | + extendifyButton.click(); |
| 171 | + } |
| 172 | + } catch ( e ) { |
| 173 | + // Silently fail - don't break tour if Extendify handling fails. |
| 174 | + console.warn( 'PP Guided Tour: Could not close Extendify editor sidebar', e ); |
| 175 | + } |
| 176 | + }, |
| 177 | + |
133 | 178 | /** |
134 | 179 | * Open the Progress Planner sidebar in the block editor. |
135 | 180 | */ |
|
1453 | 1498 | * Show tour completion message. |
1454 | 1499 | */ |
1455 | 1500 | showCompletionMessage() { |
| 1501 | + console.log( 'PP Guided Tour: showCompletionMessage called', { |
| 1502 | + brandingId: config.brandingId, |
| 1503 | + isYourHosting: config.brandingId === 5159, |
| 1504 | + } ); |
| 1505 | + |
1456 | 1506 | // Check for YourHosting branding (with safeguard). |
1457 | 1507 | if ( config.brandingId && config.brandingId === 5159 ) { |
1458 | 1508 | this.showYourHostingCompletionMessage(); |
|
1495 | 1545 | * Show YourHosting-specific completion message with publish CTA. |
1496 | 1546 | */ |
1497 | 1547 | showYourHostingCompletionMessage() { |
| 1548 | + console.log( 'PP Guided Tour: showYourHostingCompletionMessage called' ); |
| 1549 | + |
1498 | 1550 | try { |
1499 | 1551 | const notification = document.createElement( 'div' ); |
1500 | 1552 | notification.className = 'pp-guided-tour-complete-notice pp-guided-tour-yourhosting-complete'; |
|
1510 | 1562 | `; |
1511 | 1563 |
|
1512 | 1564 | document.body.appendChild( notification ); |
| 1565 | + console.log( 'PP Guided Tour: YourHosting completion message appended to body' ); |
1513 | 1566 |
|
1514 | 1567 | // Find and link to the publish button (with safeguard). |
1515 | 1568 | const publishBtn = notification.querySelector( '#pp-yourhosting-publish-btn' ); |
1516 | 1569 | const adminBarPublish = document.querySelector( '#wp-admin-bar-iwp_migration_btn a' ); |
1517 | 1570 |
|
| 1571 | + console.log( 'PP Guided Tour: Publish button elements', { |
| 1572 | + publishBtn: !! publishBtn, |
| 1573 | + adminBarPublish: !! adminBarPublish, |
| 1574 | + adminBarPublishHref: adminBarPublish?.href, |
| 1575 | + } ); |
| 1576 | + |
1518 | 1577 | if ( publishBtn && adminBarPublish ) { |
1519 | 1578 | publishBtn.href = adminBarPublish.href; |
1520 | 1579 | } else if ( publishBtn ) { |
|
0 commit comments