Our themes and plugins use hooks to run code when an event fires. We use WordPress’ functions to add or remove a hooked callback, fire the event, or check the status. How do you unit test those interactions without loading WordPress? Meet Brain Monkey. Brain Monkey gives you the power to unit test hooks by simulating WordPress. In this lab, you’ll walk through building unit tests for hooks.
The What Syntax mixed beans_apply_filters( string $id, mixed $value [, mixed $… ]] ); Beans Code Reference Description This function extends the power of WordPress’ apply_filter by: Using a smart unique ID Processing sub-hooks within the unique ID More coming soon…keep checking back. Parameters id The unique ID, is broken up into individual filter event name’s. Sub-hooks are specified using square brackets, such as ‘hook[_sub_hook]’. value The value which will be filtered by the registered callbacks. … optional Additional argument(s) to be passed to the registered callbacks. Return Values Returns the filtered value. Show It in Action More coming soon…keep […]
The What Syntax beans_open_markup_e( string $id, string|bool $tag [, string|array $attributes [, mixed $… ]] ); Beans Code Reference Description This function builds and renders the HTML for the specified opening tag’s HTML with the specified attributes (optional). It uses beans_open_markup and then echoes the return string out to the browser. It provides flexibility for 3rd party customization (i.e. child theme and/or plugins) to remove or change the HTML. The power of Beans is the ability to customize whatever you need via the unique ID and internal functionality. Using the specified $id, a child theme or plugin can register to […]
Let’s dive into the Bean’s framework to understand how the beans_open_markup() function works.
Let’s say that you want the “read more” link or button to be wrapped in a <p> element. You want it as a separate paragraph. How would you do that? One approach is to use the WordPress “read more” link filter event. You’d register a callback and then wrap the HTML that Beans builds within a paragraph element.