0
0
Wordpressframework~5 mins

Plugin database tables in Wordpress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of plugin database tables in WordPress?
Plugin database tables store data specific to a plugin's functionality, separate from WordPress core tables, allowing plugins to manage their own data efficiently.
Click to reveal answer
intermediate
How do WordPress plugins create custom database tables?
Plugins create custom tables using the dbDelta() function inside activation hooks, which safely creates or updates tables based on SQL statements.
Click to reveal answer
beginner
Why should plugin database tables use the WordPress table prefix?
Using the WordPress table prefix (usually $wpdb->prefix) prevents naming conflicts and ensures compatibility with multisite installations.
Click to reveal answer
intermediate
What is the role of the $wpdb object when working with plugin tables?
$wpdb is WordPress's database access object. It helps safely query, insert, update, and delete data in plugin tables using prepared statements to avoid SQL injection.
Click to reveal answer
beginner
When should a plugin remove its custom database tables?
A plugin should remove its custom tables only if the user chooses to delete plugin data during uninstall, to avoid accidental data loss.
Click to reveal answer
Which WordPress function is commonly used to create or update plugin database tables?
AdbDelta()
Bcreate_table()
C$wpdb->create()
Dinstall_table()
Why should plugin tables use the WordPress table prefix?
ATo encrypt data
BTo speed up queries
CTo make tables hidden
DTo avoid conflicts and support multisite
Which object is used to interact with the database in WordPress plugins?
A$sql
B$wpdb
C$database
D$db
When should a plugin delete its custom database tables?
AImmediately on deactivation
BEvery time the plugin updates
COnly when the user uninstalls and chooses to delete data
DNever, tables stay forever
What is the main risk if plugin database tables do not use prepared statements?
ASQL injection attacks
BSlower queries
CTables won't create
DPlugin won't activate
Explain how a WordPress plugin should create and manage its custom database tables.
Think about the plugin lifecycle and WordPress database tools.
You got /5 concepts.
    Describe best practices for deleting plugin database tables when uninstalling a plugin.
    Consider user control and data safety.
    You got /5 concepts.