2018-05-18 17:31:08 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2020-04-29 18:01:27 +00:00
|
|
|
import { Component, Suspense, lazy } from '@wordpress/element';
|
2019-06-13 19:58:21 +00:00
|
|
|
import { parse, stringify } from 'qs';
|
2019-07-11 17:22:26 +00:00
|
|
|
import { find, isEqual, last, omit } from 'lodash';
|
2019-05-14 03:58:37 +00:00
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
2019-07-05 08:15:49 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2020-02-14 02:23:21 +00:00
|
|
|
import {
|
|
|
|
getNewPath,
|
|
|
|
getPersistedQuery,
|
|
|
|
getHistory,
|
2021-01-07 16:53:31 +00:00
|
|
|
getQueryExcludedScreens,
|
|
|
|
getScreenFromPath,
|
2020-02-14 02:23:21 +00:00
|
|
|
} from '@woocommerce/navigation';
|
2020-04-29 18:01:27 +00:00
|
|
|
import { Spinner } from '@woocommerce/components';
|
2018-11-05 21:02:04 +00:00
|
|
|
|
2018-05-18 17:31:08 +00:00
|
|
|
/**
|
2018-10-18 04:37:28 +00:00
|
|
|
* Internal dependencies
|
2018-05-18 17:31:08 +00:00
|
|
|
*/
|
2020-08-13 02:05:22 +00:00
|
|
|
import getReports from '../analytics/report/get-reports';
|
|
|
|
import { isWCAdmin } from '../dashboard/utils';
|
2022-01-06 12:53:30 +00:00
|
|
|
import { getAdminSetting } from '~/utils/admin-settings';
|
2021-10-14 14:04:17 +00:00
|
|
|
import { NoMatch } from './NoMatch';
|
2020-06-03 20:42:30 +00:00
|
|
|
|
2020-04-29 18:01:27 +00:00
|
|
|
const AnalyticsReport = lazy( () =>
|
2020-08-13 02:05:22 +00:00
|
|
|
import( /* webpackChunkName: "analytics-report" */ '../analytics/report' )
|
2020-04-29 18:01:27 +00:00
|
|
|
);
|
|
|
|
const AnalyticsSettings = lazy( () =>
|
2020-08-13 02:05:22 +00:00
|
|
|
import(
|
|
|
|
/* webpackChunkName: "analytics-settings" */ '../analytics/settings'
|
|
|
|
)
|
2020-04-29 18:01:27 +00:00
|
|
|
);
|
|
|
|
const Dashboard = lazy( () =>
|
2020-08-13 02:05:22 +00:00
|
|
|
import( /* webpackChunkName: "dashboard" */ '../dashboard' )
|
2020-04-29 18:01:27 +00:00
|
|
|
);
|
2020-10-15 01:55:55 +00:00
|
|
|
|
2020-06-15 02:17:12 +00:00
|
|
|
const Homescreen = lazy( () =>
|
2020-08-13 02:05:22 +00:00
|
|
|
import( /* webpackChunkName: "homescreen" */ '../homescreen' )
|
2020-04-29 18:01:27 +00:00
|
|
|
);
|
|
|
|
const MarketingOverview = lazy( () =>
|
2020-08-13 02:05:22 +00:00
|
|
|
import(
|
|
|
|
/* webpackChunkName: "marketing-overview" */ '../marketing/overview'
|
|
|
|
)
|
2020-04-29 18:01:27 +00:00
|
|
|
);
|
2020-07-16 15:17:10 +00:00
|
|
|
const ProfileWizard = lazy( () =>
|
2020-08-13 02:05:22 +00:00
|
|
|
import( /* webpackChunkName: "profile-wizard" */ '../profile-wizard' )
|
2020-07-16 15:17:10 +00:00
|
|
|
);
|
2021-02-12 19:32:42 +00:00
|
|
|
const SettingsGroup = lazy( () =>
|
|
|
|
import( /* webpackChunkName: "profile-wizard" */ '../settings' )
|
|
|
|
);
|
2018-05-18 17:31:08 +00:00
|
|
|
|
2022-01-12 06:46:33 +00:00
|
|
|
const WCPaymentsWelcomePage = lazy( () =>
|
|
|
|
import(
|
|
|
|
/* webpackChunkName: "wcpay-payment-welcome-page" */ '../payments-welcome'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-06-26 23:00:23 +00:00
|
|
|
export const PAGES_FILTER = 'woocommerce_admin_pages_list';
|
|
|
|
|
2020-06-11 00:26:20 +00:00
|
|
|
export const getPages = () => {
|
2019-02-12 20:02:02 +00:00
|
|
|
const pages = [];
|
2021-08-24 11:39:48 +00:00
|
|
|
const initialBreadcrumbs = [
|
2022-01-06 12:53:30 +00:00
|
|
|
[ '', getAdminSetting( 'woocommerceTranslation' ) ],
|
2021-08-24 11:39:48 +00:00
|
|
|
];
|
2019-02-12 20:02:02 +00:00
|
|
|
|
2020-09-14 23:44:46 +00:00
|
|
|
pages.push( {
|
|
|
|
container: Homescreen,
|
|
|
|
path: '/',
|
|
|
|
breadcrumbs: [
|
|
|
|
...initialBreadcrumbs,
|
|
|
|
__( 'Home', 'woocommerce-admin' ),
|
|
|
|
],
|
|
|
|
wpOpenMenu: 'toplevel_page_woocommerce',
|
2020-12-02 22:56:24 +00:00
|
|
|
navArgs: {
|
|
|
|
id: 'woocommerce-home',
|
|
|
|
},
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'manage_woocommerce',
|
2020-09-14 23:44:46 +00:00
|
|
|
} );
|
2019-02-12 20:02:02 +00:00
|
|
|
|
2020-09-14 23:44:46 +00:00
|
|
|
if ( window.wcAdminFeatures.analytics ) {
|
2020-04-22 21:32:44 +00:00
|
|
|
pages.push( {
|
2020-09-14 23:44:46 +00:00
|
|
|
container: Dashboard,
|
|
|
|
path: '/analytics/overview',
|
2020-04-22 21:32:44 +00:00
|
|
|
breadcrumbs: [
|
|
|
|
...initialBreadcrumbs,
|
2020-09-14 23:44:46 +00:00
|
|
|
[
|
|
|
|
'/analytics/overview',
|
|
|
|
__( 'Analytics', 'woocommerce-admin' ),
|
|
|
|
],
|
|
|
|
__( 'Overview', 'woocommerce-admin' ),
|
2020-04-22 21:32:44 +00:00
|
|
|
],
|
2020-09-14 23:44:46 +00:00
|
|
|
wpOpenMenu: 'toplevel_page_wc-admin-path--analytics-overview',
|
2020-12-02 22:56:24 +00:00
|
|
|
navArgs: {
|
|
|
|
id: 'woocommerce-analytics-overview',
|
|
|
|
},
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'view_woocommerce_reports',
|
2020-04-22 21:32:44 +00:00
|
|
|
} );
|
2019-02-12 20:02:02 +00:00
|
|
|
pages.push( {
|
2019-01-31 01:04:11 +00:00
|
|
|
container: AnalyticsSettings,
|
|
|
|
path: '/analytics/settings',
|
2019-07-05 08:15:49 +00:00
|
|
|
breadcrumbs: [
|
2020-03-23 22:57:16 +00:00
|
|
|
...initialBreadcrumbs,
|
2020-02-14 02:23:21 +00:00
|
|
|
[
|
|
|
|
'/analytics/revenue',
|
|
|
|
__( 'Analytics', 'woocommerce-admin' ),
|
|
|
|
],
|
2019-07-05 08:15:49 +00:00
|
|
|
__( 'Settings', 'woocommerce-admin' ),
|
|
|
|
],
|
2020-09-14 23:44:46 +00:00
|
|
|
wpOpenMenu: 'toplevel_page_wc-admin-path--analytics-overview',
|
2020-12-02 22:56:24 +00:00
|
|
|
navArgs: {
|
|
|
|
id: 'woocommerce-analytics-settings',
|
|
|
|
},
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'view_woocommerce_reports',
|
2019-02-12 20:02:02 +00:00
|
|
|
} );
|
2020-02-20 11:59:02 +00:00
|
|
|
pages.push( {
|
|
|
|
container: AnalyticsReport,
|
|
|
|
path: '/customers',
|
2020-03-23 22:57:16 +00:00
|
|
|
breadcrumbs: [
|
|
|
|
...initialBreadcrumbs,
|
|
|
|
__( 'Customers', 'woocommerce-admin' ),
|
|
|
|
],
|
2020-02-20 11:59:02 +00:00
|
|
|
wpOpenMenu: 'toplevel_page_woocommerce',
|
2020-12-02 22:56:24 +00:00
|
|
|
navArgs: {
|
|
|
|
id: 'woocommerce-analytics-customers',
|
|
|
|
},
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'view_woocommerce_reports',
|
2020-02-20 11:59:02 +00:00
|
|
|
} );
|
2019-02-12 20:02:02 +00:00
|
|
|
pages.push( {
|
2018-05-18 17:31:08 +00:00
|
|
|
container: AnalyticsReport,
|
|
|
|
path: '/analytics/:report',
|
2019-07-05 08:15:49 +00:00
|
|
|
breadcrumbs: ( { match } ) => {
|
2020-02-14 02:23:21 +00:00
|
|
|
const report = find( getReports(), {
|
|
|
|
report: match.params.report,
|
|
|
|
} );
|
2019-07-05 08:15:49 +00:00
|
|
|
if ( ! report ) {
|
|
|
|
return [];
|
|
|
|
}
|
2020-02-14 02:23:21 +00:00
|
|
|
return [
|
2020-03-23 22:57:16 +00:00
|
|
|
...initialBreadcrumbs,
|
2020-02-14 02:23:21 +00:00
|
|
|
[
|
|
|
|
'/analytics/revenue',
|
|
|
|
__( 'Analytics', 'woocommerce-admin' ),
|
|
|
|
],
|
|
|
|
report.title,
|
|
|
|
];
|
2019-07-05 08:15:49 +00:00
|
|
|
},
|
2020-09-14 23:44:46 +00:00
|
|
|
wpOpenMenu: 'toplevel_page_wc-admin-path--analytics-overview',
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'view_woocommerce_reports',
|
2019-02-12 20:02:02 +00:00
|
|
|
} );
|
|
|
|
}
|
2018-05-18 17:31:08 +00:00
|
|
|
|
2020-03-28 13:48:27 +00:00
|
|
|
if ( window.wcAdminFeatures.marketing ) {
|
|
|
|
pages.push( {
|
|
|
|
container: MarketingOverview,
|
|
|
|
path: '/marketing',
|
|
|
|
breadcrumbs: [
|
|
|
|
...initialBreadcrumbs,
|
2020-07-16 15:17:10 +00:00
|
|
|
[ '/marketing', __( 'Marketing', 'woocommerce-admin' ) ],
|
2020-06-12 21:55:15 +00:00
|
|
|
__( 'Overview', 'woocommerce-admin' ),
|
2020-03-28 13:48:27 +00:00
|
|
|
],
|
2020-06-12 21:55:15 +00:00
|
|
|
wpOpenMenu: 'toplevel_page_woocommerce-marketing',
|
2020-12-02 22:56:24 +00:00
|
|
|
navArgs: {
|
|
|
|
id: 'woocommerce-marketing-overview',
|
|
|
|
},
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'view_woocommerce_reports',
|
2020-03-28 13:48:27 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2020-07-16 15:17:10 +00:00
|
|
|
if ( window.wcAdminFeatures.onboarding ) {
|
|
|
|
pages.push( {
|
|
|
|
container: ProfileWizard,
|
2020-08-27 12:10:23 +00:00
|
|
|
path: '/setup-wizard',
|
2020-07-16 15:17:10 +00:00
|
|
|
breadcrumbs: [
|
|
|
|
...initialBreadcrumbs,
|
2022-01-26 20:28:52 +00:00
|
|
|
__( 'Setup Wizard', 'woocommerce-admin' ),
|
2020-07-16 15:17:10 +00:00
|
|
|
],
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'manage_woocommerce',
|
2020-07-16 15:17:10 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2021-02-12 19:32:42 +00:00
|
|
|
if ( window.wcAdminFeatures.settings ) {
|
|
|
|
pages.push( {
|
|
|
|
container: SettingsGroup,
|
|
|
|
path: '/settings/:page',
|
|
|
|
breadcrumbs: ( { match } ) => {
|
|
|
|
// @todo This might need to be refactored to retreive groups via data store.
|
2022-01-06 12:53:30 +00:00
|
|
|
const settingsPages = getAdminSetting( 'settingsPages' );
|
2021-02-12 19:32:42 +00:00
|
|
|
const page = settingsPages[ match.params.page ];
|
|
|
|
if ( ! page ) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
...initialBreadcrumbs,
|
|
|
|
[
|
|
|
|
settingsPages.general
|
|
|
|
? '/settings/general'
|
|
|
|
: `/settings/${
|
|
|
|
Object.keys( settingsPages )[ 0 ]
|
|
|
|
}`,
|
|
|
|
__( 'Settings', 'woocommerce-admin' ),
|
|
|
|
],
|
|
|
|
page,
|
|
|
|
];
|
|
|
|
},
|
|
|
|
wpOpenMenu: 'toplevel_page_woocommerce',
|
2021-02-19 13:57:17 +00:00
|
|
|
capability: 'manage_woocommerce',
|
2021-02-12 19:32:42 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2022-01-12 06:46:33 +00:00
|
|
|
if ( window.wcAdminFeatures[ 'wc-pay-welcome-page' ] ) {
|
|
|
|
pages.push( {
|
|
|
|
container: WCPaymentsWelcomePage,
|
|
|
|
path: '/wc-pay-welcome-page',
|
|
|
|
breadcrumbs: [
|
|
|
|
[
|
|
|
|
'/wc-pay-welcome-page',
|
|
|
|
__( 'WooCommerce Payments', 'woocommerce-admin' ),
|
|
|
|
],
|
|
|
|
__( 'WooCommerce Payments', 'woocommerce-admin' ),
|
|
|
|
],
|
|
|
|
navArgs: {
|
|
|
|
id: 'woocommerce-wc-pay-welcome-page',
|
|
|
|
},
|
|
|
|
wpOpenMenu: 'toplevel_page_woocommerce-wc-pay-welcome-page',
|
|
|
|
capability: 'manage_woocommerce',
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* List of WooCommerce Admin pages.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_pages_list
|
|
|
|
* @param {Array.<Object>} pages Array page objects.
|
|
|
|
*/
|
2021-10-14 14:04:17 +00:00
|
|
|
const filteredPages = applyFilters( PAGES_FILTER, pages );
|
|
|
|
|
|
|
|
filteredPages.push( {
|
|
|
|
container: NoMatch,
|
|
|
|
path: '*',
|
|
|
|
breadcrumbs: [
|
|
|
|
...initialBreadcrumbs,
|
|
|
|
__( 'Not allowed', 'woocommerce-admin' ),
|
|
|
|
],
|
|
|
|
wpOpenMenu: 'toplevel_page_woocommerce',
|
|
|
|
} );
|
|
|
|
|
|
|
|
return filteredPages;
|
2018-05-18 17:31:08 +00:00
|
|
|
};
|
|
|
|
|
2019-06-26 23:00:23 +00:00
|
|
|
export class Controller extends Component {
|
2019-04-08 17:53:28 +00:00
|
|
|
componentDidMount() {
|
|
|
|
window.document.documentElement.scrollTop = 0;
|
2020-10-16 18:47:29 +00:00
|
|
|
window.document.body.classList.remove( 'woocommerce-admin-is-loading' );
|
2019-04-08 17:53:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 02:55:06 +00:00
|
|
|
componentDidUpdate( prevProps ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
const prevBaseQuery = omit(
|
2020-07-14 12:20:51 +00:00
|
|
|
prevProps.query,
|
2020-06-01 23:03:26 +00:00
|
|
|
'chartType',
|
|
|
|
'filter',
|
2020-02-14 02:23:21 +00:00
|
|
|
'paged'
|
|
|
|
);
|
|
|
|
const baseQuery = omit(
|
2020-07-14 12:20:51 +00:00
|
|
|
this.props.query,
|
2020-06-01 23:03:26 +00:00
|
|
|
'chartType',
|
|
|
|
'filter',
|
2020-02-14 02:23:21 +00:00
|
|
|
'paged'
|
|
|
|
);
|
2019-02-04 02:55:06 +00:00
|
|
|
|
2020-07-28 02:32:58 +00:00
|
|
|
if (
|
|
|
|
prevProps.query.paged > 1 &&
|
|
|
|
! isEqual( prevBaseQuery, baseQuery )
|
|
|
|
) {
|
2019-07-11 17:22:26 +00:00
|
|
|
getHistory().replace( getNewPath( { paged: 1 } ) );
|
2019-02-04 02:55:06 +00:00
|
|
|
}
|
2019-04-08 17:53:28 +00:00
|
|
|
|
|
|
|
if ( prevProps.match.url !== this.props.match.url ) {
|
|
|
|
window.document.documentElement.scrollTop = 0;
|
|
|
|
}
|
2019-02-04 02:55:06 +00:00
|
|
|
}
|
|
|
|
|
2018-05-18 17:31:08 +00:00
|
|
|
render() {
|
2020-07-14 12:20:51 +00:00
|
|
|
const { page, match, query } = this.props;
|
2019-06-13 19:58:21 +00:00
|
|
|
const { url, params } = match;
|
2019-04-11 18:31:31 +00:00
|
|
|
|
2019-11-28 20:54:15 +00:00
|
|
|
window.wpNavMenuUrlUpdate( query );
|
2019-06-13 19:58:21 +00:00
|
|
|
window.wpNavMenuClassChange( page, url );
|
2020-04-29 18:01:27 +00:00
|
|
|
return (
|
|
|
|
<Suspense fallback={ <Spinner /> }>
|
|
|
|
<page.container
|
|
|
|
params={ params }
|
|
|
|
path={ url }
|
|
|
|
pathMatch={ page.path }
|
|
|
|
query={ query }
|
|
|
|
/>
|
|
|
|
</Suspense>
|
|
|
|
);
|
2018-05-18 17:31:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-14 03:58:37 +00:00
|
|
|
/**
|
|
|
|
* Update an anchor's link in sidebar to include persisted queries. Leave excluded screens
|
|
|
|
* as is.
|
|
|
|
*
|
2022-03-18 11:45:14 +00:00
|
|
|
* @param {HTMLElement} item - Sidebar anchor link.
|
|
|
|
* @param {Object} nextQuery - A query object to be added to updated hrefs.
|
|
|
|
* @param {Array} excludedScreens - wc-admin screens to avoid updating.
|
2019-05-14 03:58:37 +00:00
|
|
|
*/
|
|
|
|
export function updateLinkHref( item, nextQuery, excludedScreens ) {
|
2020-08-05 22:02:24 +00:00
|
|
|
if ( isWCAdmin( item.href ) ) {
|
2019-06-13 19:58:21 +00:00
|
|
|
const search = last( item.href.split( '?' ) );
|
|
|
|
const query = parse( search );
|
2020-09-14 23:44:46 +00:00
|
|
|
const path = query.path || 'homescreen';
|
2021-01-07 16:53:31 +00:00
|
|
|
const screen = getScreenFromPath( path );
|
2019-06-13 19:58:21 +00:00
|
|
|
|
|
|
|
const isExcludedScreen = excludedScreens.includes( screen );
|
|
|
|
|
|
|
|
const href =
|
2020-02-14 02:23:21 +00:00
|
|
|
'admin.php?' +
|
|
|
|
stringify(
|
|
|
|
Object.assign( query, isExcludedScreen ? {} : nextQuery )
|
|
|
|
);
|
2019-06-13 19:58:21 +00:00
|
|
|
|
|
|
|
// Replace the href so you can see the url on hover.
|
|
|
|
item.href = href;
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
item.onclick = ( e ) => {
|
2019-06-13 19:58:21 +00:00
|
|
|
e.preventDefault();
|
|
|
|
getHistory().push( href );
|
|
|
|
};
|
2019-05-14 03:58:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 19:58:21 +00:00
|
|
|
// Update's wc-admin links in wp-admin menu
|
2020-07-28 02:32:58 +00:00
|
|
|
window.wpNavMenuUrlUpdate = function ( query ) {
|
2019-06-13 19:58:21 +00:00
|
|
|
const nextQuery = getPersistedQuery( query );
|
2021-01-07 16:53:31 +00:00
|
|
|
const excludedScreens = getQueryExcludedScreens();
|
2019-05-14 03:58:37 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
Array.from(
|
|
|
|
document.querySelectorAll( '#adminmenu a' )
|
|
|
|
).forEach( ( item ) => updateLinkHref( item, nextQuery, excludedScreens ) );
|
2018-10-18 04:37:28 +00:00
|
|
|
};
|
|
|
|
|
2018-05-18 17:31:08 +00:00
|
|
|
// When the route changes, we need to update wp-admin's menu with the correct section & current link
|
2020-07-28 02:32:58 +00:00
|
|
|
window.wpNavMenuClassChange = function ( page, url ) {
|
2021-10-25 13:59:35 +00:00
|
|
|
const wpNavMenu = document.querySelector( '#adminmenu' );
|
|
|
|
Array.from( wpNavMenu.getElementsByClassName( 'current' ) ).forEach(
|
2020-07-28 02:32:58 +00:00
|
|
|
function ( item ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
item.classList.remove( 'current' );
|
|
|
|
}
|
|
|
|
);
|
2018-10-10 14:24:57 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
const submenu = Array.from(
|
2021-10-25 13:59:35 +00:00
|
|
|
wpNavMenu.querySelectorAll( '.wp-has-current-submenu' )
|
2020-02-14 02:23:21 +00:00
|
|
|
);
|
2020-07-28 02:32:58 +00:00
|
|
|
submenu.forEach( function ( element ) {
|
2018-10-27 17:38:35 +00:00
|
|
|
element.classList.remove( 'wp-has-current-submenu' );
|
|
|
|
element.classList.remove( 'wp-menu-open' );
|
|
|
|
element.classList.remove( 'selected' );
|
|
|
|
element.classList.add( 'wp-not-current-submenu' );
|
|
|
|
element.classList.add( 'menu-top' );
|
|
|
|
} );
|
2018-10-10 14:24:57 +00:00
|
|
|
|
2019-06-13 19:58:21 +00:00
|
|
|
const pageUrl =
|
2020-02-14 02:23:21 +00:00
|
|
|
url === '/'
|
2019-06-13 19:58:21 +00:00
|
|
|
? 'admin.php?page=wc-admin'
|
|
|
|
: 'admin.php?page=wc-admin&path=' + encodeURIComponent( url );
|
2018-10-29 15:43:30 +00:00
|
|
|
const currentItemsSelector =
|
2019-06-13 19:58:21 +00:00
|
|
|
url === '/'
|
|
|
|
? `li > a[href$="${ pageUrl }"], li > a[href*="${ pageUrl }?"]`
|
|
|
|
: `li > a[href*="${ pageUrl }"]`;
|
2021-10-25 13:59:35 +00:00
|
|
|
const currentItems = wpNavMenu.querySelectorAll( currentItemsSelector );
|
2018-10-18 04:37:28 +00:00
|
|
|
|
2020-07-28 02:32:58 +00:00
|
|
|
Array.from( currentItems ).forEach( function ( item ) {
|
2018-10-10 16:06:32 +00:00
|
|
|
item.parentElement.classList.add( 'current' );
|
|
|
|
} );
|
2018-10-10 14:24:57 +00:00
|
|
|
|
2019-04-11 18:31:31 +00:00
|
|
|
if ( page.wpOpenMenu ) {
|
2021-10-25 13:59:35 +00:00
|
|
|
const currentMenu = wpNavMenu.querySelector( '#' + page.wpOpenMenu );
|
2020-06-10 21:56:01 +00:00
|
|
|
if ( currentMenu ) {
|
|
|
|
currentMenu.classList.remove( 'wp-not-current-submenu' );
|
|
|
|
currentMenu.classList.add( 'wp-has-current-submenu' );
|
|
|
|
currentMenu.classList.add( 'wp-menu-open' );
|
|
|
|
currentMenu.classList.add( 'current' );
|
|
|
|
}
|
2019-04-11 18:31:31 +00:00
|
|
|
}
|
2018-10-18 04:37:28 +00:00
|
|
|
|
2019-02-20 15:18:27 +00:00
|
|
|
const wpWrap = document.querySelector( '#wpwrap' );
|
|
|
|
wpWrap.classList.remove( 'wp-responsive-open' );
|
2018-05-18 17:31:08 +00:00
|
|
|
};
|