How do I programatically insert a new menu item?

Before being printed, all the menu items get run through a filter. You can target the wp_nav_menu_items filter to tack things on to the menu: // Filter wp_nav_menu() to add additional links and other output function new_nav_menu_items($items) { $homelink = ‘<li class=”home”><a href=”‘ . home_url( “https://wordpress.stackexchange.com/” ) . ‘”>’ . __(‘Home’) . ‘</a></li>’; // add … Read more

Export data as CSV in back end with proper HTTP headers

Do not point the URL to admin.php, use admin-post.php instead: ‘<a href=”‘ . admin_url( ‘admin-post.php?action=print.csv’ ) . ‘”>’ In your plugin register a callback for that action: add_action( ‘admin_post_print.csv’, ‘print_csv’ ); function print_csv() { if ( ! current_user_can( ‘manage_options’ ) ) return; header(‘Content-Type: application/csv’); header(‘Content-Disposition: attachment; filename=example.csv’); header(‘Pragma: no-cache’); // output the CSV data } … Read more

Vagrant script to setup all the common PHP / WordPress version combinations

On the WordPress side of things, Basic WordPress Vagrant Environment is ready to work with any WordPress version (with a little help). You would still need to find a way to configure the PHP but there is a hint in https://github.com/ideasonpurpose/basic-wordpress-box/blob/master/ansible/roles/php/tasks/php.yml. To use it out of the box; Download or clone the project to wplatest-php55.dev/ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)