Settings API – format container of setting and setting’s description

It doesn’t seem possible to modify the <tr> tag, but for making it hidden by default (or initially hidden), then you can use the sixth parameter passed to add_settings_field(), which is $args: add_settings_field( ‘my_field’, // ID ‘My Field’, // Title ‘my_field_callback’, // Callback ‘my-setting-admin’, // Page/slug ‘setting_section_id’, // Section array( ‘class’ => ‘hidden’ ) ); … Read more

WordPress Environment: Dynamic Page using shortcode – how to change the page name for sharing

So depending on your theme, you’ll need to take a different approach. By the sounds of it, you’re using a theme that adds WordPress theme support for title-tag e.g. twentynineteen. In this case, your code would look like this: function add_dynamic_title( $aTitleParts ) { if ( isset( $aTitleParts[ ‘title’ ] ) && $aTitleParts[ ‘title’ ] … Read more

Download button in a plugin’s settings page

I managed to get the behaviour I was looking for with the following code : add_action(‘admin_menu’, ‘my_plugin_menu’); function my_plugin_menu() { add_menu_page(‘Plugin management’, ‘Plugin management’, ‘manage_options’, ‘my_plugin-plugin-settings’, ‘my_plugin_settings_page’, ‘dashicons-admin-generic’); } function my_plugin_settings_page() { if ( !current_user_can( ‘manage_options’ ) ) { wp_die( __( ‘You do not have sufficient permissions to access this page.’ ) ); } ?> … Read more

WordPress Plugin Activate / Deactive Failing

So the ‘activate_plugin’ was a typo in the question. But even so, as a friendly reminder (for all of us), activate_plugin() is an existing function in WordPress. And you should use unique prefix in your custom functions (that are defined in the global scope): function my_plugin_activate_plugin() { … } register_activation_hook( __FILE__, ‘my_plugin_activate_plugin’ ); The Problem … Read more