The register_activation_hook()
function takes two parameters: the first parameter is the path to the main plugin file, and the second parameter is the name of the function to be executed when the plugin is activated. In your case, you are passing the plugin directory path to the register_activation_hook()
function instead of the path to the main plugin file.
To fix this, you need to change the first parameter of the register_activation_hook()
function to the path to the main plugin file.
define('PROMO_DIR_PATH', plugin_dir_path(__FILE__));
function activate_promo_card() {
// ...
}
function deactivate_promo_card() {
// ...
}
register_activation_hook( __FILE__, 'activate_promo_card' );
register_deactivation_hook( __FILE__, 'deactivate_promo_card' );
Related Posts:
- What is the advantage of using wp_mail?
- Plugin Form Submission Best Practice
- Plugin directory “Last Updated” not changed after initial commit?
- What is the recommended way to create plugin administration forms?
- Fatal error: Call to undefined function wp_mail()
- Does WordPress have an Browser Agent?
- How Do I Load My Action Earlier Enough?
- How to check WordPress website username and password is correct
- How to sync with plugins update after I have done manual optimizations?
- How to retrieve a value via get_option when the option_value is stored in a multi-dimensional array?
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Filter on the_content ignores shortcodes
- Custom theme sufficient or custom plugin neccessary for this feature set?
- Replacing WordPress menu functionality with a plugin
- Check spam in custom form – akismet
- Add Admin Menu Inside Construct or Init
- get plugin directory url
- WordPress cron running twice
- How to create thumbnail of different files?
- Database for development
- PHP library that can merge stylesheet with inline style [closed]
- Admin-ajax.php appending a status code to ajax response
- comment_email hook doesn’t seem to work for comment editor field
- How can I add a field to make link nofollow to the WordPress Link Inspector Window?
- admin_notices not displaying in plugin
- How to create multiple Gutenberg blocks in one plugin
- How to disable reCaptcha v3 except on Contact Form 7 pages?
- How to get color name in PanelColorSettings in custom Gutenberg block?
- Get Objects While Deleting term
- Fetching the value of forms in WordPress AJAX
- Cannot redeclare function error on the same line
- js/css updating when making a plugin
- settings_fields() doesn’t work for other roles except admin
- Subscribe to author?
- Get Current Menu Location inside Nav_Walker
- Append country to ‘pretty’ url but serve same page
- Set page template programaticlly in plugin
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Adding a brand column to WooCommerce Products
- How to use output buffering in WordPress hooked functions?
- Custom GET Parameters In Plugin’s Admin Page
- Adding option to Gallery shortcode
- WordPress Search filter to remove possible script injections
- Plugin menu addition in multisite
- Mixing and Matching – Custom templates in a WordPress plugin
- Open Graph Object Debugger & url parameters – Page Not Found result
- How to get Metabox custom field to show checked if value is updated using post meta query?
- wp_schedule_event seems to be being added twice
- Where do I put my add_action(… and add_filter(… and do I need to remove them?
- How to Move the Comments Bubble to the Right Side of the Toolbar
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- What happens when two or more plugins use the same hook?
- Can’t find where to modify attrbitutes
- How to pull user/author profile data in a plugin?
- Adding columns to core tables
- ajax recursive calls on wordpress returning answers outsite the function scope
- Add Password Generator on password protected page
- WordPress pages are not published due to External database connection with WPDB class
- How to optimize multiple insert into wordpress database
- Injecting HTML on (arbitrary) admin pages
- Custom Stylesheet instead of Inline CSS for WordPress Customizer API Overrides
- How to add custom options for plugin into the add post screen – like yoast seo
- How to find where an object first instantiatiation
- Information on plugin adding text when a post, page, or other such is displayed
- How to relate the Category to user?
- Plugin’s total number of users
- How to edit wp-signup.php content using plugin
- Get coordinates of selected area to use in image maps [closed]
- Setting post_id for single.php based on URL without a redirect
- How to trigger selected option from a clic. (variation product woocommerce)
- WordPress Favicon not Working For Images/Videos/PDFs
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Show username only if logged in in a else no directly name
- Conditionally check if page is using template from plugin directory
- plugin css is not being applied to the page
- Is it possible to develop themes and plugins locally while still allowing content to be updated directly in the admin dashboard?
- Is there any way to get post meta from publish_post hook?
- How to save multiple values in custom post type from front end to back end
- How to create plugin settings page for each admin user?
- Using JavaScript in WordPress page to call for server data using AJAX
- Headers already sent on custom plugin (Export function)
- Insert Data into Database
- login_message filter not working
- Handle changed Woocommerce function
- Making Woocommerce optimized for more than 500k products
- Displaying Custom Post Meta
- wp_enqueue_style don’t register all google fonts
- API WordPress is Limited? Return False
- How to return a blank page
- Array/List Edit in Backend
- How to Modify My Plugin’s Admin Settings so that the Plugin can be Added to a Specific Page?
- Add placeholder into contact form 7 recaptcha text field
- To remove rendering of menus and header, plugin or theme?
- Wrapping shortcodes in another shortcode
- Adding a custom button to WordPress Add Post (and Edit Post too) screen, that can save the post
- How to display custom taxonomy and terms using/creating plugin template
- Display Data’s metabox in page
- How to add ‘use_desc_for_title = 0’ to all wp_list_categories calls?
- Modify a Themes Appearance >> Header admin screen from a plugin
- Display months on a drop down calendar as TEXT instead of Numbers