Sub Promotion

?

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 수정 삭제
Extra Form
제목 loreenbird@speedpost.net
예약자 37|@|2248|@|25126
wp-react-starter-license.jpgPlugins 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, 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 v2.2.1 v1.1 - TwentyOne – Responsive Email + Online Template Builder Nulled 1.0 Gonzales Nulled Download – WordPress Site Accelerator v.1.1.10 HomePress WordPress Real Estate Website Template licence v2.2 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: Amasty One Step Checkout v.2.10.1 M2 licence 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 Ukil Law Firm Elementor Template Kit Crack pages that are added by your plugin. Order Delivery Date Pro V.9.16.0 For WooCommerce By TycheSoftwares Download For Free example, if your plugin 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 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, 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
번호 제목 글쓴이 최근 수정일 날짜
144306 teodorotrost@t-online.de TeodoroTrost055558 2020.06.14 2020.06.14
144305 amosabigail@123mail.org CPPAmos4670153961088 2020.06.14 2020.06.14
144304 jacquelynspivey@gmail.com JacquelynSpivey51 2020.06.14 2020.06.14
» loreenbird@speedpost.net LoreenBird1272428 2020.06.14 2020.06.14
144302 dawnnava@aol.com DawnNava28608604 2020.06.14 2020.06.14
144301 shanelscherf@bigstring.com ShanelScherf1323327 2020.06.14 2020.06.14
144300 veronabradley@snail-mail.net VeronaBradley587701 2020.06.14 2020.06.14
144299 marylinmackersey@yahoo.com MarylinMackersey5 2020.06.14 2020.06.14
144298 zoilaevergood@gmail.com Zoila97Z2928106570692 2020.06.14 2020.06.14
144297 chadmontenegro@gmail.com ChadMontenegro57 2020.06.14 2020.06.14
144296 rosetta.arreola@gmail.com RosettaArreola88224 2020.06.14 2020.06.14
144295 kaycawthorn@gmail.com KayCawthorn0736 2020.06.14 2020.06.14
144294 celsafleischer@googlemail.com CelsaFleischer92 2020.06.14 2020.06.14
144293 everette.leff@yahoo.de EveretteLeff81367 2020.06.14 2020.06.14
144292 yettaomalley@gmail.com YettaOmalley6884601 2020.06.14 2020.06.14
144291 doylesouthern@aol.com DoyleSouthern56616 2020.06.14 2020.06.14
144290 lynnekwan@gmx.de LynneKwan76128371 2020.06.14 2020.06.14
144289 chassidybooker@gmail.com ChassidyBooker8862 2020.06.14 2020.06.14
144288 charmain_shoemaker@bestmail.us FOVCharmain49815394 2020.06.14 2020.06.14
144287 jodywashington@freenet.de JodyWashington6 2020.06.14 2020.06.14
144286 johnie_skillen@t-online.de JohnieSkillen503 2020.06.14 2020.06.14
144285 mercedesormond@freenet.de MercedesZsc85383162 2020.06.14 2020.06.14
144284 margaretafairweather@inbox.com MargaretaFairweather 2020.06.14 2020.06.14
144283 wally.person@inbox.com WallyPerson9495 2020.06.14 2020.06.14
144282 roma_mawson@gmail.com ZUVRoma0006960962316 2020.06.14 2020.06.14
144281 maritasampson@gmail.com MaritaSampson732452 2020.06.14 2020.06.14
144280 demetrialandrum@gmail.com DemetriaLandrum0836 2020.06.14 2020.06.14
144279 lorrine.wagner@bigstring.com LorrineWagner0512183 2020.06.14 2020.06.14
144278 alex.almanza@inbox.com AlexAlmanza145021 2020.06.14 2020.06.14
144277 beatrisdelancey@gmail.com BeatrisDelancey05764 2020.06.14 2020.06.14
144276 esmeralda_hollins@gmail.com EsmeraldaHollins4 2020.06.14 2020.06.14
144275 enriquesipes@gawab.com EnriqueSipes20824973 2020.06.14 2020.06.14
144274 randialt@arcor.de RandiAlt87633880322 2020.06.14 2020.06.14
144273 antoinekinser@gmail.com AntoineKinser612 2020.06.14 2020.06.14
144272 alisa_colby@yahoo.com AlisaColby914653 2020.06.14 2020.06.14
144271 damion_praed@gmail.com DamionPraed01871 2020.06.14 2020.06.14
144270 leannegiron@zoho.com LeanneZjw8149121135 2020.06.14 2020.06.14
144269 meimarsden@yahoo.com MeiMarsden466411 2020.06.14 2020.06.14
144268 noeliahoyt@gmail.com NoeliaHoyt00481990 2020.06.14 2020.06.14
144267 brent.beach@gmail.com BrentBeach437165 2020.06.14 2020.06.14
144266 juliet.shepherd@gmail.com Juliet1941188560 2020.06.14 2020.06.14
144265 esmeralda_hollins@gmail.com EsmeraldaHollins4 2020.06.14 2020.06.14
144264 mittiegipps@gmail.com MittieGipps0929311 2020.06.14 2020.06.14
144263 marilynbower@zoho.com MarilynBower679 2020.06.14 2020.06.14
144262 cyrustimms@aol.com CyrusTimms14594257 2020.06.14 2020.06.14
144261 epifaniawatts@gmail.com EpifaniaWatts276532 2020.06.14 2020.06.14
144260 andy.borges@gmail.com AndyBorges0580767289 2020.06.14 2020.06.14
144259 kristieelston@web.de KristieElston27 2020.06.14 2020.06.14
144258 troycolby@gmail.com TroyO946537770723 2020.06.14 2020.06.14
144257 louannlambie@zoho.com LouannLambie884 2020.06.14 2020.06.14
Board Pagination Prev 1 ... 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 ... 4736 Next
/ 4736

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved