It seems the problem was not the timing of when it is inserted but the style of the div tag. Since the purpose of this is to create a minimum width in the admin panel, the border:0px
does not create a solid element. Therefore, the browser seems to ignore it.
Inserting this worked.
<div id="min-width" style="width:1000px; height:0px; border:1px; border-style:solid; border-color: rgba(0,0,0,0);"></div>
This is the sample plugin which demonstrates how to do it.
<?php
/* Plugin Name: Sample Embed Image for Admin Page Width */
add_action('plugins_loaded', create_function('',
'$o = new AdminPageClass_EmbedImage("Sample Embed Image in Admin Panel"
, "Sample Embed Image in Admin Panel"
, "manage_options"
, "sample_embed_image_in_admin_panel");
'));
class AdminPageClass_EmbedImage {
function __construct($title, $menuname, $privilege, $pageslug) {
$this->title = $title;
$this->menuname = $menuname;
$this->privilege = $privilege;
$this->pageslug = $pageslug;
add_action('admin_menu', array(&$this, 'admin_menu'));
add_action('wp_before_admin_bar_render', array(&$this, 'embed_image')); // inserts it between #wpcontent and #wpadminbar
// add_action('in_admin_header', array(&$this, 'embed_image')); // inserts it between #wpadminbar and #wp-body which is after #wpcontent
// add_action('network_admin_notices', array(&$this, 'embed_image')); // no insertion
// add_action('user_admin_notices', array(&$this, 'embed_image')); // no insertion
// add_action('admin_notices', array(&$this, 'embed_image')); // inserts it after #screen-meta inside #wpbody-content which is inside #wp-content
// add_action('all_admin_notices', array(&$this, 'embed_image')); // same as 'admin_notices'
}
function admin_menu() {
add_options_page($this->title, $this->menuname, $this->privilege, $this->pageslug, array(&$this, 'admin_page'));
}
function embed_image() {
?>
<div id="min-width" style="width:1000px; height:0px; border:1px; border-style:solid; border-color: rgba(0,0,0,0);"></div>
<?
}
function admin_page() {
// $this->embed_image();
?>
<div class="wrap">
<h1>Hi there</h1>
<?php // $this->embed_image(); ?>
<p>Hello World!</p>
</div>
<?php
}
}