Sub Promotion

?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제
Extra Form
제목 harveymcmillen@gawab.com
예약자 30|@|3956|@|56292
Plugins that clean up all the garbage are one of the best. If you are developing a plugin that adds something to the WordPress database, you need to make sure that it removes after itself all unwanted or unused data during the uninstall process. In this guide, we will look at useful methods for this related to the uninstall.php file. How uninstall.php works Usually you need to add the uninstall.php file to the main (root) directory of the plugin. For example, you have a plugin called Add Data to WP Database, and its main directory is / add-data-wp-database /. In this directory we can add the uninstall.php file with the following code: 01 /add-data-wp-database/ 02 /add-data-wp-database.php 03 /index.php 04 /uninstall.php <--- here it is. 05 /readme.txt Now, when uninstalling (removing) the plugin through the Plugins screen in the admin panel, WordPress will find and execute uninstall.php. This approach allows plug-in developers to remove any unwanted or unused data from the database. Here's how it works in a nutshell. For more information, you can refer to the WP Code. What code is suitable for placement in uninstall.php The uninstall.php file may contain any code necessary for the correct procedure for removing the plugin. Be sure to include code that protects the file from unwanted access. Here is an easy way to do this: 01 <?php // exit if uninstall constant is not defined 02 if (!defined('WP_UNINSTALL_PLUGIN')) exit; These lines should be located at the very beginning of uninstall.php before any other code. The code checks the constant WP_UNINSTALL_PLUGIN, which is determined by WordPress immediately before loading uninstall.php. If someone tries to access the file from the side, the script will immediately end. To give you a better idea, here is an example uninstall.php file that removes several data types. Note that most of the code is excluded for clarity: 01 <?php // exit if uninstall constant is not defined 02 if (!defined('WP_UNINSTALL_PLUGIN')) exit; 03 04 // remove plugin options 05 06 // remove plugin transients 07 08 // remove plugin cron events 09 10 // ..etc., based on what needs to be removed This shows that the approaches in terms of code are highly dependent on the data that needs to be deleted or changed. The code will vary from plugin to plugin. You need to know exactly what data you want to delete before using the appropriate technique. In the following sections of this guide, we will look at methods for removing all data types from a WordPress database. Removing plug-in options (parameters) The most popular method for deleting plugin parameters is the delete_option () function. For example, to remove a parameter called myplugin_options, add the following code to the uninstall.php file: 01 // delete plugin options 02 delete_option('myplugin_options'); Or, if you have several options to delete, use an array: 01 // delete multiple options 02 $options = array( 03 'myplugin_option_1', 04 'myplugin_option_2', 05 'myplugin_option_3', 06 ); 07 foreach ($options as $option) 08 if (get_option($option)) delete_option($option); 09 Just rename the elements of the array (for example, myplugin_option_1, etc.), specifying the options of your plugin that you want to remove. Everything is simple! Removing plugin transients Another common approach is to remove all transient plugins from the database. To do this, we can use the delete_transient () function: 01 // delete plugin transient 02 delete_transient('myplugin_transient'); If you need to remove several transients, then you can use the array: 01 // delete multiple transients 02 $transients = array( 03 'myplugin_transient_1', 04 'myplugin_transient_2', 05 'myplugin_transient_3', 06 ); 07 foreach ($transients as $transient) 08 delete_transient($transient); 09 Just rename the elements of the array (for example, myplugin_transient_1, etc.), indicating the transients of your plugin that you want to remove. Delete cron events The following methodology shows how to remove cron events using the wp_unschedule_event () function. Here is an example: 01 // delete cron event 02 $timestamp = wp_next_scheduled('myplugin_cron_event'); 03 wp_unschedule_event($timestamp, 'myplugin_cron_event'); The trick here is to use wp_next_scheduled () to get the correct $ timestamp value for the event you want to delete. Deleting database tables One of my favorite techniques. Be careful with her. Make sure the table name is correct. Here is an example of how to delete a table called myplugin_table: 01 // delete database table 02 global $wpdb; 03 $table_name = $wpdb->prefix .'myplugin_table'; 04 $wpdb->query("DROP TABLE IF EXISTS $table_name"); The technique uses the wpdb class to determine $ table_name, Magestore WebPOS v.2.4.2.2 M2.2 Crack after which the table is deleted if it exists.

Again, it is very important to replace myplugin_table with the correct name of the table you want to delete. No other code changes are required. Check everything very carefully! Delete posts and pages To delete a post or page, we can use wp_trash_post (). For example, to delete a post with ID 44, we need the following code: 01 // delete post id 44 02 wp_trash_post(44); The trick of this technique is to determine the correct ID for the page or post.

There are several ways to do this. The easiest way is to save the ID of any posts and pages that are added by your plugin. For Amasty Product Attachments v.2.3.1 -M2 Crack example, if your Live Streaming Plugin v.1.0 Belloo Dating Software Crack adds three pages upon first activation, you can add the ID of these pages to the database as an option. Then you can turn to these options and v1.3.1 - Aki Nulled – Multipurpose Kids v.4.0.5 Hotel Master Booking WordPress lifetime Theme v.1.3.0 get the correct posts to delete. In code, it looks something like this: 01 // delete pages 02 $myplugin_pages = get_option('myplugin_pages'); 03 if (is_array($myplugin_pages) && !empty($myplugin_pages)) 04 foreach ($myplugin_pages as $myplugin_page) 05 wp_trash_post($myplugin_page); 06 07 Here we use get_option () to get our array of page IDs.

