Several WordPress plugins ask you to add certain code to the WordPress theme template files to make them work. ووردبريس ملحقات عدة اطلب منكم ان اضيف بعض المدونه الى موضوع WordPress القالب ملفات لكي يكتب لها النجاح. If you are not a PHP developer or you don’t have time to code review the plugin and you decide to activate the plugin then the plugin can very easily cause your site to crash or worse. اذا لم تكن بي. اتش. بى المطور او لم يكن لديك الوقت لاعادة النظر في قانون البرنامج المساعد وانت تقرر لتفعيل البرنامج المساعد ثم البرنامج المساعد يمكن بسهولة بالغة سبب تحطم الطائرة الى موقعك او الى الاسوأ. Often the errors are hard to detect (sporadic, happening only in certain conditions) and even harder to debug as you are not familiar with the code. الاخطاء هي في كثير من الاحيان الى صعوبة الكشف (متقطعه ، يحدث الا في ظروف معينة) واصعب التصحيح كما أنت لم تكن مالوفه مع المدونه. Today we will talk about a simple step you can take to make your site robust against untested and buggy plugins. اليوم سوف نتحدث عن خطوة بسيطة يمكنك ان تتخذ لجعل موقعك غير مجربه وقوية ضد عربة ملحقات.

Normally most of the time you are asked to include a code block similar to this: عادة في معظم الاحيان يطلب منك ان تدرج مدونة لقواعد مماثلة لهذه الكتلة :

The func_name obviously represents a function which the plugin author wants you to include; the arguments are as required for that function. فان من الواضح ان func_name يمثل وظيفة البرنامج المساعد المؤلف الذي كنت تريد ان تدرج ؛ الحجج اللازمة لتلك المهمة.

This can create two major issues. هذا يمكن ان تخلق المسألتين الرئيسيتين.
Firstly if at any time you decide to disable the plugin then you will have to first remove the code from all your template files before you can safely de-activate / remove the plugin. اولا اذا كان في أي وقت تقررون لتعطيل البرنامج المساعد ثم سيتعين عليكم اولا بازاله هذا القانون من جميع القالب قبل ان تتمكن من الملفات بأمان في تنشيط / ازالة البرنامج المساعد. Otherwise the pages in the site will fail to load properly. وإلا فإن الصفحات في الموقع لا يتم تحميل صحيح.

Secondly the plugin itself may fail in certain conditions or always. وثانيا فان البرنامج المساعد في حد ذاته قد تفشل في ظروف معينة او دائما. In the worst case you will find certain pages on your site fails to load sometimes. وفي اسوأ الحالات سوف تجد بعض الصفحات على موقعك لتحميل فشل في بعض الاحيان. It could be long before you are aware of the problem. ويمكن ان يمضي وقت طويل قبل انت على علم بهذه المشكلة.

We will look at two small changes you can make to the code template above to take care of both of the problems described above. وسنتطرق في اثنين من التغييرات الصغيرة يمكنك ان تجعل الى المدونه اعلاه نموذج لرعايه كلا من المشاكل المذكورة أعلاه. First the modified code: اول قانون المعدل :

if(function_exists(’ func_name ‘) @ func_name( arg1,arg2 …); ?> اذا كانت الاجابه ب (function_exists ( 'func_name') @ func_name (arg1 ، arg2…) ؛؟>
Remember to replace func_name with the actual name of the function. تذكر ليحل محل func_name الفعليه مع اسم وظيفة.

Testing the existence of the function ensures that the code isn’t executed when the plugin is inactive / disabled. أختبار وجود وظيفة يضمن ان المدونه ليست عندما اعدم هو البرنامج المساعد الخامله / المعوقين. This prevents the first problem. وهذا يحول دون قيام المشكلة الاولى.

Appending an @ before the function name ensures that errors, if any, while executing the function are ignored and do not cause further problems down the road and do not prevent the overall page from displaying. @ الاضافه وجود اسم وظيفة قبل ان يضمن الاخطاء ، ان وجدت ، في حين ان تنفيذ مهمة يتم تجاهلها ولا يسبب مزيدا من المشاكل اسفل هذا الطريق وهذا لا يحول دون الشامله من عرض الصفحه.

This fix works against all versions of WordPress and also in any other templating system which uses php code. هذا الاصلاح وتعمل ضد كافة اصدارات WordPress وايضا في آية اخرى templating النظام الذي يستخدم بي. اتش. بى المدونه.

Carefully make the changes following the template above to make your site more robust against WordPress plugins. بعناية باجراء التغييرات التالية النموذج اعلاه لجعل موقعك اكثر قوة ضد وردبريس ملحقات.