How to add multiple custom URL variables?

I pretty sure this filter lets you add an array of variables. I’ve not tested this: function add_custom_query_vars( $vars ){ $vars[] = “variable1”; $vars[] = “variable2”; $vars[] = “variable3”; //… etc return $vars; } add_filter( ‘query_vars’, ‘add_custom_query_vars’ ); Or another way of doing it would be to do this: function add_custom_query_vars( $vars ){ array_push($vars, “variable1”, … Read more

What is the recommended way to create plugin administration forms?

I personally just add a menu link and in the function for it handle the form. With $_SERVER[‘REQUEST_URI’] as the action. Example below. add_action(“admin_menu”, “menu” ); function menu(){ add_menu_page(‘Test form’, ‘Test form’, ‘manage_options’, ‘show_form’ ); } function show_form(){ if ( $_SERVER[“REQUEST_METHOD”] == “POST” ){ print “do stuff”; } else { ?><form method=”post” action=”<?php echo $_SERVER[‘REQUEST_URI’]; … Read more

PHPUnit testing WordPress Plugin

The reason the WordPress test bootstrap is loaded at the end is precisely because it loads WordPress: // Load WordPress require_once ABSPATH . ‘/wp-settings.php’; If you don’t hook your function to load your plugin to ‘muplugins_loaded’ before including the bootstrap, your plugin won’t be loaded with WordPress. In most cases that will mean that your … Read more

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