WordPress- GetDef Plugin By ZHOU Wei: Fixed

Last Updated on

I’m not a good coder, but I seem to have gotten lucky with this one. A great plugin by Zhou Wei called GetDef, a [tag]Wordpress[/tag] [tag]plugin[/tag], was causing my site problems.  I kept getting this error:

Warning: fopen(http://www.google.com/search?ie=utf8&oe=utf8&q=define:) failed to open stream: Success in /home/ggxf/public_html/blog/wp-content/plugins/GetDEF/GetDEF.php on line 19

I never had this problem before and it seemed to appear for “no reason”.  Then I started to analyze my site and I realized that I was starting to use this plugin more frequently and more [tag]GetDef[/tag] calls were being performed on each page.  I began to think that maybe [tag]Google[/tag] was timing out because of the quickness of the calls or perhaps it was thinking it was getting spammed.

Long story short: I added a “usleep(100)” line to make the plugin pause a 10th of a second after each “fetch”.

Here is the code I used:

function def_fy( $text ) {
    $text = preg_replace(
        “#\~GetDEF\((\S*)\)\~#imseU”,
        “getDEF(‘$1’)”,
        $text
    );
   
usleep(100);

return $text;
}

Also Google decaprecated some values (no longer being used) that were in the search string so I pulled them from the “$searchStr” value and changed to this:

$searchStr=http://www.google.com/search?q=define:;

Finally, I fixed a spacing problem with the “term” tag and bracket  and changed a line of code by adding a space:

article = “<div class=\”Gdef\”><img align=\”left\” src=\””.$imgpath.”\”><b>[“.$def.”] </b>”.$article.$description.”</div>”;

Note: I added a space after the ] and just before the </b>

That’s it! 

I am going to keep a .zip of the changes here for on http://mustech.net for a little while.
You can down load the changes I made in a zip file by clicking here: Click for it!  (I am not sure how long I am going to keep this link).

Again, this has fixed my problem, I am not sure if it will fix yours! Also, you may be able to change the “usleep” value to less and have it work as well. 

I also have updated ZHOU wei about this on his site.  It’s in Chinese and you can visit it here: http://www.ennonce.com/blog/

                          ~J. Pisano

Print Friendly, PDF & Email

Related Post from MusTech.Net

Joseph M. Pisano, Ph.D. is an industry innovator, education clinician and lecturer, trumpeter and conductor, and the creator of many education websites. He is currently the Vice President of Innovation and Engagement at Keystone Ridge Designs, Inc. After twenty-three years as a professor and administrator at Grove City College, he made the move into industry in 2018.  As one of the youngest full professors in Grove City’s history, he served in various roles over his tenure including the Technical Director of the Pew Fine Arts Center, Assistant and Associate Chairs of Music and Music and Fine Arts, Director of Music and Fine Arts Technology, Director of Jazz Studies, Stage Manager, and he finished his tenure as the Director of Bands where he directed the college’s Symphonic Concert Band, Wind Ensemble, Marching Band, Pep Bands, and various small ensembles.

He been named a TI:ME Teacher of the Year, received the JEN Jazz Educator Award, the PA Citation of Excellence, and named a “member for life” of the PA Intercollegiate Bandmasters Association. He is a past Vice President of the Technology Institute for Music Educators, an associate member of the American Bandmasters Association,  a past President of the PA Intercollegiate Bandmasters Association, and a member of various education and music honoraries. He has written for numerous publications including DCI Magazine, Teaching Music Magazine, and was the Educational Editor for In-Tune Monthly Magazine for eight years; he has contributed hundreds of articles to various publications. He is an active conductor, trumpeter, clinician, and educator. Find out more at his website jpisano.com.

#biography #bio #josephmpisano #josephpisano #musiced #musiceducation #industryleader

Category : General-Other
Tags :