Forums

Full URL Redirection of Theme URL (3 posts)

  1. Bruno Augusto
    Member
    Posted 10 months ago #

    I think this is the right place for this question. I could not be so clear in the title but I will give you more details.

    Here is the thing. I developed a small framework and I would like to use its' awesome URL Routing System in WordPress' Theme I'm currently developing.

    But this URL Routing System is based upon clean URL's like:

    /foo/bar/option/value

    But the WordPress' Admin URLs, specifically in the Themes' Page, as far as I know about WordPress is pre-established as admin.php?page=some-value

    Where some-value is what we defined in the fourth parameter of add_menu_page() function.

    I tried some trick in the .htaccess file to redirect the requests:

    RewriteCond %{REQUEST_URI} wp-admin/sometext.*?
    RewriteRule !\.(js|ico|gif|jpg|png|css)$ wp-content/themes/ThemeName/admin/index.php [NC]

    And it was a success, or at least I thought it was. I was able to access pages like:

    http://domain.com/blog/wp-admin/sometext/foo/bar

    And by analyzing the REQUEST URI received I got /foo/bar, and from this point my Framework is able to handle the Requests.

    But, as I said, it was not correctly, because I was REDIRECTING the request, and by doing this, even partially working, I could not have my code side by side the WordPress' Admin Menu (or header, footer...)

    In fact, I couldn't even access constants defined, because the request did not came through WordPress' logical structure, and no require call were made.

    Is this kind of hack possible in any way?

  2. digibucc
    Member
    Posted 10 months ago #

    i may be far off but what about permalinks? wordpress default
    structure is variable, but you can turn permalinks on and get
    a folder-like structure as you are talking about.

    again, i may just be missing what you are asking...

  3. Bruno Augusto
    Member
    Posted 10 months ago #

    I don't know if the permalinks affects the Admin Panel. Maybe yes, maybe not...

    Here, I will try to explain in a better way.

    When developing a theme (or plugin) you can use the function add_menu_page() to add another "division" for your own theme/plugin, instead of let it "lost" between all the others plugins or in the menu Appearance, for themes.

    The fourth parameter, called $menu_slug is the GET value for the page querystring. E.g.:

    $menu_slug is set to vendor-theme-settings and the URL is something like admin.php?page=vendor-theme-settings

    But, my URL Router System expects a slash-separated string, like vendor/theme/settings

    Of course, this URL Router is the Standard URL Router, I can easily create a WordPress Router, specifically for WordPress' Theme/Plugins.

    But I would like to know if it's possible some different trick to use the class I already have.

Reply

You must log in to post.

About this Topic