You can add those without a button:
register_activation_hook( __FILE__, 'my_plugin_install_function');
function my_plugin_install_function()
{
//post status and options
$post = array(
'comment_status' => 'closed',
'ping_status' => 'closed' ,
'post_author' => 1,
'post_date' => date('Y-m-d H:i:s'),
'post_name' => 'Checklists',
'post_status' => 'publish' ,
'post_title' => 'Checklists',
'post_type' => 'page',
);
//insert page and save the id
$newvalue = wp_insert_post( $post, false );
//save the id in the database
update_option( 'hclpage', $newvalue );
}
This function will run when the user installs the plugin. For super smart control you should check if that option already exists and if the id is not 0 (that means failure)
Related Posts:
- Uninstall, Activate, Deactivate a plugin: typical features & how-to
- Function to activate WordPress theme inside a plugin
- Activate Plugin which is in subfolder?
- Force plugin to fail activation
- WordPress register_activation_hook table creation not working
- Correct way to use register_activation_hook
- How to automate wordpress plugin activate and deactivate by php logic?
- Default Plugin Settings Not Writing to Database
- Own plugin corrups plugin-activation
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Force file download on plugin activation
- Run function on plugin activation before plugin is loaded
- My plugin does not install correctly if a previous version is still installed
- Activation flow of a plugin in a multisite environment
- How to check for already existing plugin versions on activation? and prevent errors
- My WordPress activation hook isn’t working
- Notify Admins about Plugin Merge
- Adding Featured Image in Post List
- Why does including a file in theme’s functions.php not work?
- WooCommerce – Call to undefined function is_woocommerce()
- OEmbed from Pinterest
- Custom values are not translated
- Should I use RIPS tool to test my themes and plugins?
- Add Top-Level Menu that opens URL
- Change the name of an installed plugin
- Issue with post request to admin-post.php
- action-scheduler vs wp-background-processing
- Do you clean up your self-written plugins’ at deactivation?
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Accessing GET variable named ‘error’
- download_url() appears as grey icons
- Plugin not appearing after uploading it via FTP
- How can I add an options page for my class based plugin?
- Sending WP posts to external API
- Any Short code Availble for Get Post List With Thumbnail Plugin?
- Any hook for pre-plugin-update -either bulk or single plugin update
- wp_create_nonce function doesn’t work inside a plugin?
- When to load auto-login code?
- CSV file generation failing
- finding whether request is for post, and post id
- 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
- Owl Carousel2 image not displaying full width when using Stretch row and content, Stretch row and content(no padding) in wordpress
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- Get Time Taken By Each Action Hook in WordPress
- How to replace WordPress Media Upload Window with user’s device window?
- Buidling a translate plugin for wordpress
- Force language in translate function
- wp_footer hook only working on homepage not in other pages
- How do I combine a theme with a plugin
- Use wp-config.php constants in all files of plugin
- Prevent direct access to WordPress plugin assets?
- Using ACF default value to autoincrement a number field
- How to automatically add edit link on frontpage post of any wordpress theme?
- A question about register_activation hook
- plugins_url() works everywhere but wp_reqister_script()
- Is there a plugin for automatically adding a word or symbol after a trigger word? I.e. Like a search and replace but more like search and add? [closed]
- Integrating boxtal PHP library into a custom WordPress Plugin
- Images under 1MB are not being compressed
- Sanitize $_GET variable when comparing
- Where can I save plugin data?
- show my own admin_notices after a post has been published
- How to add a WordPress Nonce for this form to avoid CSRF
- Overriding current theme files via plugin
- How to add update function to plugin without adding it to https://wordpress.org/plugins/ [closed]
- Plugin option default value
- How to edit link for comment count
- Integrating Custom Database with WordPress
- How to get the custom field value using SQL query
- specific rows style for in custom list table using WP_List_Table
- How to add the search page link to the anchor tag?
- Need to know if my approach to designing a geneaology plug-in for wordpress makes sense
- Creating one user access account for all the multiple sites
- Using id to show item
- return bbp_get_topic_author_id as integer
- I am Getting Sorry, no posts matched your criteria on form submit only for certain page [duplicate]
- wpdb update method is updating but not refreshing the current page data
- Shortcode and WP query using category attributes
- Dynamic input fields in WordPress Plugin
- Custom role not listed
- Better way to run heavy scripts using WordPress database
- how to check plugin name unique or not?
- WordPress Widget: Is it possible to make the form dynamic without updating?
- Change default url to plugin custom post type
- Creating a user ‘add custom field’ section
- WordPress ajax not working in registration
- How to show post attachment image
- Can a developer adopt a plugin marked as “not updated in over 2 years”?
- Making a Custom Post Type Publish Loop
- How wordpress plugin hooks works? [duplicate]
- Post curl function save twice using plugin hook function wordpress
- Adding a variable to a meta field in the backend?
- Someone Comment 1000 times in a Day in My WordPress Site, What Can i Do
- get_option returning a different value from what’s saved
- Plugin: Custom menu item problem
- Getting warning of Missing argument 2 for wpdb::prepare()
- Meta box not displaying on the plugin page
- public custom posts not showing in my wordpress plugin
- Allow manage_options capability for specific user only for specific plugin?