<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>techNerdia - Web Development Tips &#187; statistics</title>
	<atom:link href="http://technerdia.com/tag/statistics/feed" rel="self" type="application/rss+xml" />
	<link>http://technerdia.com</link>
	<description>Web Development Tips, Tricks and Ideas</description>
	<lastBuildDate>Tue, 07 Feb 2012 13:43:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Adding a Link to the WordPress Dashboard Menu that opens an Internal or External Page. [Updated]</title>
		<link>http://technerdia.com/557_dashboard-link-in-wordpress.html</link>
		<comments>http://technerdia.com/557_dashboard-link-in-wordpress.html#comments</comments>
		<pubDate>Mon, 23 Jan 2012 09:20:16 +0000</pubDate>
		<dc:creator>tribalNerd</dc:creator>
				<category><![CDATA[Admin Area]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[layouts]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[wp]]></category>
		<guid isPermaLink="false">http://technerdia.com/?p=557</guid>
		<description><![CDATA[Easily add a Custom Link to your Dashboard Menu...<p><div style="clear:both;border:2px dashed #c00;text-align:left;font-weight:bold;font-size:16px;padding:8px 10px;margin:40px 10px;text-align:center;">Thanks For Reading <a href="http://technerdia.com/557_dashboard-link-in-wordpress.html">Adding a Link to the WordPress Dashboard Menu that opens an Internal or External Page. [Updated]</a></b> from <a href="http://technerdia.com/" target="_blank">techNerdia.com</a></div>
<p align="center">~ <b>Visit the New techNerdia.com today</b> ~</p></p>
]]></description>
			<content:encoded><![CDATA[<p><b>Updated</b>: <em>January 23, 2012</em> &#8211; This tip walks you through adding a Statistics link for Google Analytics within the WordPress Admin under the Dashboard tab.</p>
<p><b>Sources</b>:</p>
<ul>
<li><a href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGV4LndvcmRwcmVzcy5vcmcv" target=\"_blank\">The WordPress Codex</a></li>
<li><a href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGV4LndvcmRwcmVzcy5vcmcvQWRtaW5pc3RyYXRpb25fTWVudXM=" target=\"_blank\">Administration Menus</a></li>
</ul>
<h2>Adding a Link to the Dashboard of WordPress</h2>
<p>The example below is two functions. The second function (dashboardMenu) adds the link within the dashboard, then calls the first function (linkedPage).</p>
<h2>What To Do&#8230;</h2>
<ul>
<li>On Line 8 replace the <b>ENTER-YOUR-GOOGLE-ANALYTICS-URL-HERE</b> with your Google Analytics URL or any URL you wish to open.</li>
<li>On Line 10 replace YOUR-DOMAIN with your domain.</li>
</ul>
<br />
<div class="mycode"><pre class="brush: php; title: ; notranslate">
/* The Redirect Function */
function linkedPage(){
	if(!current_user_can('manage_options')){
		wp_die( __('You do not have sufficient permissions to access this page.'));
	}
?&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	window.open(&quot;ENTER-YOUR-GOOGLE-ANALYTICS-URL-HERE&quot;); /* Update This Line */
	function delay(){
		window.location.href = &quot;http://YOUR-DOMAIN.com/wp-admin/index.php&quot;; /* Update This Line */
	}
&lt;/script&gt;
&lt;body onLoad=&quot;setTimeout('delay()', 4000)&quot;&gt;
&lt;? } /* end function */
/* Add Dashboard Link */
function dashboardMenu(){
	if(function_exists('add_submenu_page'))
	add_submenu_page('index.php', __('Statistics'), __('Statistics'), 'manage_options', 'stats', 'linkedPage');
} /* end function */
add_action('admin_menu', 'dashboardMenu');
</pre></div>
<h2>How Does It Work?</h2>
<p>When the Statistics link is clicked in the dashboard, the linkedPage function is called. This sets two Javascripts in action, the first opens Google Analytics in a tab-less browser window. The second redirect waits a few seconds, then returns back to your WordPress Admin homepage.</p>
<h2>Adding Multiple Dashboard Links</h2>
<p>Duplicate the linkedPage function and rename it, and adjust the urls within the Javascript. Then in the dashboardMenu function, duplicate the <em>add_submenu_page</em> line, adjust the link name and finally replace the linkedPage function with the new function name.</p>
<br />
<div class="mycode"><pre class="brush: php; title: ; notranslate">
/* Multiple Redirects */
function secondFunctionName(){
	if(!current_user_can('manage_options')){
		wp_die( __('You do not have sufficient permissions to access this page.'));
	}
?&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	window.open(&quot;OUT-GOING-URL&quot;); /* Update This Line */
	function delay(){
		window.location.href = &quot;http://YOUR-DOMAIN.com/wp-admin/index.php&quot;; /* Update This Line */
	}
&lt;/script&gt;
&lt;body onLoad=&quot;setTimeout('delay()', 4000)&quot;&gt;
&lt;? } /* end function */
/* Add Dashboard Link */
function dashboardMenu(){
	if(function_exists('add_submenu_page'))
	add_submenu_page('index.php', __('Statistics'), __('Statistics'), 'manage_options', 'stats', 'linkedPage');
	add_submenu_page('index.php', __('New Link'), __('New Link'), 'manage_options', 'link', 'secondFunctionName');
} /* end function */
add_action('admin_menu', 'dashboardMenu');
</pre></div>
<h2>Opening an Internal Page</h2>
<p>Instead of redirecting to an outsideURL, you can open a page directly within the admin, then add all the links and goodies you like to that page.</p>
<p>The example below offers two methods for display HTML. The first is to include the html within the function &#8211; a much cleaner way of doing it, and the second is to display the html directly within the function.</p>
<br />
<div class="mycode"><pre class="brush: php; title: ; notranslate">
function linkedPage(){
	if(!current_user_can('manage_options')){
		wp_die( __('You do not have sufficient permissions to access this page.'));
	}
/* Method #1 - Include the HTML */
//include(&quot;full/path/to/file.php&quot;);
/* */
/* Method #2 - HTML within the Function */ ?&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;Bird is the Word&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;? }
function dashboardMenu(){
	if(function_exists('add_submenu_page'))
	add_submenu_page('index.php', __('My Page'), __('My Page'), 'manage_options', 'mypage', 'linkedPage');
}
add_action('admin_menu', 'dashboardMenu');
</pre></div>
<h3>Simple Enough!</h3>
<p>This can save you a bit of time and it can be twisted in many various ways. Add links to Feed Stats, Online Tools, Related Sites, Social Networks and whatever else you like.</p>
<hr />
<h4>Did this article help you? Did this article solve your problem? Have Feedback?</h4>
<p>Let me know in the <a href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=I2NvbW1lbnRz">comments</a> below or <a href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2huZXJkaWEuY29tL2ZlZWRiYWNr">drop me feedback directly</a>! Your input helps improve, expand, and create future articles, so speak up!</p>
<p>Enjoy your day ~tribalNerd</p><p><div style="clear:both;border:2px dashed #c00;text-align:left;font-weight:bold;font-size:16px;padding:8px 10px;margin:40px 10px;text-align:center;">Thanks For Reading <a href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2huZXJkaWEuY29tLzU1N19kYXNoYm9hcmQtbGluay1pbi13b3JkcHJlc3MuaHRtbA==">Adding a Link to the WordPress Dashboard Menu that opens an Internal or External Page. [Updated]</a></b> from <a href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2huZXJkaWEuY29tLw==" target=\"_blank\">techNerdia.com</a></div>
<p align="center">~ <b>Visit the New techNerdia.com today</b> ~</p></p>
 <img src="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=557" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://technerdia.com/557_dashboard-link-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

