WordPress Plugin Activate / Deactive Failing

So the ‘activate_plugin’ was a typo in the question. But even so, as a friendly reminder (for all of us), activate_plugin() is an existing function in WordPress. And you should use unique prefix in your custom functions (that are defined in the global scope): function my_plugin_activate_plugin() { … } register_activation_hook( __FILE__, ‘my_plugin_activate_plugin’ ); The Problem … Read more

Add Link Category on Activation?

Link category is a simple taxonomy just like categories , named: link_category so to add one you can use wp_insert_term() eg: wp_insert_term( ‘My link category’, // the term ‘link_category’, // the taxonomy array( ‘description’=> ‘this is a description.’, ‘slug’ => ‘my-link-category’ ) ); and to make all this happen on plugin activation take a look … Read more

I have no images in an activated wp theme

images folder is inside theme’s folder. But relative URLs do not work that way. They are relative to the URL not to the filesystem path. Your problem is here: <img id=”thinker01″ src=”https://wordpress.stackexchange.com/questions/74779/images/thinker01.png” width=”120″ height=”163″ /> If you look at the request (via HttpFox or other means) you will see that the browser is looking for … Read more

register_activation_hook for multiple functions

My approach to this would be to have a start_activation() method that calls the other methods. register_activation_hook( __FILE__, array( ‘my_plugin_loader’, ‘start_activation’ ) ); class my_plugin_loader { function start_activation() { $this->func1(); // or self::func1(); $this->func2(); // self::func2(); for static methods } function func1() { // do stuff } function func2() { // do other stuff } … Read more

How to create multiple database tables on plugin activation?

Why only the second? Because dbDelta() supports CREATE TABLE table_name format only. I.e. Exactly “CREATE TABLE” followed by (one space and) the table name. More specifically, dbDelta() uses this regular expression pattern: CREATE TABLE ([^ ]*) when parsing the queries into an array indexed by the table name; i.e. array( ‘table_1’ => ‘query’, ‘table_2’ => … Read more

register_activation_hook in oop approach

It doesn’t really matter. If you simply must have it inside a class, I would use a constant and a static method. // in the main plugin file define( ‘MYPLUGIN_FILE’, __FILE__ ); // include another file with this class in class MyPlugin { public static function init() { register_activation_hook( MYPLUGIN_FILE, array( ‘MyPlugin’, ‘install’ )); } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)