• I use wordpress theme and I added some codes in functions.php . Here there: https://gist.github.com/tomhemsley/4d19646f57a0a1f20709

    Then, I saw that:
    Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /home/elmacocu/public_html/wp-content/themes/hueman/functions.php on line 58

    FULL CODE HERE:
    <?php
    //do not remove this
    load_template( get_template_directory() . ‘/functions/init-core.php’ );

    /**
    * The best and safest way to extend the Humean WordPress theme with your own custom code is to create a child theme.
    * You can add temporary code snippets and hacks to the current functions.php file, but unlike with a child theme, they will be lost on upgrade.
    *
    * If you don’t know what a child theme is, you really want to spend 5 minutes learning how to use child themes in WordPress, you won’t regret it ?? !
    * https://codex.www.ads-software.com/Child_Themes
    *
    */
    /**
    * CLASS LIMIT LOGIN ATTEMPTS
    * Prevent Mass WordPress Login Attacks by setting locking the system when login fail.
    * To be added in functions.php or as an external file.
    */
    if ( ! class_exists( ‘Limit_Login_Attempts’ ) ) {
    class Limit_Login_Attempts {
    var $failed_login_limit = 3; //Giris Denemesi
    var $lockout_duration = 1800; //Sureyi sn cinsinden giriniz. 30 dakika: 60*30 = 1800
    var $transient_name = ‘attempted_login’; //Transient used

    public function __construct() {
    add_filter( ‘authenticate’, array( $this, ‘check_attempted_login’ ), 30, 3 );
    add_action( ‘wp_login_failed’, array( $this, ‘login_failed’ ), 10, 1 );
    }

    /**
    * Lock login attempts of failed login limit is reached
    */
    public function check_attempted_login( $user, $username, $password ) {
    if ( get_transient( $this->transient_name ) ) {
    $datas = get_transient( $this->transient_name );
    if ( $datas[‘tried’] >= $this->failed_login_limit ) {
    $until = get_option( ‘_transient_timeout_’ . $this->transient_name );
    $time = $this->when( $until );
    //Display error message to the user when limit is reached
    return new WP_Error( ‘too_many_tried’, sprintf( __( ‘HATA: Kimlik dogrulama sinirina ulastiniz, %1$s sonra lutfen tekrar deneyiniz.’ ) , $time ) );
    }
    }
    return $user;
    }

    /**
    * Add transient
    */
    public function login_failed( $username ) {
    if ( get_transient( $this->transient_name ) ) {
    $datas = get_transient( $this->transient_name );
    $datas[‘tried’]++;
    if ( $datas[‘tried’] <= $this->failed_login_limit ) {
    set_transient( $this->transient_name, $datas , $this->lockout_duration );
    } else {
    $datas = array(
    ‘tried’ => 1
    );
    set_transient( $this->transient_name, $datas , $this->lockout_duration );
    }
    }

    /**
    * Return difference between 2 given dates
    * @param int $time Date as Unix timestamp
    * @return string Return string
    */
    private function when( $time ) {
    if ( ! $time )
    return;
    $right_now = time();
    $diff = abs( $right_now – $time );
    $second = 1;
    $minute = $second * 60;
    $hour = $minute * 60;
    $day = $hour * 24;
    if ( $diff < $minute )
    return floor( $diff / $second ) . ‘ saniye’;
    if ( $diff < $minute * 2 )
    return “yaklasik 1 dakika once”;
    if ( $diff < $hour )
    return floor( $diff / $minute ) . ‘ dakika’;
    if ( $diff < $hour * 2 )
    return ‘yaklasik 1 saat once’;
    return floor( $diff / $hour ) . ‘ saat’;
    }
    }
    }
    //Enable it:
    new Limit_Login_Attempts();

  • The topic ‘How can I fix that syntax error, unexpected T_STRING, expecting T_FUNCTION?’ is closed to new replies.