Almost all of your code is correct. I didn’t even know about the insert_with_markers function, and now I do, so thank you.
In return, I believe I have your solution.
get_home_path()
is not defined when any of the hooks (init
,wp
, etc.) you mentioned are triggered. That function is defined in the admin-side “file.php”, which as part of the admin dashboard side of things, has not yet loaded.
The hook admin_init
, however, should serve you well, presuming you are making those .htaccess changes on the admin side. If not, you could either include wp-admin/includes/file.php manually, or use an alternate way of finding .htaccess, such as the constant ABSPATH (although they are not equivalent).
Using the admin_init hook on the first function you provided, I found the rules written to my .htaccess file the next time I loaded a page on the admin side.
By the way, you might want to do a check for current_user_can( 'edit_files' )
before allowing that code to run.
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- How to Loop Plugin Option Field Set?
- Update Multiple Post Meta for the Same Post In One call?
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to Create a Directory in a Plugin Folder?
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Create plugin that works in background
- Checking for user role in a custom plugin
- HELP: Integrating WP with raw PHP code once published button is hit
- Loading class files via autoload method
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Getting media library popup in custom plugin admin page
- jQuery function didn’t work in my plugin
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Escape when echoed
- Plugin Development sqlite or WordPress’ database
- Can WordPress Plugin Directory Cache Delay the Upload of Images?
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Correct way to perform non-cacheable DB query
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- 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
- What are the specifics of WordPress development I need to know? [closed]
- 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?
- Setup wp_schedule_event within a custom plugin
- Activate my plugins via FTP
- How to add apply_filter for a class property in plugin
- Issue running db create table query from static method
- execute function after one completed
- How to make multiple admin pages for one plugin?
- Integrating boxtal PHP library into a custom WordPress Plugin
- A server-side hook failed when committing plugin code to SVN
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- How to add/change (woocommerce) product tab icon
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- I want to generate the pdf and save it in library?
- Using meta_query in a WP_Query not working for numbers properly
- How to write to a separate PHP file in plugin settings
- Create “new pages” within the admin section of plugin
- More gentle way to hook WordPress custom url
- How to display results from a data table with an encrypted user id?
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- 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
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- Why is my shortcode not working?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- Using id to show item
- implement checkbox or toggle switch in plugin code
- 500 Internal server error wp_handle_upload_prefilter
- Create a form and have custom menu display based on user answers?
- Can’t access 3rd party API, code works on local server but not on wordpress
- WP Migrate DB Pro plugin cannot transfer Media files to remote server
- Get post content inside plugin class method
- Is admin section completely customizable in terms of styling?
- .htaccess file doesn’t work, with hundred tries
- Help Code Review – I need to write on .htaccess file from theme’s function.php
- Problem with conditional woocommerce custom checkout field
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Creating a user ‘add custom field’ section
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- Apache rewrite rules and wordpress problem
- How to add a handler for a button in plugin?
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Doing action based on input from options menu
- Load my plugin before cache
- How to fix ‘Call to undefined function do_settings()’ error?
- wordpress select multiple options and illegal string offset ‘timeslot’ [closed]
- how to search through plugin in wordpress cimy-user-extra-fields?
- How to add custom html to the Media > Attachment Details modal?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How to override plugin function in code snippets WordPress
- How to create a “Most Popular” & “Latest” TAB in WordPress
- WordPress Throwing Deprecated Errors on its own Files
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class
- plugin doesn’t retrieve data from database