Other than order of execution it doesn’t really matter where code is run.
In general case you can move code to Functions File (functions.php
) of theme or create simple plugin and it will still work.
In this specific case the code seems to be part of WooFramework so you will need to additionally check so that it isn’t declared twice (causing error), for example by using function_exists()
.
Related Posts:
- body_class hook for admin pages
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Why does WordPress add 0 (zero) to an Ajax response?
- How to redirect to settings page once the plugin is activated?
- How to add multiple custom URL variables?
- Implement phpunit testing on a plugin
- How long does it take to update a plugin page from the readme.txt?
- A Post is saved twice or more during add_action(save_post)
- Problem creating cron job wordpress
- Hook event for upload image in the menu
- Plugin Localization
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- array_map() for sanitizing $_POST
- calling jquery function on plugin page
- Is there a faster way than wp_insert_post to add content to a blog
- How to include external library in wordpress plugin
- Delete a specific item menu when I deactivate my plugin
- Ajax in WordPress – path issue
- Decrease RSS cache time in plugin?
- How to add a custom tag in contact form 7 and change the output in email?
- How can I create a plugin that changes the title color of a website?
- How to check if Woocommerce Order number equals to post ID?
- Add custom element ID depending where the widget place is, sidebar or footer
- Two functions utilizing registration_errors filter
- Issue plugin commands in admin settings page
- My plugin class doesn’t work! [closed]
- Creating a shortcode, but getting tied up with OOP and Classes?
- Call PHP file within a plugin to activate function
- add_action not calling back to function
- Example Dashboard Widget, Cancel not working
- Woocommerce checkout update totals with datepicker
- add_shortcode() not working inside of function
- How to add and remove a page
- correct way to call javascript into hook function
- “dashboard”-named PHP file doesn’t get included
- How to get plugin activate URL to use URL vars?
- rewrite URL based on selected taxonomy for post page
- Woocommerce – Convert Delivery method into a custom field
- Possible to get all posts with my shortcode?
- Plugin uninstall function is not working
- Loading custom js file on the admin page through plugin
- How to prevent someone from entering strings without making it available for translation?
- What’s wrong with my usage of add_filter
- Moving/dragging a metabox removes TinyMCE’s content
- How can I develop a plugin that generates a page dynamically
- Redirect in WordPress plugin
- Converting data-name editor plugin to Gutenberg plugin
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- Can calling wp_enqueue_style in wp_iframe apply the stylesheet to everything not just the iframe?
- Copied files from plugin to theme not working
- How can I allow the user to press enter without creating a new element in the editor?
- Forward an old url rewrite scheme to a new one?
- Will a plugin able to know is_user_logged_in?
- Widget instance options not showing correctly
- How Place a Custom Form Fields in a specific location on the User Profile Page?
- Access to the template file of a plug-in
- Can’t remove action hook on plugin class
- Bootstrap within shortcode
- How to make premium plugin? I want to limit it until verification
- `registration_errors` filter doesn’t seem to be called
- How to grab data after wp user search is complete
- How to direct WordPress to load custom template for custom post type
- get_the_tags doesn’t works?
- WordPress discards PNG file when uploading plugin file
- Registration Forms
- Override theme’s WooCommerce file
- My plugin showing “Are you sure you want to do this” on screen with a “Argument #2 is not an array in load.php’
- Cannot save settings value
- Is it possible to modify an Elated plugin portfolio-list template in such a way that it will not conflict with future plugin updates?
- Displaying settings information in a table
- Add Admin menus or submenus depending on conditions
- Plugin settings not saving and 404 is generated on submit
- Refresh or redirect page after activate my plugin
- Why does is_front_page and is_home always return true for posts in wordpress? [closed]
- How to Rewrite WordPress URL for a Plugin
- modify buddpress adminbar only in admin pages
- Are custom posts delete by unregistering post type
- How to translate WP plugin name?
- Why isn’t my readme.txt file being read
- How to update WordPress Plugins in your own maintance application?
- register_setting registered with incorrect data type
- Custom Nav Walker $item->url producing malformed hyperlinks
- Extend Plugin that creates an endpoint for GET request to also accepts POST requests
- Personalized URL for non-logged in WordPress
- WordPress Breadcrumb Taxonomy Display
- Adding custom avatar field to comments
- i want to auto create pages with shortcode when plugin is activated and delete when deactivated
- WordPress plugin options page not saving options, no errors
- WordPress database error: [Table ‘bitnami_wordpress.questions’ doesn’t exist]
- How to manage different tier plugin subscriptions to users
- Plugin submission denied for “Calling file locations poorly” when using WP_PLUGIN_DIR constant
- Do plugin auto-updates also run for a lower version?
- wordpress wp_editor() does not support tag
- Insert meta-description into Yoast-SEO input-field via JavaScript
- Loading all PHP files all the time or only when they needed in Custom Plugin Development [closed]
- Showing Home option in dropdown when there is no Home page exist
- REST API error in block editor for custom templates
- Execute callback after REST API request completes + Response is sent
- High-Performance Order Storage conflict action `manage_shop_order_posts_custom_column`
- Set srcset on a block image