WordPress custom plugin developement

Use add_submenu_page and set $parent_slug to null: add_action(‘admin_menu’, ‘wpdocs_register_my_custom_submenu_page’); function wpdocs_register_my_custom_submenu_page() { add_submenu_page( null, ‘My Custom Submenu Page’, ‘My Custom Submenu Page’, ‘manage_options’, ‘my-custom-submenu-page’, ‘my_custom_submenu_page_callback’, ); }

Deactivate Other Incompatible Plugin Upon Activation

Ok, based on the comments, I decided to just prevent activation and send an admin notice instead. add_action( ‘admin_notices’, ‘lsmi_admin_notice’ ); add_action( ‘network_admin_notices’, ‘lsmi_admin_notice’ ); function lsmi_admin_notice() { if( class_exists ( ‘Location_Specific_Menu_Items_By_City’ ) ){ global $pagenow; if( $pagenow == ‘plugins.php’ ){ deactivate_plugins ( ‘lsmi-by-country/LSMI_Country.php’ ); if ( current_user_can( ‘install_plugins’ ) ) { echo ‘<div id=”error” … Read more

Developing a plugin where users can edit entries saved in database

I’ve managed to do it, but probably there is a much cleaner WP way of doing these things. So, I have a menu page that I’ve added using add_menu_page. On it, I display all the records. The url is: /wp-admin/admin.php?page=plugin-settings (or whatever you call it) I use: <a href=”https://wordpress.stackexchange.com/questions/218076/<?php echo bloginfo(“url’);?>/wp-admin/admin.php?page=utm-user-plugin-settings&id=<?php echo $row->id; ?>”>Edit</a> So … Read more

Adding admin for specific users

You can use add_role function : add_role( $role, $display_name, $capabilities ); Just set your custom values as you wish : add_role(‘basic_contributor’, ‘Basic Contributor’, array( ‘read’ => true, // True allows that capability ‘edit_posts’ => true, ‘delete_posts’ => false, // Use false to explicitly deny )); Plugin : https://wordpress.org/plugins/user-role-editor/

Use plupload to upload images and save them to custom folder and database table

I managed to do it by myself thanks to this tutorial. Moved content of do.php file to a function named cmr_upload inside a class. Then changed the plupload options from: url : plugin_dir + ‘do.php’, … multipart_params : { “chapter_id”: i, “path”: path to url : ‘<?php echo admin_url(‘admin-ajax.php’) ?>’, … multipart_params : { “chapter_id”: … Read more