admin管理员组文章数量:1122832
I am learning WordPress Plugin Development. I have below HTML in a Admin Panel Page.
<form method="post" action="options.php">
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row">My Text</th>
<td></td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
</p>
</form>
How can I select My Text uniquely so that other Admin Panel pages will not affected ?
I am learning WordPress Plugin Development. I have below HTML in a Admin Panel Page.
<form method="post" action="options.php">
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row">My Text</th>
<td></td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
</p>
</form>
How can I select My Text uniquely so that other Admin Panel pages will not affected ?
Share Improve this question asked Jul 29, 2024 at 10:36 FoysalFoysal 4451 gold badge5 silver badges15 bronze badges1 Answer
Reset to default 2Start by creating a stylesheet for your plugin.Then you can use the do_action('admin_enqueue_scripts')
to enqueue it in the controlpanel only, avoiding it to be loaded in the frontend.
You could do something like this:
function my_plugin_admin_styles() {
wp_enqueue_style('my-plugin-admin-style', plugin_dir_url(__FILE__) . 'assets/css/admin-style.css', array(), '1.0.0', 'all');
}
add_action('admin_enqueue_scripts', 'my_plugin_admin_styles');
Just make sure to correct the path for your stylesheet. In the code above, it's assumed the stylesheet is in an "assets" folder - and in a "css" folder within the assets-folder. Also, I would highly recommend to rename the function name - and the style ID "my-plugin-admin-style" to something more fitting for your plugin.
Then you can add the classes to your optionspage, and style them in the stylesheet without messing anything else up - as long as the classes are unique.
本文标签: plugin developmentSelect a Text for CSS
版权声明:本文标题:plugin development - Select a Text for CSS 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299519a1930484.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论