How to get the current plugin folder url in WordPress?
plugin_dir_url( ) function is used to get the current url. Sample: $imgurl=plugin_dir_url( __FILE__ ).”placeholder.png”;
How to get the plugin folder path in wordpress?
echo $plugin_folder= plugins_url(); To get any specific file inside plugin directory use : Here getting path of file ‘widget_newslider11123.html’ insde plugin “books” echo plugins_url(‘books/widget_newslider11123.html’); Reference : https://codex.wordpress.org/Function_Reference/plugins_url
How to get the current plugin folder path in WordPress?
Current plugin folder path : plugin_dir_path( __FILE__ ) To include a file in this path: include(plugin_dir_path( __FILE__ ).”widgetfile.html”);
How to create custom tables for wordpress plugin ?
After creating plugin and writing required hooks, we can create tables. We can call these function inside acivation hook. So once we activate the plugin, table creations will be done. /* Plugin Database Creation Starts Here, call this function inside a activation hook. Table name :mynewtable */ function db_initialize(){ global $wpdb; // Global object $charset_collate…
How to register uninstall hook plugin?
Using register_uninstall_hook we can register the uninstall hook. /* Plugin Uninstall Hook Here */ register_uninstall_hook(__FILE__, ‘avg_point_uninstall’); function avg_point_uninstall(){ }
How to register activation hook and deactivation hook for plugin?
Using register_activation_hook we can register the activaton hook. /* Plugin Activation Hook Here */ function avg_point_activation(){ global $wpdb; } register_activation_hook(__FILE__, ‘avg_point_activation’); Using register_deactivation_hook we can register the deactivaton hook. /* Plugin Deactivate Hook Here */ function avg_point_deactivation(){ } register_deactivation_hook(__FILE__, ‘avg_point_deactivation’); Using register_uninstall_hook we can register the uninstall hook. /* Plugin Uninstall Hook Here */ register_uninstall_hook(__FILE__,…
How to create a plugin in wordpress?
1. Create a folder in plugins folder . Project Folder >>wp-content >> plugins >> New folder. 2. Name the folder in such a way that related to functionality of plugin. Sample : To give average rating for post name the plugin as : average-rating 3. Create a php file with same name as the created…