function thirstyAdminOptions()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have suffifient permissions to access this page.', 'thirstyaffiliates'));
    }
    $thirstyOptions = get_option('thirstyOptions');
    $linksRebuilt = false;
    if ($thirstyOptions['rebuildlinks'] == 'true') {
        $thirstyOptions['rebuildlinks'] = 'false';
        update_option('thirstyOptions', $thirstyOptions);
        $thirstyOptions = get_option('thirstyOptions');
        thirstyResaveAllLinks();
        flush_rewrite_rules();
        $linksRebuilt = true;
    }
    // Sanity check on link prefix
    if (empty($thirstyOptions['linkprefix'])) {
        $thirstyOptions['linkprefix'] = 'recommends';
        update_option('thirstyOptions', $thirstyOptions);
    }
    $redirectTypes = thirstyGetRedirectTypes();
    // Sanity check on link redirect type
    if (empty($thirstyOptions['linkredirecttype'])) {
        $thirstyOptions['linkredirecttype'] = '301';
        update_option('thirstyOptions', $thirstyOptions);
    }
    $thirstyOptions['nofollow'] = isset($thirstyOptions['nofollow']) ? 'checked="checked"' : '';
    $thirstyOptions['newwindow'] = isset($thirstyOptions['newwindow']) ? 'checked="checked"' : '';
    $thirstyOptions['showcatinslug'] = isset($thirstyOptions['showcatinslug']) ? 'checked="checked"' : '';
    $thirstyOptions['disablecatautoselect'] = isset($thirstyOptions['disablecatautoselect']) ? 'checked="checked"' : '';
    $thirstyOptions['legacyuploader'] = isset($thirstyOptions['legacyuploader']) ? 'checked="checked"' : '';
    $thirstyOptions['disabletitleattribute'] = isset($thirstyOptions['disabletitleattribute']) ? 'checked="checked"' : '';
    $thirstyOptions['disablethirstylinkclass'] = isset($thirstyOptions['disablethirstylinkclass']) ? 'checked="checked"' : '';
    $thirstyOptions['disableslugshortening'] = isset($thirstyOptions['disableslugshortening']) ? 'checked="checked"' : '';
    $thirstyOptions['disablevisualeditorbuttons'] = isset($thirstyOptions['disablevisualeditorbuttons']) ? 'checked="checked"' : '';
    $thirstyOptions['disabletexteditorbuttons'] = isset($thirstyOptions['disabletexteditorbuttons']) ? 'checked="checked"' : '';
    echo '<script type="text/javascript">var thirstyPluginDir = "' . plugins_url('thirstyaffiliates/') . '";
	var thirstyJSEnable = true;
	</script>';
    echo '<div class="wrap">';
    echo '<img id="thirstylogo" src="' . plugins_url('thirstyaffiliates/images/thirstylogo.png') . '" alt="ThirstyAffiliates" />';
    echo '<form id="thirstySettingsForm" method="post" action="options.php">';
    wp_nonce_field('update-options');
    settings_fields('thirstyOptions');
    if (!empty($_GET['settings-updated'])) {
        echo '<div id="message" class="updated below-h2"><p>' . __('Settings updated.', 'thirstyaffiliates') . '</p>' . ($linksRebuilt ? '<p>' . __('Links rebuilt.', 'thirstyaffiliates') . '</p>' : '') . '</div>';
    }
    echo '
	<table class="thirstyTable form-table" cellspacing="0" cellpadding="0">

	<tr><td><h3 style="margin-top: 0;">' . __('General Settings', 'thirstyaffiliates') . '</h3></td></tr>

	<tr>
		<th>
			<label for="thirstyOptions[linkprefix]">' . __('Link Prefix:', 'thirstyaffiliates') . '</label>
		</th>
		<td>
			<select id="thirstyOptionsLinkPrefix" name="thirstyOptions[linkprefix]">
				<option value="' . __('custom', 'thirstyaffiliates') . '"' . (!empty($thirstyOptions['linkprefix']) && $thirstyOptions['linkprefix'] == __('custom', 'thirstyaffiliates') ? __(' selected', 'thirstyaffiliates') : '') . '>-- ' . __('Custom', 'thirstyaffiliates') . ' --</option>';
    thirstyGenerateSelectOptions(array("recommends", "link", "go", "review", "product", "suggests", "follow", "endorses", "proceed", "fly", "goto", "get", "find", "act", "click", "move", "offer", "run"), true);
    echo '</select><br />
			<input type="text" id="thirstyCustomLinkPrefix" value="' . (isset($thirstyOptions['linkprefixcustom']) ? $thirstyOptions['linkprefixcustom'] : '') . '" name="thirstyOptions[linkprefixcustom]" />';
    if (isset($thirstyOptions['linkprefix']) && $thirstyOptions['linkprefix'] == 'custom') {
        echo '<script type="text/javascript">
			jQuery("#thirstyCustomLinkPrefix").css("display", "block");
			jQuery("#thirstyCustomLinkPrefix").show();
			</script>';
    }
    echo '</td>
		<td>
			<span class="description">' . __('The prefix that comes before your cloaked link\'s slug.<br />eg. ', 'thirstyaffiliates') . trailingslashit(get_bloginfo('url')) . '<span style="font-weight: bold;">' . thirstyGetCurrentSlug() . '</span>/your-affiliate-link-name</span>
			<br /><span class="description"><b>' . __('Warning:', 'thirstyaffiliates') . '</b> ' . __('Changing this setting after you\'ve used links in a post could break those links. Be careful!', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[showcatinslug]">' . __('Show Link Category in URL?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[showcatinslug]" id="thirstyOptionsShowCatInSlug" ' . $thirstyOptions['showcatinslug'] . ' />
		</td>
		<td>
			<span class="description">' . __('Show the selected category in the url. eg. ', 'thirstyaffiliates') . trailingslashit(get_bloginfo('url')) . '' . thirstyGetCurrentSlug() . '/<span style="font-weight: bold;">link-category</span>/your-affiliate-link-name</span></span>
			<br /><span class="description"><b>' . __('Warning:', 'thirstyaffiliates') . '</b> ' . __('Changing this setting after you\'ve used links in a post could break those links. Be careful!', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[disablecatautoselect]">' . __('Disable "uncategorized" category on save?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[disablecatautoselect]" id="thirstyOptionsDisableCatAutoSelect" ' . $thirstyOptions['disablecatautoselect'] . ' />
		</td>
		<td>
			<span class="description">' . __('If the "Show the selected category in the url" option above is selected, by default ThirstyAffiliates will add an "uncategorized" category to apply to non-categorised links during save. If you disable this, it allows you to have some links with categories in the URL and some without.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[linkredirecttype]">' . __('Link Redirect Type:', 'thirstyaffiliates') . '</label>
		<td>';
    foreach ($redirectTypes as $redirectTypeCode => $redirectTypeDesc) {
        $linkTypeSelected = false;
        if (strcasecmp($thirstyOptions['linkredirecttype'], $redirectTypeCode) == 0) {
            $linkTypeSelected = true;
        }
        echo '<input type="radio" name="thirstyOptions[linkredirecttype]" id="thirstyOptionsLinkRedirectType' . $redirectTypeCode . '" ' . ($linkTypeSelected ? 'checked="checked" ' : '') . 'value="' . $redirectTypeCode . '" /> <label for="thirstyOptionsLinkRedirectType' . $redirectTypeCode . '">' . $redirectTypeDesc . '</label><br />';
    }
    echo '
		</td>
		<td>
			<span class="description">' . __('This is the type of redirect ThirstyAffiliates will use to redirect the user to your affiliate link.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[nofollow]">' . __('Use no follow on links?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[nofollow]" id="thirstyOptionsNofollow" ' . $thirstyOptions['nofollow'] . ' />
		</td>
		<td>
			<span class="description">' . __('Add the nofollow attribute to links so search engines don\'t index them', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[newwindow]">' . __('Open links in new window?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[newwindow]" id="thirstyOptionsNewwindow" ' . $thirstyOptions['newwindow'] . ' />
		</td>
		<td>
			<span class="description">' . __('Force the user to open links in a new window or tab', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[legacyuploader]">' . __('Revert to legacy image uploader?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[legacyuploader]" id="thirstyOptionsLegacyUploader" ' . $thirstyOptions['legacyuploader'] . ' />
		</td>
		<td>
			<span class="description">' . __('Disable the new media uploader in favour of the old style uploader', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[disabletitleattribute]">' . __('Disable title attribute output on link insertion?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[disabletitleattribute]" id="thirstyOptionsDisableTitleAttribute" ' . $thirstyOptions['disabletitleattribute'] . ' />
		</td>
		<td>
			<span class="description">' . __('Links are automatically output with a title html attribute (by default this shows the text
			that you have linked), this option lets you disable the output of the title attribute on your links.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[disablethirstylinkclass]">' . __('Disable automatic output of ThirstyAffiliates CSS classes?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[disablethirstylinkclass]" id="thirstyOptionsDisableThirstylinkClass" ' . $thirstyOptions['disablethirstylinkclass'] . ' />
		</td>
		<td>
			<span class="description">' . __('To help with styling your affiliate links a CSS class called "thirstylink" is added
			to the link and a CSS class called "thirstylinkimg" is added to images (when inserting image affiliate links),
			this option disables the addition of both of these CSS classes.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[disableslugshortening]">' . __('Disable slug shortening?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[disableslugshortening]" id="thirstyOptionsDisableSlugShortening" ' . $thirstyOptions['disableslugshortening'] . ' />
		</td>
		<td>
			<span class="description">' . __('By default, ThirstyAffiliates removes superfluous words from your cloaked link URLs, this option turns that feature off.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[disablevisualeditorbuttons]">' . __('Disable buttons on the Visual editor?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[disablevisualeditorbuttons]" id="thirstyOptionsDisableVisualEditorButtons" ' . $thirstyOptions['disablevisualeditorbuttons'] . ' />
		</td>
		<td>
			<span class="description">' . __('Hide the ThirstyAffiliates buttons on the Visual editor.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[disabletexteditorbuttons]">' . __('Disable buttons on the Text/Quicktags editor?', 'thirstyaffiliates') . '</label>
		<td>
			<input type="checkbox" name="thirstyOptions[disabletexteditorbuttons]" id="thirstyOptionsDisableTextEditorButtons" ' . $thirstyOptions['disabletexteditorbuttons'] . ' />
		</td>
		<td>
			<span class="description">' . __('Hide the ThirstyAffiliates buttons on the Text editor.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>

	<tr>
		<th>
			<label for="thirstyOptions[additionalreltags]">' . __('Additional rel attribute tags to add during link insertion: ', 'thirstyaffiliates') . '</label>
		<td>
			<input type="text" name="thirstyOptions[additionalreltags]" id="thirstyOptionsAdditionalRelTags" value="' . $thirstyOptions['additionalreltags'] . '" />
		</td>
		<td>
			<span class="description">' . __('Allows you to add extra tags into the rel= attribute when links are inserted.', 'thirstyaffiliates') . '</span>
		</td>
	</tr>';
    do_action('thirstyAffiliatesAfterMainSettings');
    echo '
	</table>

	<input type="hidden" name="thirstyOptions[rebuildlinks]" id="thirstyHiddenRebuildFlag" value="false" />

	<input type="hidden" name="page_options" value="thirstyOptions" />

	<p class="submit">
	<input type="submit" class="button-primary" value="' . __('Save All Changes', 'thirstyaffiliates') . '" />
	<input type="submit" id="thirstyForceLinkRebuild" class="button-secondary" value="' . __('Save & Force Link Rebuild') . '" />
	</p>

	</form>

	<div class="thirstyWhiteBox">

		<h3>' . __('Plugin Information', 'thirstyaffiliates') . '</h3>' . 'ThirstyAffiliates Version: ' . THIRSTY_VERSION . '<br />';
    do_action('thirstyAffiliatesPluginInformation');
    echo '</div><!-- /.thirstyWhiteBox -->';
    do_action('thirstyAffiliatesAfterPluginInformation');
    echo '
		<div class="thirstyWhiteBox">
			<h3>Join The Community</h3>
			<ul id="thirstyCommunityLinks"><li><a href="http://thirstyaffiliates.com">' . __('Visit Our Website', 'thirstyaffiliates') . '</a></li>
				<li><a href="' . admin_url('edit.php?post_type=thirstylink&page=thirsty-addons') . '">' . __('Browse ThirstyAffiliates Add-ons', 'thirstyaffiliates') . '</a></li>
				<li><a href="http://thirstyaffiliates.com/affiliates">' . __('Join Our Affiliate Program', 'thirstyaffiliates') . '</a> ' . __('(up to 50% commissions)', 'thirstyaffiliates') . '</li>
				<li><a href="http://facebook.com/thirstyaffiliates" style="margin-right: 10px;">' . __('Like us on Facebook', 'thirstyaffiliates') . '</a><iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Fthirstyaffiliates&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;font=arial&amp;colorscheme=light&amp;action=like&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px; vertical-align: bottom;" allowTransparency="true"></iframe></li>
				<li><a href="http://twitter.com/thirstyaff" style="margin-right: 10px;">' . __('Follow us on Twitter', 'thirstyaffiliates') . '</a> <a href="https://twitter.com/thirstyaff" class="twitter-follow-button" data-show-count="true" style="vertical-align: bottom;">Follow @thirstyaff</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script></li>
			</ul>
		</div><!-- /.thirstyWhiteBox -->

	</div><!-- /.wrap -->';
    // Provide debug output for diagnostics and support use
    if (isset($_GET['debug'])) {
        if ($_GET['debug'] == 'true') {
            $thirstyOptions = get_option('thirstyOptions');
            // re-retrieve options in case any of the filters/actions messed with it
            echo '<pre>' . __('DEBUG: ', 'thirstyaffiliates') . print_r($thirstyOptions, true) . '</pre>';
        }
    }
}
function thirstyGetQuickAddLinkThickboxContent()
{
    ?>
	<html>
		<head>
			<?php 
    wp_enqueue_script('editor');
    wp_dequeue_script('jquery-ui-sortable');
    wp_dequeue_script('admin-scripts');
    do_action('admin_print_styles');
    do_action('admin_print_scripts');
    do_action('admin_head');
    ?>
			<style>
				body {
					font: 14px/16px sans-serif;
					background: #fff;
				}

				#heading_title {
					display: block;
					margin: 10px auto 0px auto;
				}

				#quick-add-link-container {
					padding: 1em 3em;
				}

				#error-bulletin {
					padding: .4em .8em;
					border: 1px solid #BB0E19 !important;
					background-color: #FFEFF0;
					font-size: 1em;
					/*font-family: arial, sans-serif;*/
					font-family: 'Open Sans', sans-serif;
					margin: 1em 0;
					color: #BB0E19;
					display: none;
					border-radius: 3px;
				}

				#quick-add-link-form {
					display: block;
				}

				.field_row {
					padding: .2em;
					margin-bottom: 1em;
				}
				.field_row label,
				.field_row .desc {
					display: block;
					font-size: 14px;
					color: #444444;
					/*font-family: arial, sans-serif;*/
					font-family: 'Open Sans', sans-serif;
					margin-bottom: .4em;
					font-weight: normal;
				}
				.field_row .errmsg {
					display: none;
					color: red;
					font-size: 12px;
					font-weight: bold;
					/*font-family: arial, sans-serif;*/
					font-family: 'Open Sans', sans-serif;
					margin-bottom: .4em;
				}
				.field_row .desc {
					font-size: 12px;
					font-style: italic;
				}
				.field_row input[type="text"] {
					display: block;
					width: 100%;
					border: 1px solid #DDD;
					padding: 5px;
					margin-bottom: .4em;
					height: 31px;
					font-size: 14px;
					box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
					background-color: #fff;
					color: #333;
				}
				.field_row select {
					padding: 2px;
					line-height: 28px;
					height: 28px;
					vertical-align: middle;
					border-color: #ddd;
					box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
					background-color: #fff;
					color: #333;
					font-size: 14px;
				}
				.field_row select option {
					font-weight: normal;
					font: inherit;
					line-height: 28px;
				}
				.field_row .err {
					border: 1px solid #BB0E19 !important;
					background-color: #FFEFF0;
				}
				.field_row .option label {
					cursor: pointer;
				}
				.field_row .button-primary {
					margin-top: 8px;
					margin-bottom: 5px;
					background: #2ea2cc;
					border-color: #0074a2;
					-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);
					box-shadow: inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);
					color: #fff;
					text-decoration: none;
				}
				.field_row .button-primary:hover {
					background: #1e8cbe;
					-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,.6);
					box-shadow: inset 0 1px 0 rgba(120,200,230,.6);
				}
				.field_row .button_secondary {
					color: #555;
					border-color: #ccc;
					background: #f7f7f7;
					-webkit-box-shadow: inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,.08);
					box-shadow: inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,.08);
					vertical-align: top;
				}
				.field_row .button_secondary:hover {
					background: #fafafa;
					border-color: #999;
					color: #222;
				}
				.field_row .button {
					display: inline-block;
					line-height: 26px;
					height: 28px;
					margin: 0;
					padding: 0 10px 1px;
					cursor: pointer;
					border-width: 1px;
					border-style: solid;
					-webkit-border-radius: 3px;
					-webkit-appearance: none;
					border-radius: 3px;
					white-space: nowrap;
					box-sizing: border-box;
					margin-left: 5px;
					font-size: 14px;
					font-family: Arial, sans-serif;
				}
				.field_row.button-container {
					text-align: right;
				}
			</style>
		</head>
		<body>
			<div id="quick-add-link-container">

				<?php 
    // Create Nonce
    wp_nonce_field(plugin_basename(__FILE__), 'quick_add_aff_link_nonce');
    // Get Global Options
    $thirstyOptions = get_option('thirstyOptions');
    ?>

				<img id="heading_title" src="<?php 
    echo plugins_url('thirstyaffiliates/');
    ?>
