-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into dev/build
- Loading branch information
Showing
18 changed files
with
259 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { subscribe, select } from '@wordpress/data'; | ||
|
||
/** | ||
Check failure on line 3 in assets/apps/dashboard/src/utils/module-observer.js
|
||
* Append New Sub Menu Page. | ||
* | ||
* The page will be added after the parent container of the linkSelector. | ||
* | ||
* @param {string} linkSelector The link selector to determine the position of the added submenu page. | ||
* @param {Object} subMenuData The Sub Menu data to be added. | ||
* @return {HTMLAnchorElement} Custom Layouts menu page. | ||
*/ | ||
function appendNewSubMenuPage(linkSelector, subMenuData) { | ||
// Create and configure a new anchor element | ||
const link = document.createElement('a'); | ||
link.setAttribute('href', subMenuData?.linkSubMenu); | ||
link.textContent = subMenuData?.labelSubMenu; | ||
|
||
const linkToAppendAfter = document.querySelector(linkSelector); | ||
if (!linkToAppendAfter) { | ||
return; | ||
} | ||
|
||
// Append the after the Customizer menu item. | ||
const listNode = linkToAppendAfter.parentNode; | ||
const container = document.createElement('li'); | ||
container.appendChild(link); | ||
listNode.parentNode.insertBefore(container, listNode.nextSibling); | ||
|
||
return link; | ||
} | ||
|
||
/** | ||
* Auto Sub Menu Pages on Admin Dashboard for Pro Modules. | ||
*/ | ||
function autoHideModuleSubMenuPages() { | ||
let clLinkElem = document.querySelector( | ||
'.toplevel_page_neve-welcome a[href*="edit.php?post_type=neve_custom_layouts"]' | ||
); | ||
|
||
subscribe(() => { | ||
/** | ||
* Auto hide Custom Layouts submenu page link based on module status. | ||
*/ | ||
const isModuleEnabled = | ||
select('neve-dashboard').getModuleStatus('custom_layouts'); | ||
|
||
if (isModuleEnabled && !clLinkElem) { | ||
clLinkElem = appendNewSubMenuPage( | ||
'.toplevel_page_neve-welcome .wp-submenu a[href*="customize.php"]', | ||
window?.neveDash?.moduleObserver?.customLayouts | ||
); | ||
} else if (!isModuleEnabled && clLinkElem) { | ||
clLinkElem.parentNode.remove(); | ||
clLinkElem = undefined; | ||
} | ||
}); | ||
} | ||
|
||
function run() { | ||
// Run only on the Neve Pro tab. | ||
if (window.location.hash === '#pro') { | ||
autoHideModuleSubMenuPages(); | ||
} | ||
} | ||
|
||
if (document.readyState !== 'loading') { | ||
run(); | ||
} else { | ||
document.addEventListener('DOMContentLoaded', function () { | ||
run(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.