Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add hook to alter admin url #1882

Open
jan-clockworkwp opened this issue May 2, 2024 · 0 comments
Open

[Feature] Add hook to alter admin url #1882

jan-clockworkwp opened this issue May 2, 2024 · 0 comments

Comments

@jan-clockworkwp
Copy link

Currently in @faustwp/core: 3.0.1 package, there is a way to hook into wpUrl method. But there is no way to hook into the adminUrl, and as far as there is a way to override SiteName link in the custom toolbar with snippet like this:

hooks.addFilter(
      'toolbarNodes',
      'faust',
      (toolbarNodes: FaustToolbarNodes, context: FaustToolbarContext) => {
        const adminUrl = getAdminUrl().replace('/wp-admin', '/wp/wp-admin');
        const customToolbarNodes: FaustToolbarNodes = [
          {
            id: 'site-name',
            location: 'primary',
            component: <SiteName url={adminUrl} />,
          },
        ];

        // Removing default site name node to be able to override admin url
        toolbarNodes = [
          ...toolbarNodes.filter((node) => node.id !== 'site-name'),
        ];

        return [...customToolbarNodes, ...toolbarNodes];
      },
    );

there is no way to override rest of the toolbar items to render proper admin urls.

Would be great if we could do something like:

// @note: wpAdminUrl filter is not currently part of @faustwp/core package
hooks.addFilter('wpAdminUrl', 'faust', (url: string) => {
  return url.replace('/wp-admin', '/wp/wp-admin'); // or whatever admin url modification is needed
});

There is a similar request to this one, but it is related to WordPress faustwp plugin #1872 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants