Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
Answered using insights from @Milo.
Answered using insights from @Milo.
Use custom clean URLs for a plug in
You have the same username as the plugin author? o.O The error comes from line 444: There’s two characters between ?> and the next <?php Change: add_action( ‘admin_menu’,’business_hours_menu’ ); ?> <?php add_action( ‘widgets_init’, ‘lordlinus_businesshour_load’ ); To: add_action( ‘admin_menu’,’business_hours_menu’ ); add_action( ‘widgets_init’, ‘lordlinus_businesshour_load’ );
I think you have to solve this with jQuery. If checked -> addClass, if not -> removeClass. Here’s how to enqueue your JS file: add_action(‘admin_menu’, ‘fwds_plugin_settings’); function fwds_plugin_settings() { $hook = add_menu_page( ‘Price Display’, ‘Price Display’, ‘add_users’, ‘fwds_settings’, ‘fwds_display_settings’ ); add_action( “admin_print_scripts-$hook”, ‘fwds_print_scripts’ ); } function fwds_print_scripts() { wp_register_script( ‘my-fx’ , plugin_dir_url( __FILE__ ) . … Read more
Your code should work (not how you expect but it should work), and probably the error was in something that you didn’t post. However… __FILE__ is a constant: you don’t have to use quotes when write it. Remove them like so: add_menu_page(‘Item Display’,’Item Display’,’administrator’, __FILE__, function(){ }); If you use the quotes, ‘__FILE__’ became a … Read more
Does the code that imports to the external DB need to be on a different page? Adding a conditional that checks if the form is submitted, to your callback function would work as well. Then your form posts the data back to itself, checks if the form is submited and runs the import script instead … Read more
Use the Settings API or hook a function to admin_init that checks permissions and nonces, saves the updated values and redirects to your settings page.
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
In order to show $_FILES or $_POST, you will need to create a sumbenu_page under the post_type. Then, you will be able to manipulate $_FILES and $_POST in whichever way you want. This means that upload_screen() function should be a submenu page.
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