Does a multisite wordpress program run plugin instance per site? -


first, apologize if question isn't clear enough - i'm new wordpress might have issues nouns.

second, here's description of problem: have plugin creates tables in db. want accomplish create multisite solution in same plugin installed on sites each site see different instance of db.

this allow me have sort of multi tenant solution without re-writing plugin.

is possible?

i'll appreciate help.

nadav

edit:

that's code have in base entity of plugin:

 public static function gettablename()     {         global $wpdb;          return $wpdb->base_prefix . static::$table;     } 

should change following in order support table per site?

 public static function gettablename() {     global $wpdb;      return $wpdb->prefix . static::$table; } 

if using $wpdb->prefix when creating tables, have separate tables each site.

global $wpdb; $my_table = $wpdb->prefix . 'my_table'; $query = "create table $my_table..."; 

the above code result in separate table each site, names wp_2_my_table, wp_3_my_table, etc (assuming using default base prefix wp_).

the majority of plugins not have updated support multi-sites explicitly, long adhere best practices.

conversely if wanted create single table of sites in network, use $wpdb->base_prefix.

just make sure consistently use correct prefix when creating or accessing tables.

https://codex.wordpress.org/class_reference/wpdb#class_variables

edit:

should change following in order support table per site?

if want separate tables each site, yes need change use $wpdb->prefix rather $wpdb->base_prefix. note if you're creating tables in activation hook, you'll have re-install plugin in order create new tables.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -