First of all, these are the configuration form of the plugin after and before applying the trick.

Log Rotation configuration form after applying the trick

log rotation config form after applying the trick

Log Rotation configuration form after applying the trick

log rotation config form before the trick

The trick is to use the Note standard form field of Joomla! to include the trigger ajax header and button.

If you don't know what is the use of the Note field, this is the definition on the official Joomla documentation page:

This form field makes it possible to create titles, texts, descriptions and even alert boxes. It also allows you to bring order in the settings for extensions, by separating them with useful titles. Or adding descriptions for certain settings (without having to rely on the tooltips). Or adding any other text you want.

So I found that it is possible to add HTML text in the description attribute of the Note form field, but plain HTML text will break the plugin form, so I encoded the HTML text and inserted it, and it works!

Oh! this is so powerful!

I can insert anchor, button, div and SCRIPT elements. awesome! :)

I used this online HTML encoder to encode the description:

<a href="#" class="btn btn-secondary" >Click Me!</a><div id="ajax_result"></div><script src="/plugins/system/myplugin/assets/js/ajax.js"></script>

So the field definition in the logrotation.xml file will be:

<field
name="trigger_ajax"
type="note"
label="Trigger Ajax Request"
description="&lt;a href=&quot;#&quot; class=&quot;btn btn-secondary&quot; &gt;Click Me!&lt;/a&gt;&lt;div id=&quot;ajax_result&quot;&gt;&lt;/div&gt;&lt;script src=&quot;/plugins/system/myplugin/assets/js/ajax.js&quot;&gt;&lt;/script&gt;"
/>

Save and preview the plugin configuration form to see the magic!

Give it a try and let me know what other ideas you think to implement using this trick.