bueltge / authenticator

This plugin allows you to make your WordPress site accessible to logged in users only.
https://wordpress.org/plugins/authenticator/
GNU General Public License v3.0
24 stars 7 forks source link

Passwort vergessen, Zurück link unterbinden #8

Closed bueltge closed 10 years ago

bueltge commented 11 years ago

Optionales ausblenden der Links

<?php
/**
 * Plugin Name: Password Reset Removed
 * Description: Removes the ability for non admin users to change/reset their passwords.
 * Version:     1.0.0
 * Author:      Frank Bültge
 * Author URI:  http://bueltge.de
 * License:     GPLv3
 */

! defined( 'ABSPATH' ) and exit;

class Fb_Password_Reset_Removed {

    protected static $instance = NULL;

    public function __construct() {

        add_filter( 'show_password_fields',  array( $this, 'disable' ) );
        add_filter( 'allow_password_reset',  array( $this, 'disable' ) );
        add_filter( 'gettext',               array( $this, 'remove' ) );
        add_action( 'login_enqueue_scripts', array( $this, 'add_script' ) );
        add_action( 'login_footer',          array( $this, 'remove_via_js' ) );
    }

    /**
     * Access this plugin’s working instance
     *
     * @wp-hook plugins_loaded
     * @return  object of this class
     */
    public static function get_instance() {

        NULL === self::$instance and self::$instance = new self();

        return self::$instance;
    }

    function disable() {

        if ( is_admin() ) {
            $userdata = wp_get_current_user();
            $user = new WP_User($userdata->ID);
            if ( !empty( $user->roles ) && is_array( $user->roles ) && $user->roles[0] == 'administrator' )
            return TRUE;
        }

        return FALSE;
    }

    function remove($text) {

        return str_replace( array( 'Passwort vergessen', 'Lost your password?', 'Lost your password' ), '', trim($text, '?') ); 
    }

    function add_script() {

        wp_enqueue_script( 'jquery' );
    }

    function remove_via_js() {
        ?>
        <script type="text/javascript">
        //<![CDATA[
        jQuery(document).ready( function($) {
            $( '#backtoblog, #nav' ).remove();
        });
        //]]>
        </script>
        <?php
    }
}
add_action( 'plugins_loaded', array( 'Fb_Password_Reset_Removed', 'get_instance' ) );
bueltge commented 11 years ago

Aktuell habe ich ein JS im stable branch, wo per jQuery der Link unterbunden wird. commit https://github.com/bueltge/Authenticator/commit/d44aca80245045175bc943c9261b0c274b8af145

@dnaber-de Könntest du das in der aktuell version des Master prüfen, ggf einbauen.

bueltge commented 10 years ago

Fixed with 85d0515a5676d8acee5ab49499d6d41168d9a667