plugin_dir_url() returns the URL directory path for your plugin, so this won’t work as expected (the function won’t be called):
register_activation_hook(plugin_dir_url(__FILE__) . 'frequentVisitorCoupons.php',
'Utilities::createTablesIfNotExists');
You should have used plugin_dir_path() which returns the file-system directory path for your plugin (e.g. /var/www/public/<user>/wp-content/plugins/your-plugin/).
But if the code is in the main plugin file, then you could simply use __FILE__:
register_activation_hook(__FILE__, 'Utilities::createTablesIfNotExists');
Sample plugin main file:
<?php
/*
* Plugin Name: My Plugin
*/
require_once 'path/to/classes/utilities.php';
// Installs the tables on plugin activation.
register_activation_hook( __FILE__, 'Utilities::createTablesIfNotExists' );
Related Posts:
- Help With MySQL to WPDB Query Conversion
- WPDB: Update table
- How to create plugin/ page that reads from database
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- How to display results from a data table with an encrypted user id?
- How to securely controlling data without keeping it in postmeta?
- Using id to show item
- plugin doesn’t retrieve data from database
- What are the differences between WPINC and ABSPATH?
- How to delete all records from or empty a custom database table?
- Using require_once in a Plugin?
- Simple form that saves to database
- How to find out if option exists but is empty?
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Scope for PHP Variables Assigned in functions.php or a plugin
- Plugin Development sqlite or WordPress’ database
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Where should I save an API key of my user when installing my plugin?
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- wordpress plugin is not activating from widget
- How to access data in wordpress database externally using php
- Creating mySQL procedure with $wpdb
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Prevent duplicate records in plugin table
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- Update results, Before deleting the related category [closed]
- What are the specifics of WordPress development I need to know? [closed]
- Ajax call returning 0
- How to replace WordPress Media Upload Window with user’s device window?
- How to create a custom post type that contains another custom post type?
- Redirect to another page using contact form 7? [closed]
- Setup wp_schedule_event within a custom plugin
- Is it necessary to auto delete my WP plugin database tables when users deactivate/delete my plugin?
- Activate my plugins via FTP
- How to insert and call new data in wordpress website database through a plugin
- How to add apply_filter for a class property in plugin
- execute function after one completed
- How to make multiple admin pages for one plugin?
- Integrating boxtal PHP library into a custom WordPress Plugin
- Why is it important to check for isset and is_array before checking in_array in this example?
- How to add/change (woocommerce) product tab icon
- I want to generate the pdf and save it in library?
- How to call external functions from a PHP script in a WordPress plugin?
- How to write to a separate PHP file in plugin settings
- Create “new pages” within the admin section of plugin
- select a single val though a table in wordpress
- More gentle way to hook WordPress custom url
- Integrating Custom Database with WordPress
- How to add custom function to pluggable.php
- add_action for publish_post doesn’t work
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- Getting URL GET parameter with Code snippets and storing it in database?
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to Add text value in Automatically in this conditions?
- Checkbox show / hide output result
- save_post_product action not firing
- How to get the custom field value using SQL query
- admin_notices show after load completed
- Prevent WordPress from sending set-cookie http header
- How use wp_insert_post and add og:custom tags?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- How to change “Read More” text?
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- 500 Internal server error wp_handle_upload_prefilter
- Can’t access 3rd party API, code works on local server but not on wordpress
- Generate and send ICS file through WordPress
- Get post content inside plugin class method
- Is admin section completely customizable in terms of styling?
- Change pricing in Woocommerce based on Category and Product [closed]
- WordPress environment not loading properly
- Where do the section input fields values are stored in database
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Creating a user ‘add custom field’ section
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- How to add a handler for a button in plugin?
- Doing action based on input from options menu
- Create New Admin Menu Section – Like how custom post type works, in a way
- Load my plugin before cache
- My wordpress website admin panel loads very slow, what can i do about that? [closed]
- wordpress select multiple options and illegal string offset ‘timeslot’ [closed]
- Get all the related data from WordPress DB
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- get_option returning a different value from what’s saved
- How can I delete the options from DB when the plugin is deleted?
- wp_handle_upload – specified file failed upload test
- How to make a Template page to show the information of different things Shop and Product page?
- public custom posts not showing in my wordpress plugin
- add_action() not working for admin
- Error 400 Invalid “products[1].productId” Kinguin [closed]
- Plugin question, How to insert a colon in a value box
- Woocommerce attatch files and custom input meta to cart items and then to order
- Call to undefined function create_function() – PHP 8.2
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1