Prevent Data Resubmission On Page refresh

To prevent multiple button clicks, you can use JavaScript to disable the button. jQuery(‘#review_member_button’).on(‘click’, function(evt) { jQuery(this).attr(‘disabled’, ‘disabled’); }); On the WordPress end, you can set a unique key for the form every time it’s generated and check to see if a form with that key has been resubmitted. I would recommend setting a transient, … Read more

Where would I find Custom menu attributes in the database?

Nav menu items are posts of the type nav_menu_item. They are combined to a nav menu by an assigned term from the taxonomy nav_menu. Each nav menu is a collection of posts under a term. The function wp_get_nav_menu_items() is probably the best start to explore this. The tables {$prefix}_terms and {$prefix}_term_taxonomy are queried for the … Read more

Split WP_POST table based on post types

You could filter ‘query’ (you get the complete SQL here) and search for the post type in that. Then switch the database depending on what you found. But I don’t think this would work well: You might end up with the same post ID used multiple times (in each DB) and some strange side effects … Read more

For best DB performance should I serialize all theme options together or by type?

All options with autoload = yes (default) are fetched very early in one query. So the number of options does affect performance only marginally. Split options if you don’t need everything on every page load. With … add_option( ‘option_name’, ‘option_value’, ”, ‘no’ ); … you can set options that aren’t loaded before you actually call … Read more

How can I get a list of comments by target

When it comes to retrieve posts, it’s supposed to call WP_Query. WP_Query has an argument called meta_query but it doesn’t have comment_query. So it might need a trick to achieve what you want, $args = array(); $args[‘feed’] = 1; $args[‘withcomments’] = 1; $args[‘author’] = 1; //author id. $query = new WP_Query($args); $posts = $query->posts; //do … Read more

How to interact with another wordpress install on same database?

Reading through the source code for the wpdb class, I see no reason why something like this shouldn’t work: $otherdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); $otherdb->prefix = ‘wp2_’; And then (if I’m understanding this right) you can use all the existing $wpdb methods and variables. Eg: $x = $otherdb->get_results( $sql_query ); (If I’m wrong … Read more