Then we iterate over the array and use wp_trash_post () to delete each item. Please note that this technique can be used to delete any type of posts, AtomTrack URL Rotator price not just pages. Removing custom post types Here we will focus on the removal of posts that are defined as an arbitrary post type (CPT).

List of Articles
번호 제목 글쓴이 최근 수정일 날짜
» harveymcmillen@gawab.com HarveyMcMillen996 2020.06.10 2020.06.10
67905 alenasimone@gmail.com AlenaSimone9726 2020.06.10 2020.06.10
67904 randellklass@arcor.de RandellR281565775445 2020.06.10 2020.06.10
67903 sherlenesanto@gmail.com SherleneSanto2420 2020.06.10 2020.06.10
67902 matilda_schweizer@bigstring.com Matilda79C7813675486 2020.06.10 2020.06.10
67901 juliannebermingham@web.de Julianne93U6060058 2020.06.10 2020.06.10
67900 blytheartis@googlemail.com BlytheArtis9237 2020.06.10 2020.06.10
67899 bonnycounts@freenet.de BonnyCounts393251 2020.06.10 2020.06.10
67898 graciehodel@freenet.de GracieHodel664588 2020.06.10 2020.06.10
67897 daniellasimms@hotmail.de Daniella05E5605 2020.06.10 2020.06.10
67896 nickolasstafford@t-online.de NickolasStafford9543 2020.06.10 2020.06.10
67895 silvia.prentice@gmail.com SilviaPrentice746 2020.06.10 2020.06.10
67894 finlaybolt@web.de FinlayBolt2472386 2020.06.10 2020.06.10
67893 haroldtisdall@fast-mail.org HaroldTisdall812165 2020.06.10 2020.06.10
67892 wilhemina.mooney@gmail.com WilheminaMooney4 2020.06.10 2020.06.10
67891 libbysheldon@gmail.com LibbySheldon93708 2020.06.10 2020.06.10
67890 velvacriswell@freenet.de VelvaCriswell779 2020.06.10 2020.06.10
67889 florriebrookes@gawab.com QFMFlorrie22739 2020.06.10 2020.06.10
67888 glindachitwood@gmail.com GlindaChitwood1 2020.06.10 2020.06.10
67887 bettieboreham@gmail.com BettieBoreham2745 2020.06.10 2020.06.10
67886 jinafairchild@mailsent.net JinaFairchild463796 2020.06.10 2020.06.10
67885 phillippranieri@googlemail.com PhillippRanieri 2020.06.10 2020.06.10
67884 pedrostiles@freenet.de PedroStiles99668523 2020.06.10 2020.06.10
67883 mosessleigh@mailmight.com MosesSleigh45000061 2020.06.10 2020.06.10
67882 danebray@gmail.com DaneAoc3736820978 2020.06.10 2020.06.10
67881 lawrencefrueh@inbox.com LawrenceFrueh1167351 2020.06.10 2020.06.10
67880 antonio_palma@t-online.de XSAAntonio575762580 2020.06.10 2020.06.10
67879 darcipeppin@gmx.de DarciSdp20361967375 2020.06.10 2020.06.10
67878 wilford.naumann@gmail.com Wilford49B0329779 2020.06.10 2020.06.10
67877 tanisha_ridgeway@gmail.com TanishaRidgeway10887 2020.06.10 2020.06.10
67876 omerplate@yahoo.de OmerPlate1376196 2020.06.10 2020.06.10
67875 hildegardgaribay@gmx.net PRFHildegard52909 2020.06.10 2020.06.10
67874 luelladoolette@freenet.de LuellaDoolette1783 2020.06.10 2020.06.10
67873 jeromebonnor@gmail.com JeromeBonnor286014 2020.06.10 2020.06.10
67872 kattieescamilla@web.de KattieT134917224 2020.06.10 2020.06.10
67871 eliseabdul@gmail.com EliseAbdul9712226 2020.06.10 2020.06.10
67870 monserrateyamamoto@gmail.com MonserrateYamamoto76 2020.06.10 2020.06.10
67869 catharineschumacher@gmail.com CatharineSchumacher2 2020.06.10 2020.06.10
67868 daniellehomer@gmail.com DanielleHomer9047 2020.06.10 2020.06.10
67867 heikepender@gmx.de HeikePender522933 2020.06.10 2020.06.10
67866 marilyncoles@care2.com MarilynColes07677 2020.06.10 2020.06.10
67865 delorislevy@gmail.com DelorisLevy6155916516 2020.06.10 2020.06.10
67864 joyprindle@bigstring.com JoyPrindle0967546593 2020.06.10 2020.06.10
67863 dwightsikes@gmail.com DwightSikes702808 2020.06.10 2020.06.10
67862 bryantmackintosh@gmail.com BryantMackintosh 2020.06.10 2020.06.10
67861 fidelia.goldman@gmail.com Fidelia58U4078408182 2020.06.10 2020.06.10
67860 careywillson@gmail.com CareyWillson153 2020.06.10 2020.06.10
67859 celestechristison@gmail.com CelesteJbc30335478899 2020.06.10 2020.06.10
67858 iolatidwell@web.de IolaTidwell485385243 2020.06.10 2020.06.10
67857 christenwestmoreland@t-online.de ChristenWestmoreland 2020.06.10 2020.06.10
Board Pagination Prev 1 ... 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 ... 4736 Next
/ 4736

bodum2ro 43,sejong, Korea / Copyrightⓒ. All Rights Reserved By fone

© k2s0o1d4e0s2i1g5n. All Rights Reserved