Tracing dashboard publish settings from input form in WordPress

Those are some dangerous words “public…can enter data directly to the DB” You could write your own form and use wp_insert_post() Something like this: $new_post = array( ‘comment_status’ => ‘closed’, ‘ping_status’ => ‘closed’, ‘post_author’ => 1, // id of admin, or some other user ‘post_title’ => $_POST[‘title’], ‘post_name’ => $_POST[‘title’], ‘post_status’ => ‘draft’, ‘post_type’ => … Read more

Create new folder and upload files to custom folder via wp_handle_upload

This isn’t a working example but should help, Use wp_upload_dir() to define the default uploads folder and append a username to it using wp_get_current_user. $wp_upload_dir = wp_upload_dir(); $user_folder = wp_get_current_user(); // The actual folder $custom_upload_folder= $wp_upload_dir[‘basedir’] . $user_folder->display_name; //make the dir mkdir($custom_upload_folder); You would need to employ security and code that checks for errors/user capabilities … Read more

Plugin admin list pages as submenu

You do not post how you add the top level menu page, however I think when you click on a submenu item you have an url like: http://www.example.com/wp-admin/admin.php?page=theme_admin_{$pageid} So the id of page is in the $_GET[‘page’] variable with a fixed string prepended to it. So why don’t use something like: function display_page_test() { $id … Read more

WordPress automatic plugin update

Not sure if exactly what you’re looking for, but Advanced Custom Fields has a custom update message. Checking its code, it uses: add_action( ‘in_plugin_update_message-‘ . $hook, array($this, ‘in_plugin_update_message’), 10, 2 ); The in_plugin_update_message() callback method it’s not exactly simple and worth a detailed look. Note that it only works if the plugin is active.

Using Nonce for my Form

I figured out what I needed to do. I needed if(isset( $_POST[ ‘tdgmt_plugin_noncename’]) && wp_verify_nonce( $_POST[‘tdgmt_plugin_noncename’], plugins_url( __FILE__))){ to be above if($screen->base == ‘settings_page_tgdmt_options_page’){ as well as fixing my typos of tdgmt_plugin_noncename instead of tgdmt_plugin_noncename

WordPress rewrite question

Here’s an endpoint solution as mentioned in my comment. First, add the endpoint by adding this code to your theme’s functions.php file: function wpa_add_rep_endpoint(){ add_rewrite_endpoint( ‘rep’, EP_ROOT ); } add_action( ‘init’, ‘wpa_add_rep_endpoint’ ); Then visit the Settings > Permalinks page in admin after adding the endpoint to flush the rewrite rules so this endpoint will … Read more