Where to get information about array fields in $_REQUEST?

This is mostly pure PHP, but it does have WordPress twist. PHP has number of superglobal variables, that contain information relevant to current request. Out of those: $_GET contains info from URL (HTTP GET request) $_POST info from form submission (HTTP POST request) $_COOKIES about cookies set and $_REQUEST is combination of the above (according … Read more

Menu Items Disappearing

The following has worked for some users with similar problem: Try to increase the value of the max_input_vars variable in php.ini. This variable was introduced in PHP version 5.3.9 and has the default value of 1000. You can read more about it in the PHP documentation: http://php.net/manual/en/info.configuration.php max_input_vars 1000 PHP_INI_PERDIR Available since PHP 5.3.9. How … Read more

Proper use of Output Buffer

No, you don’t need output buffering in this case. As a rule of thumb: Don’t use output buffering unless you really have to. Just imagine what happens if someone else uses output buffering too from a plugin and it crosses with yours: // plugin ob_start(); // later, you in your theme ob_start(); // you call … Read more

Hide main div if wp_nav_menu is empty

Assign the menu to a string: $menu = wp_nav_menu( array ( ‘echo’ => FALSE, ‘fallback_cb’ => ‘__return_false’ ) ); if ( ! empty ( $menu ) ) { echo ‘<div class=”navmain2″>’ . $menu . ‘</div>’; }

How to stop jQuery.migrate manually

jQuery Migrate is nothing but a dependency of the jQuery script in WordPress, so one can simply remove that dependency. The code for that is pretty straightforward: function dequeue_jquery_migrate( $scripts ) { if ( ! is_admin() && ! empty( $scripts->registered[‘jquery’] ) ) { $scripts->registered[‘jquery’]->deps = array_diff( $scripts->registered[‘jquery’]->deps, [ ‘jquery-migrate’ ] ); } } add_action( ‘wp_default_scripts’, … Read more

What does the token %1$s in WordPress represent [closed]

Read the PHP docs on sprintf(). %s is just a placeholder for a string %d is just a placeholder for a number So an example of sprintf would look like this: $variable = sprintf( ‘The %s ran down the %s’, // String with placeholders ‘dog’, // Placed in the first %s placeholder ‘street’ // Placed … Read more