Plugin settings not saving

the problem is you keep resting the values here: $options = array( ‘cemb_seminar_seminars_college’ => ‘0’, ‘cemb_seminar_showcases_college’ => ‘0’, ‘cemb_seminar_writers_college’ > ‘0’, ‘cemb_seminar_aet_college’ => ‘0’, ‘cemb_seminar_mbu_college’ => ‘0’, ‘cemb_seminar_eis_college’ => ‘0’, ‘cemb_seminar_sng_college’ => ‘0’, ); update_option( ‘cemb_seminar_options’, $options ); change it to $options = get_option(‘cemb_seminar_options’); if ($options === false){ $options = array( ‘cemb_seminar_seminars_college’ => ‘0’, ‘cemb_seminar_showcases_college’ … Read more

Adding plugin settings link upon activation

Code extracted from my plugin, adapt as necessary. add_filter( ‘plugin_action_links’, ‘wpse_25030_settings_plugin_link’, 10, 2 ); function wpse_25030_settings_plugin_link( $links, $file ) { if ( $file == plugin_basename(dirname(__FILE__) . ‘/many-tips-together.php’) ) { /* * Insert the link at the beginning */ $in = ‘<a href=”https://wordpress.stackexchange.com/questions/25030/options-general.php?page=many-tips-together”>’ . __(‘Settings’,’mtt’) . ‘</a>’; array_unshift($links, $in); /* * Insert at the end */ … Read more

Auto add content such as pages upon plugin activation?

You can add those without a button: register_activation_hook( __FILE__, ‘my_plugin_install_function’); function my_plugin_install_function() { //post status and options $post = array( ‘comment_status’ => ‘closed’, ‘ping_status’ => ‘closed’ , ‘post_author’ => 1, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_name’ => ‘Checklists’, ‘post_status’ => ‘publish’ , ‘post_title’ => ‘Checklists’, ‘post_type’ => ‘page’, ); //insert page and save the id $newvalue … Read more

How can plugins have their own pages?

Believe it or not the WordPress official documentation has a great page covering this topic called Administration Menus. It also provides example code on how to use WordPress hooks in your plugin code to add custom setting pages and other pages like that. The page can be found here. Fire up the kettle and make … Read more