images/thirstylogo.png" alt="<?php 
    _e('Affiliate Link Picker', 'thirstyaffiliates');
    ?>
" />

				<div id="error-bulletin"></div>

				<div id="quick-add-link-form">

					<div class="field_row">
						<label for="qal_link_name"><?php 
    _e('Link Name:', 'thirstyaffiliates');
    ?>
</label>
						<input type="text" name="qal_link_name" id="qal_link_name">
						<div class="errmsg"></div>
					</div>

					<div class="field_row">
						<label for="qal_destination_url"><?php 
    _e('Destination URL:', 'thirstyaffiliates');
    ?>
</label>
						<div class="desc"><?php 
    _e('http:// or https:// is required', 'thirstyaffiliates');
    ?>
</div>
						<input type="text" name="qal_destination_url" id="qal_destination_url">
						<div class="errmsg"></div>

						<?php 
    /* Only display link nofollow setting if the global nofollow setting is disabled */
    if ($thirstyOptions['nofollow'] != 'on') {
        ?>
								<div class="option"><label for="qal_no_follow_link"><input type="checkbox" name="qal_no_follow_link" value="on" id="qal_no_follow_link"><?php 
        _e('No follow this link?', 'thirstyaffiliates');
        ?>
</label></div>
								<?php 
    }
    /* Only display link new window setting if the global new window setting is disabled */
    if ($thirstyOptions['newwindow'] != 'on') {
        ?>
								<div class="option"><label for="qal_new_window"><input type="checkbox" name="qal_new_window" value="on" id="qal_new_window"><?php 
        _e('Open this link in new window?', 'thirstyaffiliates');
        ?>
</label></div>
								<?php 
    }
    ?>
					</div>

					<div class="field_row">
						<label><?php 
    _e('Redirect Type', 'thirstyaffiliates');
    ?>
