ShuDudu's Home was started in 2011, but the web data is lost, so now begin again, I would like to make some friends, I hope you like ShuDudu's home.
Current position: ShuDudu > Net Web >

WordPress optimization techniques: elementary arithmetic formula to achieve a non-plug-in authentication

Sunday on February 2nd, 2020Net Web

Yesterday I was "WordPress free tutorials (VII): WordPress Akismet plugin installation methods", explained the specific plugin Akismet comment spam filter, but there are a lot of people put forward their own views, many people do not use this plug-in, and It is to increase the verification code within a comment. I will now summarize the use Akismet to use verification code and the pros and cons of it:

Akismet Lee: WordPress one of the default plug-famous comment spam filter plug-ins.

Akismet disadvantages: the presence of misjudgment and drain off the other little WordPress plugin is bound to affect the speed

Code Lee: can effectively filter spam software category

Code disadvantages: a serious impact on the user experience, detrimental to the overall image of the blog. Spam filters can not be artificially class.

Some people say that since the use of code without using plug-ins, it naturally has his reasons. Zhang blog but here there is a reminder that if you use a verification code, your code must be simple. Now codes are generally three categories, one category is four letters, the second is a five-digit class, there is a kind of arithmetic type. Here Zhang blog recommend that you use arithmetic verification that math class, he is a random two-digit sum, let you calculate the results. Select this advantage is that the user experience impact is not too large, less-digit input will not affect the user's mood.

I put this method for everyone to share:

A modifying wp-comments-post.php:

Find:

if ( '' == $ comment_content)

Add code thereon:

// Fufu_checkcode

if (! $ user-ID) {

$ Aaa = trim ($ _ POST [aaa]);

$ Bbb = trim ($ _ POST [bbb]);

$ Subab = trim ($ _ POST [subab]);

if ((($ aaa + $ bbb)! = $ subab) || empty ($ subab)) {

wp_die (__ ( 'I am sorry, please fill in the correct number of PIN'));

}

}

// Fufu_end

Two, comments.php under the theme modify file

Seek

input name = "submit" type = "submit" id = "submit"

Add in front

? Php if ($ user_ID!):?

? Php $ aaa = rand (0,5); $ bbb = rand (3,9); ?? php echo $ aaa;?? + Php echo $ bbb;? =

input type = "text" name = "subab" id = "subab" size = "2" tabindex = "5" / php if ($ req) _e ( '(required)', 'inove')?;?

input name = "aaa" value = "? php echo $ aaa;?" type = "hidden" /

input name = "bbb" value = "? php echo $ bbb;?" type = "hidden" /

? Php endif;?

Well, done, effect test it! I believe that this WordPress optimization techniques, in the way of your blog, you will be able to give a little reference to it!

Note: The encoding code to be consistent and you, and I note the punctuation code (single and double quotes are replaced by single or double quotation marks in English), because I do not "code highlighting" This plug-in installation.

Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/netweb/WordPress-optimization-techniques-elementary-arithmetic-formula-to-achieve-a-non-plug-in-authentication.htm