Add form fields dynamically on button click

You can do that using Javascript, by creating new DOM elements. You can use this Try it yourself functionality from W3Schools Copy and paste this code into Try it yourself and see how it works, it just adds a new paragraph: <!DOCTYPE html> <html> <body> <div id=”div1″> <p id=”p1″>This is a paragraph.</p> <p id=”p2″>This is … Read more

Retrieving plugin options value saved through setting

You are saving data to an option named my_option_name so your attempt to retrieve data from an option named $this->options[‘title’] isn’t going to work. You will need something like this: public function DataToget($field = ”) { if (empty($field)) return; $jugHigh = get_option( ‘my_option_name’ ); if (!isset($jugHigh[$field])) return; return $jugHigh[$field]; } With a shortcode like: if … Read more

Create a custom page template inside my wordpress plugin

You will create a page template whose file name is custompage-template.php here I suppose put in in your plugin dir/views/ folder. Whenever the page whose title is Your Page Name is visited, the site will render your custom template add_filter( ‘page_template’, ‘fw_reserve_page_template’ ); function fw_reserve_page_template( $page_template ) { if ( is_page( ‘Your Page Name’ ) … Read more

How to make Http Request to a php file present in plugin directory of wordpress

Here is a quick and dirty plugin that shows you how to achieve this (adapt this example to your own architecture and needs): <?php /* Plugin Name: Custom rewrite rule test */ add_action( ‘plugins_loaded’, array(Registration::get_instance(), ‘setup’) ); class Registration { protected static $instance = NULL; public function __construct() {} public static function get_instance() { NULL … Read more

How does WordPress process plugin installations?

OK, so I think I got everything that is needed. So yes, you could work with a combination of: plugins_api install_plugin_install_status install from an instance of Plugin_Upgrader This may seem elaborate but you can actually see from the WP-CLI project that it is quite straight-forward. Of course, you can just install that excellent plugin and … Read more

Pass info from functions.php to plugin

Plugins are loaded before the theme which means that your apply_filters won’t have any actual callbacks registered to it. Instead, you need to call your apply_filters sometime after the theme has been loaded. Something like this: /* Your plugin’s file: */ add_action( ‘init’, ‘my_lovely_funky_filters’ ); function my_lovely_funky_filters() { /* Fire our callbacks */ $value = … Read more

Register script in one plugin, and enqueue it in another

Prioritize your actions, so the register_style function runs first. (notice the third parameter in the add_action function) add_action( ‘wp_enqueue_scripts’, ‘other_register_styles’, 11 ); function other_register_styles() { wp_register_style( ‘style’, PATH . ‘assets/css/style.min.css’ ); wp_enqueue_style( ‘style’ ); // Working as expected wp_enqueue_style( ‘fontawesome’ ); // Currently not working! } The default priority is 10, so you just need … Read more

Do We Need to Validate, Sanitize, or Filter Simple Numerical Superglobals (Cookies and Post)?

Without reading the question, just from the title, the answer is YES. Any input from the outside world should be validated and sanitized where appropriate, and this include inpude the server recieves the fact that it might have been generated in a form you designed is irrelevant. Input should never be trusted. Now about internal … Read more