REST-API: extend media-endpoint

I found the solution for my problem. The object type for media is not media, it’s just attachment. So the following code works for me: <?php /** * Plugin Name: REST Response Modifier * Description: A simple plugin to modify the rest api * Author: TheBalco * Author URI: http://somepage.dev */ add_action(‘rest_api_init’, ‘tb_add_custom_rest_fields’); function tb_add_custom_rest_fields() … Read more

How to register activation and deactivation hook in plugin using OOP pattern

It can be demonstrated like this way: Step-1: Create a folder named includes (or any name you like) inside the plugin root folder. Create two new files named class-responsive-slider-activator.php and class-responsive-slider-deactivator.php Now, in class-responsive-slider-activator.php create a class – class Responsive_Slider_Activator { public static function activate() { //do your codes to execute upon activation } } … Read more

Can I submit a plugin that follows the PSR-2 coding style guide?

I would guess to the official plugin directory? Yes, the WP’s own coding standards are recommended, but not required: Keep your code (mostly) human readable. Intentionally obscuring code by hiding it with techniques or systems […] Minified code may be used, however the unminified versions should be included whenever possible. We recommend following WordPress Core … Read more

What’s the better way to add an inline script?

wp_add_inline_script() is intended to be used for inline scripts that use or depend on another script that’s been enqueued with wp_enqueue_script(). It ensures that the inline script is placed appropriately relative to the main script and will won’t appear if the main script is unregistered. The example from the announcement was using Typekit: function mytheme_enqueue_typekit() … Read more