{"id":158,"date":"2008-03-19T01:46:58","date_gmt":"2008-03-18T17:46:58","guid":{"rendered":"http:\/\/lesterchan.net\/wordpress\/?p=158"},"modified":"2012-09-03T22:45:42","modified_gmt":"2012-09-03T14:45:42","slug":"dashboard-widget-without-controls-sample-plugin","status":"publish","type":"post","link":"https:\/\/lesterchan.net\/wordpress\/2008\/03\/19\/dashboard-widget-without-controls-sample-plugin\/","title":{"rendered":"Dashboard Widget (Without Controls) Sample Plugin"},"content":{"rendered":"<p>WordPress 2.5 has the ability to customize your administration dashboard with the help of widgets.<\/p>\n<p>After poking around WordPress 2.5 codes, I have come out with this Dashboard Widget Sample Plugin. BUT do note that this plugin does not include Dashboard Widget Controls. If I have the time, I will add that in or perhaps I will create another plugin called &#8220;Dashboard Widget (With Controls) Sample Plugin&#8221;.<\/p>\n<p>To get a clearer picture of what this sample plugin does, here is a <a href=\"http:\/\/files.lesterchan.net\/viewing\/screenshots\/dashboard_widget_sample.png\/\">screenshot of the Dashboard Widget (Without Controls) Sample<\/a> in action.<\/p>\n<p>Here comes the code:<\/p>\n<pre lang=\"php\" line=\"1\">\r\n<?php\r\n\/*\r\nPlugin Name: Dashboard Widget (Without Controls) Sample\r\nPlugin URI: https:\/\/lesterchan.net\r\nDescription: A sample on how to add widgets on your dashboard easily.\r\nVersion: 0.01\r\nAuthor: Lester 'GaMerZ' Chan\r\nAuthor URI: https:\/\/lesterchan.net\r\n*\/\r\n\r\n\/*\r\n\r\nReplace all instances of PLUGINNAME with your nice plugin name something like \"polls\" or \"ratings (without the quotes)\r\n\r\n*\/\r\n\r\n### Function: Register Dashboard Widget\r\nadd_action('wp_dashboard_setup', 'PLUGINNAME_register_dashboard_widget');\r\nfunction PLUGINNAME_register_dashboard_widget() {\r\n\twp_register_sidebar_widget('dashboard_PLUGINNAME', __('Sample Dashboard Widget', 'PLUGINNAME'), 'dashboard_PLUGINNAME',\r\n\t\tarray(\r\n\t\t'all_link' => 'Full URL For \"See All\" link', \/\/ Example: 'index.php?page=wp-useronline\/wp-useronline.php'\r\n\t\t'feed_link' => 'Full URL For \"RSS\" link', \/\/ Example: 'index.php?page=wp-useronline\/wp-useronline-rss.php'\r\n\t\t'width' => 'half', \/\/ OR 'fourth', 'third', 'half', 'full' (Default: 'half')\r\n\t\t'height' => 'single', \/\/ OR 'single', 'double' (Default: 'single')\r\n\t\t)\r\n\t);\r\n}\r\n\r\n### Function: Add Dashboard Widget\r\nadd_filter('wp_dashboard_widgets', 'PLUGINNAME_add_dashboard_widget');\r\nfunction PLUGINNAME_add_dashboard_widget($widgets) {\r\n\tglobal $wp_registered_widgets;\r\n\tif (!isset($wp_registered_widgets['dashboard_PLUGINNAME'])) {\r\n\t\treturn $widgets;\r\n\t}\r\n\tarray_splice($widgets, sizeof($widgets)-1, 0, 'dashboard_PLUGINNAME');\r\n\treturn $widgets;\r\n}\r\n\r\n### Function: Print Dashboard Widget\r\nfunction dashboard_PLUGINNAME($sidebar_args) {\r\n\tglobal $wpdb;\r\n\textract($sidebar_args, EXTR_SKIP);\r\n\techo $before_widget;\r\n\techo $before_title;\r\n\techo $widget_name;\r\n\techo $after_title;\r\n\techo 'YOUR CONTENT GOES IN HERE';\r\n\techo $after_widget;\r\n}\r\n?>\r\n<\/pre>\n<p>Hope this helps some of you guys. =)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress 2.5 has the ability to customize your administration dashboard with the help of widgets. After poking around WordPress 2.5 codes, I have come out with this Dashboard Widget Sample Plugin. BUT do note that this plugin does not include Dashboard Widget Controls. If I have the time, I will add that in or perhaps &hellip; <a href=\"https:\/\/lesterchan.net\/wordpress\/2008\/03\/19\/dashboard-widget-without-controls-sample-plugin\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Dashboard Widget (Without Controls) Sample Plugin&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[60,66,68,67],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-sample-plugins","tag-60","tag-dashboard","tag-sample","tag-widget"],"views":12956,"_links":{"self":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":0,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"wp:attachment":[{"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lesterchan.net\/wordpress\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}