'
. ''
. ''
. ''
. '';
// phpcs:enable Generic.Files.LineLength.TooLong
// phpcs:enable PSR12.Properties.ConstantVisibility.NotFound
/**
* admin_bar_menu fires on template_redirect, too late to gate at hook time.
*
* @return void
*/
public static function initAdminBar()
{
// Core's wp-logo node is priority 10, and QuickEdit's toggle rides at 5.
\add_action('admin_bar_menu', [self::class, 'addAgentButton'], 4);
}
/**
* @param \WP_Admin_Bar $bar - The bar being built.
*
* @return void
*/
public static function addAgentButton($bar)
{
if (!self::shouldRender() || !\is_user_logged_in()) {
return;
}
// buttons.js renders into this same node, so it must not move.
$bar->add_node([
'id' => 'extendify-agent-btn',
'title' => '',
'meta' => ['class' => 'extendify-agent'],
]);
}
/**
* @return bool
*/
protected static function shouldRender()
{
return \wp_is_block_theme()
&& !\is_customize_preview()
&& Admin::agentPosition() === 'docked-left';
}
/**
* @return void
*/
public static function init()
{
// agentPosition needs the query, which the constructor is too early for.
\add_action('wp_head', [self::class, 'printStyles'], 20);
\add_action('wp_body_open', [self::class, 'printRail'], 1);
self::initAdminBar();
}
/**
* @return void
*/
public static function printStyles()
{
if (!self::shouldRender()) {
return;
}
// phpcs:disable Generic.Files.LineLength.TooLong -- CSS template
?>
'extendify-agent-skeleton-gate']);
}
/**
* @return void
*/
public static function printRail()
{
if (!self::shouldRender()) {
return;
}
// phpcs:disable Generic.Files.LineLength.TooLong -- class strings copied verbatim
?>