<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Sifency Addons – Admin Bar Menu
 */
add_action( 'admin_bar_menu', 'sifency_addons_admin_bar_menu', 100 );
function sifency_addons_admin_bar_menu( $wp_admin_bar ) {

	if ( ! current_user_can( 'manage_options' ) ) {
		return;
	}

	$wp_admin_bar->add_node(
		array(
			'id'    => 'sifency-addons',
			'title' => '<img src="' . esc_url( SIFENCY_ADDONS_URL . 'assets/images/logo.png' ) . '" 
			style="height:16px; width:auto; vertical-align:middle; margin-right:3px;" />
			<span>Sifency Addons</span>',
			'href'  => admin_url( 'admin.php?page=sifency-addons' ),
		)
	);

	$wp_admin_bar->add_node(
		array(
			'id'     => 'sifency-theme-builder',
			'parent' => 'sifency-addons',
			'title'  => 'Theme Builder',
			'href'   => admin_url( 'admin.php?page=sifency-theme-builder' ),
		)
	);

	$wp_admin_bar->add_node(
		array(
			'id'     => 'sifency-widgets',
			'parent' => 'sifency-addons',
			'title'  => 'Widgets',
			'href'   => admin_url( 'admin.php?page=sifency-addons-widgets' ),
		)
	);

	$wp_admin_bar->add_node(
		array(
			'id'     => 'sifency-reusable-templates',
			'parent' => 'sifency-addons',
			'title'  => 'Templates',
			'href'   => admin_url( 'admin.php?page=sifency-templates-shortcode' ),
		)
	);
	$wp_admin_bar->add_node(
		array(
			'id'     => 'sifency-settings',
			'parent' => 'sifency-addons',
			'title'  => 'Settings',
			'href'   => admin_url( 'admin.php?page=sifency-settings' ),
		)
	);
}
