Put the following line before using the function.
require_once( ABSPATH . '/wp-admin/includes/image.php' );
Related Posts:
- How to include PHP files in plugins the correct way
- Creating a table in the admin-style?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- body_class hook for admin pages
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- function deactivate_plugins does not exist
- What is the real intention for admin-post.php?
- Understanding WordPress functions’ naming conventions
- Admin config screen without menu
- Make Categories and Tags required in admin
- When is it appropriate to put functions on page template vs. functions.php?
- How can i list current author’s categories?
- why don’t I get error messages in admin when developing?
- WP_Error handles errors, but how can I show success with a message?
- Dynamically Override Fancy Title
- Problems with removing admin bar
- Problem with `wp_mail()`
- Calling a function from functions.php in custom page/ blog post
- What is the Difference between directly call a function and call a function using add_action?
- Call to undefined function get_blog_option()
- How to put placeholder text in the main post input area?
- Plugin development: is adding empty index.php files necessary?
- Undefined function wp_set_password
- What does $_registered_pages do?
- Plugin Uninstall and Deactivate via Options Menu
- Add tab to profile.php wordpress plugin development
- How can I add a CSS rule to edit.php?
- Widget update function not saving values
- add more custom post types and custom role to the code
- How to use WP_Term with (menu) argument in the wp_nav_menu?
- WordPress after content Hook & external template part
- Enqueue scripts in footer
- override pluggable.php functions
- maintaing consistent layout wordpress dashboard
- Add column and post filter for a custom post type field on the edit.php page
- creating custom function to log actions in plugin
- Is there no admin ui guide for 4.x?
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- Maximum lifetime for nonce
- Where can i find wordpress auto update code flows?
- Correct check for any admin page with editor
- Adding (blog-specific) links to “My Sites” admin page
- Adding option to Gallery shortcode
- Change the look and feel of admin pages
- Admin Plugin POST to another file within the plugin
- how to search users by ajax live search
- Remove unwanted elements for a wp_nav_menu
- How to add user details to different tables immediately after user registration
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Including comments meta box on a plugin page
- Checking for existence of a page by title?
- how to get context information inside my funcion
- WordPress class, using add_action to call member function does not work
- How to Move the Comments Bubble to the Right Side of the Toolbar
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Print Dashboard submenu name and filename
- Autogenerate a Table of Contents
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- WordPress multisite,use same cookies across all website?
- Call to undefined function is_home() or any conditional tags
- unregister_setting() vs delete_option() for plugin update
- How to change WooCommerce loop product title HTML output in single product page and archive page
- wp_schedule_event is registered but function isn’t running
- Disable Auto-Expanding Menu in WordPress Admin Menus
- Best practice for plugin: always detect admin-ajax call?
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- Remove Permalink Meta Box not working?
- Proper way to create an administration page without adding it to the menu
- Setting post_id for single.php based on URL without a redirect
- Javascript Function Called Too Early in PHP Script
- WP 3-way voting system: On to something! Please help!
- Custom Settings Plugin Save foreach checkboxes
- function add custom fields to media gallery
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- Make visible page only in the trash
- WordPress: I wanted to use Add rewrite rule multiple times for multiple CPT in my plugin
- WordPress Ajax not returning Response
- Remove tag from all posts when publishing new post
- WordPress plugin how to run function when button is clicked
- How to create plugin settings page for each admin user?
- foreach argument to get specific file types getting too many returns
- Remove from a div by class name from post page if post author role is not administrator
- How to return a blank page
- Ajax not working to insert, query and result data
- Adding admin for specific users
- How do I control the list of Pages an author can see?
- Template file structure , wordpress hook for altering the template
- WordPress permalink setting
- How can I add recent posts to menu like mashable
- Why is ‘register_activation_hook’ undefined?
- Dynamic banner for use on external sites
- How can i call from custom fields to the category editor?
- loop and in admin header problem
- Custom options page for themes
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Call do_action() within WordPress cronjob
- How to plugin function code move to theme function.php ? I’ve tried below code but not working [closed]
- WordPress simple ‘Hello World’ plugin – problems