Widget Options Not saving

Your problem is that you’re calling the wrong method for generating the name attribute. It should be $this->get_field_name(‘via_cat’) Also, you can use wp_dropdown_categories(), no need to reinvent the wheel: wp_dropdown_categories(array( ‘name’ => $this->get_field_name(‘via_cat’), ‘selected’ => (int)$instance[‘via_cat’], ));

How to Create a Custom WordPress Install Package?

I’ve answered a similar Question. Basically: create a Dropin plugin at the root of wp-content named install.php inside install.php, create a new version of the pluggable function wp_install_defaults() remove all unwanted defaults and customize at will, like: update_option(‘template’, ‘your-theme’); update_option(‘stylesheet’, ‘your-theme’); update_option(‘current_theme’, ‘Your Theme’); update_option(‘my_theme_options’, $theme_options_array ); auto-activate some bundled plugins bundle everything into one … Read more

Where should I use get_option in a plugin

Both ways are almost equal, the first will be slightly faster, because the callback is called only if the check equals to TRUE. Note you cannot test an option like this, unless the option name is really ‘my_option[option_1]’. What you probably want is: if ( $test = get_option(‘my_option’) and 1 === $test[‘option_1’] ) add_action(); An … Read more

Create pages automatically if they don’t exist

I think you want: if( get_page_by_title( ‘home’ ) == NULL ) create_pages_fly( ‘home’ ); Your original if condition said if the page exists (does not equal NULL), then create the page. Also, the 2nd argument should be a string, though it doesn’t really matter in this case since it’ll just default to ‘page’ anyway.

How to move wp-content (or uploads) outside of the WordPress directory

You have to define WP_CONTENT_DIR and WP_CONTENT_URL: const WP_CONTENT_DIR = ‘/path/to/new/directory’; const WP_CONTENT_URL = ‘http://content.wp’; The new path must be accessible for read and write operation from the WordPress core directory. You might need a helper function to add the new directory path to the open_basedir list: /** * Add a new directory to the … Read more

How to update the delete user confirmation form?

On the Users (wp-admin/users.php) page, WordPress uses wp_dropdown_users() to generate the users drop-down menu you’re referring to, so I’d suggest using the wp_dropdown_users_args hook to filter the users query, e.g. to show only 1 result (or 10, but surely not 55k!) and then use JavaScript to add/load the other results. So in this answer, I’m … Read more

Customizing the Subject Field in WordPress’ Notification Emails?

You can change them using a filter. The filter hooks you want to use are: For the first email message (confirming they really want to reset the password): ‘retrieve_password_title’ ‘retrieve_password_message’ For the follow-up email message (sending the new username and password): ‘password_reset_title’ ‘password_reset_message’ Update: To create and use these filters, put the following or similar … Read more

Highlight custom widgets in the admin area?

All widgets in the admin area get an id in the style widget-[global_counter]_[widget_key]-[widget_id], like widget-59_monkeyman_widget_shortcut-5 (installed widget) or widget-11_monkeyman_widget_shortcut-__i__ (an uninstalled widget in the list). If your widget key contains something unique for all your widgets (like your company name), you can use this and add a substring attribute CSS selector (which works in most … Read more

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