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

array_map() for sanitizing $_POST

It’s probably not a great idea. Firstly, if you’ve got other field types then you should probably use more appropriate functions. For example, textarea fields should be sanitised with sanitize_textarea_field(), and color pickers should be sanitized with sanitize_hex_color(). You should also consider that $_POST likely also contains fields that you don’t want to save, such … Read more

Modifying WordPress plugins

In the spirit of open source software, I would definitely start by contacting the original developer. If your changes are an improvement to the codebase, and do not take the functionality of the plugin in a new direction, collaboration may be welcomed. If your modifications are rejected by the original developer, there are some other … Read more