Skip to content

Commit 0251c80

Browse files
committed
more yourhosting integration
1 parent d035dd9 commit 0251c80

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

guided-tour/guided-tour.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,21 @@
109109
initEditor() {
110110
console.log( 'PP Guided Tour: Initializing editor context', config );
111111

112+
// Close Extendify AI assistant for YourHosting (branding ID 5159).
113+
if ( config.brandingId && config.brandingId === 5159 ) {
114+
this.closeExtendifyAssistant();
115+
}
116+
112117
// Wait for editor to be ready.
113118
if ( typeof wp !== 'undefined' && wp.domReady ) {
114119
wp.domReady( () => {
115120
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+
116127
// Open Progress Planner sidebar.
117128
this.openProgressPlannerSidebar();
118129
// Wait for driver.js and editor to be ready.
@@ -123,13 +134,47 @@
123134
} else {
124135
// Fallback.
125136
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+
126143
this.openProgressPlannerSidebar();
127144
this.waitForDriver( () => {
128145
setTimeout( () => this.resumeEditorTour(), 2000 );
129146
} );
130147
}
131148
},
132149

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+
133178
/**
134179
* Open the Progress Planner sidebar in the block editor.
135180
*/
@@ -1453,6 +1498,11 @@
14531498
* Show tour completion message.
14541499
*/
14551500
showCompletionMessage() {
1501+
console.log( 'PP Guided Tour: showCompletionMessage called', {
1502+
brandingId: config.brandingId,
1503+
isYourHosting: config.brandingId === 5159,
1504+
} );
1505+
14561506
// Check for YourHosting branding (with safeguard).
14571507
if ( config.brandingId && config.brandingId === 5159 ) {
14581508
this.showYourHostingCompletionMessage();
@@ -1495,6 +1545,8 @@
14951545
* Show YourHosting-specific completion message with publish CTA.
14961546
*/
14971547
showYourHostingCompletionMessage() {
1548+
console.log( 'PP Guided Tour: showYourHostingCompletionMessage called' );
1549+
14981550
try {
14991551
const notification = document.createElement( 'div' );
15001552
notification.className = 'pp-guided-tour-complete-notice pp-guided-tour-yourhosting-complete';
@@ -1510,11 +1562,18 @@
15101562
`;
15111563

15121564
document.body.appendChild( notification );
1565+
console.log( 'PP Guided Tour: YourHosting completion message appended to body' );
15131566

15141567
// Find and link to the publish button (with safeguard).
15151568
const publishBtn = notification.querySelector( '#pp-yourhosting-publish-btn' );
15161569
const adminBarPublish = document.querySelector( '#wp-admin-bar-iwp_migration_btn a' );
15171570

1571+
console.log( 'PP Guided Tour: Publish button elements', {
1572+
publishBtn: !! publishBtn,
1573+
adminBarPublish: !! adminBarPublish,
1574+
adminBarPublishHref: adminBarPublish?.href,
1575+
} );
1576+
15181577
if ( publishBtn && adminBarPublish ) {
15191578
publishBtn.href = adminBarPublish.href;
15201579
} else if ( publishBtn ) {

0 commit comments

Comments
 (0)