</label>
						<span class="desc"><?php 
    _e('Override the default redirection type for this link:', 'thirstyaffiliates');
    ?>
</span>
						<?php 
    foreach (thirstyGetRedirectTypes() as $key => $value) {
        ?>
								<div class="option">
									<label>
										<input type="radio" name="qal_redirect_type" value="<?php 
        echo $key;
        ?>
" <?php 
        echo strcasecmp($key, $thirstyOptions['linkredirecttype']) == 0 ? "checked" : "";
        ?>
>
										<?php 
        echo $value;
        ?>
										<?php 
        echo strcasecmp($key, $thirstyOptions['linkredirecttype']) == 0 ? __(" (Default)") : "";
        ?>
									</label>
								</div>
								<?php 
    }
    ?>
					</div>

					<?php 
    /* If we are using categories in slugs force user to select a category */
    if (!empty($thirstyOptions['showcatinslug']) && $thirstyOptions['showcatinslug'] == 'on') {
        $selectedLinkCats = wp_get_post_terms($post_id, 'thirstylink-category');
        if (empty($selectedLinkCats)) {
            $defaultCat = 'Uncategorized';
            // create the default term if it doesn't exist
            if (!term_exists($defaultCat, 'thirstylink-category')) {
                wp_insert_term($defaultCat, 'thirstylink-category');
            }
            // get the default term and set this post to have it
            $defaultTerm = get_term_by('name', $defaultCat, 'thirstylink-category');
            wp_set_post_terms($post_id, $defaultTerm->term_id, 'thirstylink-category');
        }
    }
    ?>

					<?php 
    /* Only show category when the show category in slug setting is turned on */
    if (strcasecmp($thirstyOptions['showcatinslug'], "on") == 0) {
        // Retrieve all link categories
        $link_categories = get_terms("thirstylink-category", array('hide_empty' => false));
        if (count($link_categories) > 0) {
            // If no category term is present, create one, coz we really need this for the plugin to work properly
            if (!term_exists('Uncategorized', 'thirstylink-category')) {
                wp_insert_term('Uncategorized', 'thirstylink-category');
            }
            // Ok, Retrieve again all link categories
            $link_categories = get_terms("thirstylink-category", array('hide_empty' => false));
        }
        // Only show combo box if there are indeed link categories
        if (count($link_categories) > 0) {
            ?>
								<div class="field_row">
									<label for=""><?php 
            _e('Link Categories', 'thirstyaffiliates');
            ?>
</label>
									<span class="desc"><?php 
            _e('You must select a link category as you set the general setting to include category on the link', 'thirstyaffiliates');
            ?>
</span>
									<select name="qal_link_categories" id="qal_link_categories" style="width: 300px;" data-placeholder="<?php 
            _e('Select categories...', 'thirstyaffiliates');
            ?>
" multiple>
									<?php 
            foreach (get_terms("thirstylink-category", array('hide_empty' => false)) as $link_category) {
                ?>
											<option value="<?php 
                echo $link_category->term_id;
                ?>
"><?php 
                $link_category->name;
                ?>
</option>
											<?php 
            }
            ?>
									</select>
								</div>
								<?php 
        }
    }
    ?>

					<div class="field_row button-container">
						<input type="button" id="add-link" class="button button_secondary" value="<?php 
    _e('Add Link', 'thirstyaffiliates');
    ?>
">
						<input type="button" id="quick-add-link" class="button button-primary" value="<?php 
    _e('Add Link &amp; Insert Into Post', 'thirstyaffiliates');
    ?>
">
					</div>

				</div><!-- quick-add-link-form -->
			</div><!-- quick-add-link-container -->


		<?php 
    echo '<script type="text/javascript">var thirstyPluginDir = "' . plugins_url('thirstyaffiliates/') . '";
			var thirstyMCE;</script>';
    ?>

		<link rel="stylesheet" href="<?php 
    echo plugins_url('thirstyaffiliates/');
    ?>
js/lib/chosen/chosen.min.css"/>
		<script type="text/javascript" src="<?php 
    echo plugins_url('thirstyaffiliates/');
    ?>
js/lib/chosen/chosen.jquery.min.js"></script>

		<script type="text/javascript" src="<?php 
    echo plugins_url('thirstyaffiliates/');
    ?>
js/ThirstyQuickAddLinkPicker.js"></script>

		<script type="text/javascript">
			jQuery(document).ready(function($){

				$("#qal_link_categories").chosen();

			});
		</script>
		</body>
	</html>

	<?php 
    die;
}