The plugin generated x characters of unexpected output, $wpdb not defined
$wpdb is outside the scope of your plugin file, you need global $wpdb; before using $wpdb->prefix
$wpdb is outside the scope of your plugin file, you need global $wpdb; before using $wpdb->prefix
I’ve found the answer here: Customizing wp-activate.php It’s a bit of a workaround really, but it works pretty well. Step 1 Create a new page called ‘activate’ Step 2 Create a new template called ‘template-activate.php’ and add the following code: **Template (template-activate.php)** <?php /** * Template Name: Activation * */ /** * Confirms that the … Read more
In fact, most of plugins work exactly the way you want: You MUST upload them (i.e. install them) on network admin panel, but you can leave them deactivated. Then, you go to an individual subsite plugin page and activate only for said subsite.
The SQL for creating tables in dbDelta() has very specific requirements. From the codex: You must put each field on its own line in your SQL statement. You must have two spaces between the words PRIMARY KEY and the definition of your primary key. You must use the key word KEY rather than its synonym … Read more
Plugins are loaded before headers are sent. The reason is that you should be able to send your own headers per plugin. And that’s why a main plugin file must not create direct output. Wrap your echo code into a function and register that function as a callback for an action that happens later, after … Read more
Wrap your function in if( ! function_exists( ‘wp_authenticate’ ) ) to get rid of the error and successfully activate your plugin: if( ! function_exists( ‘wp_authenticate’ ) ){ function wp_authenticate(){} } This is necessary because in the context of activating a plugin, the function does already exist, only after it is activated will your plugin load … Read more
Code like this can do the trick. function plugin_activation_check(){ if ( some_check_here() ) { // this is the fail case deactivate_plugins(basename(__FILE__)); // Deactivate ourself wp_die(“Message to user.”); } } register_activation_hook(__FILE__, ‘plugin_activation_check’);
Try the following code: add_action( ‘admin_head’, ‘ask_for_activation’ ); function ask_for_activation() { ?> <script type=”text/javascript”> jQuery(function($){ $(‘span.activate a’).click(function(e){ var c = confirm(‘Are you sure wnat to activate?’) if(!c) { e.preventDefault(); return false; } return true; }); }); </script> <?php } You can add those codes in your functions.php in the theme, if you think your theme … Read more
Try using a different method. WordPress fires a hook during plugin activation activate_yourplugin/filename.php. You can use this to create tables. function creating_order_tables() { if(!get_option(‘tables_created’, false)) { global $wpdb; $ptbd_table_name = $wpdb->prefix . ‘printtextbd_order’; if ($wpdb->get_var(“SHOW TABLES LIKE ‘”. $ptbd_table_name .”‘” ) != $ptbd_table_name ) { $sql=”CREATE TABLE exone( customer_id INT(20) AUTO_INCREMENT, customer_name VARCHAR(255), order_type VARCHAR(255), … Read more
You need only use the default value on the wp_customize and that is all $wp_customize->add_setting(‘mytextoption’, array( ‘default’ => ‘defaultvalue’, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, replace defaultvalue for the value you want, and when the user activate the theme this line will register the default value on the DB only when not exist on the … Read more