<?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; layouts</title> <atom:link href="http://technerdia.com/tag/layouts/feed" rel="self" type="application/rss+xml" /><link>http://technerdia.com</link> <description>Web Development Tips, Tricks and Ideas</description> <lastBuildDate>Mon, 07 May 2012 16:46:34 +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="border-top:1px dotted #cccccc;clear:both;font-size:14px;font-weight:bold;margin:2px 10px;padding:0 10px;text-align:left;"><ul><li><b>New Wordpress Plugin</b> <a
href="http://technerdia.com/projects/adminbar/plugin.html" target="_blank">WP My Admin Bar</a> (It's Free, Download Today!)</li><li><b>Reading:</b> <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>By:</b> <a
href="https://plus.google.com/105408082571454010152/" target="_blank">tribalNerd</a> <b>From:</b> <a
href="http://technerdia.com/" target="_blank">techNerdia - Web Development Tips</a></li><li><b><a
href="https://plus.google.com/u/0/108046225913965315594/posts" target="_blank">Follow techNerdia on Google+</a></li></ul></div><p
align="center">~ <b>Thank you for subscribing to techNerdia.com - Please Share This Post With Others</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. Then how to add multiple links to the Dashboard menu and finally how to open an internal page from the Dashboard menu.</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 name="code" class="php">
/* 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 name="code" class="php">
/* 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 name="code" class="php">
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>Enjoy this article? Find an error or would you like to expand on it?</h4><p>Shoot me some <a
href="http://technerdia.com/feedback.html" target="_blank">feedback</a> then, I'm always willing to listen, take advice, and improve what is on techNerdia!</p><br
/><p><div
style="border-top:1px dotted #cccccc;clear:both;font-size:14px;font-weight:bold;margin:2px 10px;padding:0 10px;text-align:left;"><ul><li><b>New WordPress Plugin</b> <a
href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2huZXJkaWEuY29tL3Byb2plY3RzL2FkbWluYmFyL3BsdWdpbi5odG1s" target=\"_blank\">WP My Admin Bar</a> (It's Free, Download Today!)</li><li><b>Reading:</b> <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>By:</b> <a
href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly9wbHVzLmdvb2dsZS5jb20vMTA1NDA4MDgyNTcxNDU0MDEwMTUyLw==" target=\"_blank\">tribalNerd</a> <b>From:</b> <a
href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2huZXJkaWEuY29tLw==" target=\"_blank\">techNerdia - Web Development Tips</a></li><li><b><a
href="http://technerdia.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly9wbHVzLmdvb2dsZS5jb20vdS8wLzEwODA0NjIyNTkxMzk2NTMxNTU5NC9wb3N0cw==" target=\"_blank\">Follow techNerdia on Google+</a></li></ul></div><p
align="center">~ <b>Thank you for subscribing to techNerdia.com - Please Share This Post With Others</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>
