WordPress.org

Ready to get started?Download WordPress

Forums

Rename wp-login.php
[resolved] is_admin() and OOP (5 posts)

  1. Stefan
    Member
    Posted 9 months ago #

    Hey,

    thank you for the plugin!

    Is it possible to setup this nice plugin in to a oop version. it would be much more safer and it will come with an professional look. :)

    second: there is a is_admin() behavior: if i will access (not logged in) to /wp-admin/ your plugin creates an 404(). but we are in a is_admin() situation, so some of my scripts which i only will load in the frontend, wont show up and generates some ugly errors.

    for example: if you load in your functions.php like that:

    if( !is_admin() ) { load_some_css() }

    in your 404, those css files wont ever load, because technically, your in admin mode. :) is it possible, to redirect permanent to a another link, so we run out of the admins area?

    http://wordpress.org/plugins/rename-wp-login/

  2. Janneke Van Dorpe
    Member
    Plugin Author

    Posted 9 months ago #

    Thank you!

    Yes, I'll do that at some point.

    Could you explain your second situation with more detail? Can you give a specific example?

  3. Stefan
    Member
    Posted 9 months ago #

    ok.

    create a php file "class.php", insert something like ( class fun {} )

    in your functions.php, add:

    if( !is_admin() ) { include('class.php'); }

    open your 404.php, add:

    $fun = new fun();

    now, try your 404 while type http://www.example.com/xxxx (not existing page), into your browser: your 404 will show up correctly.

    now log off and type http://www.example.com/wp-admin/ into your browser:

    404 shows up, but with an error like "cannot find class "fun". because /wp-admin actually is "is_admin();

    its a stupid example, but i hope u'll see what i mean. :)

    ----------

    second thought on the 404 problem. If you have a multisite installed, user can be added via the backend in several ways. they will retrieve some confirmation mails - with the wrong url in it (/wp-admin).

    because we can't change the admin_url, i've added into your rwl_404() function:

    if (
        isset( $_SERVER['HTTP_REFERER'] ) &&
       (     strpos( $_SERVER['HTTP_REFERER'], 'newbloguser' ) !== FALSE
         || strpos( $_SERVER['HTTP_REFERER'], 'wp-activate.php' ) !== FALSE )
      ) {
    
         wp_redirect( rwl_login_url() );
         exit;
    
    }

    i know, this is not save, but at the moment, the best solution. so user wont land on a 404 page, if they click the login link.

  4. Janneke Van Dorpe
    Member
    Plugin Author

    Posted 9 months ago #

    Thanks for pointing this out. You could use ! is_admin() || is_404() and it should work. There's just no way to filter is_admin()… I'll think about it, but I don't think it can be fixed.

    I know about those multisite problems, I'll try to address them by the next release!

    Thanks!

  5. Janneke Van Dorpe
    Member
    Plugin Author

    Posted 8 months ago #

    wp-admin now just shows you a wp_die message if you're not logged in. That should solve these issues. In the next version I'll introduce some filters to redirect to a custom url.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.