Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: DakWP
- Plugin URI: http://reena.in/DakWP
- Description: This is the Main(Master) plugin by Dak, containing all the functions, Dak is going to offer. Here you can use <A HREF="http://mukeshdak.com">Links</A> and <strong>Bold</strong> and code like <code>echo "Hello Testing"; </code> etc.
- Version: v9.12.27
- Author: Mukesh Dak
- Author URI: http://mukeshdak.com
- Copyright 2009 Mukesh Dak (email : [email protected])
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- ====
- HELP
- ====
- For Help See Menu DakWP in Dashboard
- ======
- README
- ======
- This plugin in can be divided in following simple parts
- 1. Simple Shorcode [ line 062 ]
- a. Dak Profile
- b. Twitter
- c. Subscribe
- d. Dak Header
- e. Rss
- f. Dak Recent Posts
- g. Dak Popular Posts
- h. Test
- 2. Installation of Table for Dak Diary [ Line 173 ]
- a. Diary List
- b. Diary Todo
- 3. Install Function Hello World [ Line 283]
- 4. Diary Widget [ Line 390 ]
- 5. Menu and Option Pages [ Line 470 ]
- 6. Hyperlink to Del.icio.us
- 7. Copy Plugin Interlinks for internal post links
- */
- // Code for [Dak Profile] ========
- function DakProfile()
- {
- return '<script type="text/javascript" src="http://pub.mybloglog.com/newwithme.php?b=inpage&id=QV7EcrwRqdF4.vRNdB.KVj2AsZXxewWmWpm.uQ--"></script>';
- }
- add_shortcode('Dak Profile', 'DakProfile');
- // Code for [Twitter] ============
- function twitt()
- {
- return '<div id="twitit"><a href="http://twitter.com/home?status=Currently reading '.get_permalink($post->ID).'" title="Click to send this page to Twitter!" target="_blank">Share on Twitter</a></div>';
- }
- add_shortcode('Twitter', 'twitt');
- // code for [Subscribe] ============
- function subscribeRss()
- {
- return '<div class="rss-box"><a href="http://feeds.feedburner.com/wprecipes">Enjoyed this post? Subscribe to my RSS feeds!</a></div>';
- }
- add_shortcode('Subscribe', 'subscribeRss');
- // code for [Dak Header] =============
- // code for display of some fixed content
- function DakHeader()
- {
- wp_register();
- echo "<li>";
- wp_loginout();
- wp_list_bookmarks('title_li=&categorize=0');
- }
- add_shortcode('Dak Header', 'DakHeader');
- // code for [Rss] ===========
- //This file is needed to be able to use the wp_rss() function.
- include_once(ABSPATH.WPINC.'/rss.php');
- function readRss($atts) {
- extract(shortcode_atts(array(
- "feed" => 'http://',
- "num" => '1',
- ), $atts));
- return wp_rss($feed, $num);
- }
- add_shortcode('Rss', 'readRss');
- // Usage: To use the shortcode, type in: [Rss feed="http://feeds.feedburner.com/reenain" num="5"]
- // it is successful but it shows list-of-posts on the top of the post
- #========= [Dak Recent Posts] ==========================
- function sc_liste($atts, $content = null) {
- extract(shortcode_atts(array(
- "num" => '5',
- "cat" => ''
- ), $atts));
- global $post;
- $myposts = get_posts('numberposts='.$num.'&order=DESC&orderby=post_date&category='.$cat);
- $retour='<ul>';
- foreach($myposts as $post) :
- setup_postdata($post);
- $retour.='<li><a href="'.get_permalink().'">'.the_title("","",false).'</a></li>';
- endforeach;
- $retour.='</ul> ';
- return $retour;
- }
- add_shortcode("Dak Recent Posts", "sc_liste");
- # To Use write: [Dak Recent Posts num="3" cat="1"]
- # If you dont use 'num' and 'cat' attributes, you will get most recent 5 posts
- #========= [Dak Popular Posts] ==========================
- # for display of some fixed content
- function PopularPosts()
- {
- echo "Developement of this shortcode is under progess<p>Mukesh Dak<p>27 March 2009<p>";
- }
- add_shortcode('Dak Popular Posts', 'PopularPosts');
- #========= [Test] ==========================
- # for display of some fixed content
- function FunTest()
- {
- return "Hi<p>Your testing is successful";
- }
- add_shortcode('Test', 'FunTest');
- //--------------------------------------------------------------
- add_filter('widget_text', 'do_shortcode');
- /* this line above allows our short codes to be used in widgets.
- --------------------------------------------------------------
- ShortCodes Ends Here
- --------------------------------------------------------------*/
- # ========== Install table for Dak Diary ==============
- function table_install()
- {
- global $wpdb;
- $table_name = $wpdb->prefix . 'dak_diary';
- // Now check is table is already present
- if($wpdb->get_var("SHOW TABLES LIKE '" . $table_name ."'") != $table_name)
- {
- $sql ="CREATE TABLE $table_name (
- `recid` int(10) unsigned NOT NULL auto_increment,
- `title` varchar(50) NOT NULL COMMENT 'Heading of the item',
- `linkurl` varchar(60) default NULL COMMENT 'Link related to topic if any',
- `category` varchar(20) default NULL COMMENT 'category',
- `created` datetime default NULL,
- `modified` datetime default NULL,
- `details` varchar(3999) default NULL,
- `priority` char(1) default '5',
- PRIMARY KEY (`recid`)
- ) ;";
- $results = $wpdb->query($sql);
- } // table install finish
- } // function table install finish.
- register_activation_hook(__FILE__,'table_install');
- # ============= code for getting list of recent entries start here ====================
- function dak_get_diary()
- {
- global $wpdb;
- $table_name = $wpdb->prefix . 'dak_diary';
- $sql = "SELECT * from `$table_name` ORDER by created DESC Limit 10";
- $results = $wpdb->get_results($sql);
- $output_html = '<p><a href=http://localhost/php/papps/diary/index.php?ACTION=NEW target=_new>New Record.....</a><br>';
- $output_html .= '<ul>';
- foreach($results as $result)
- {
- #$output_html .= '<li>' . $result->title. "</li>";
- $output_html .= '<li><a href=http://localhost/php/papps/diary/index.php?recid='.$result->recid.'&ACTION=VIEW target=_new>E</a> <a href='.$result->linkurl.'>'. $result->title.'</a></li>';
- #http://localhost/php/papps/diary/index.php?recid=3&ACTION=VIEW
- # $output_html .= '<li class="todo-' . $class . '" title="' . date('F jS, Y', $result->date_due) . '">' . $result->task_desc . "</li>";
- }
- $output_html .= '</ul>';
- echo $output_html;
- }
- add_shortcode('Diary List', 'dak_get_diary');
- # ============= code for getting list of recent entries start here ====================
- # ============= code for getting list of todo start here ====================
- function dak_get_todo()
- {
- global $wpdb;
- $table_name = $wpdb->prefix . 'dak_diary';
- $sql = "SELECT * from `$table_name` WHERE category like 'todo' ORDER by priority LIMIT 100";
- $results = $wpdb->get_results($sql);
- $output_html = '<ul>';
- foreach($results as $result)
- {
- #$output_html .= '<li>' . $result->title. "</li>";
- $output_html .= '<li><a href=http://localhost/php/papps/diary/index.php?recid='.$result->recid.'&ACTION=VIEW target=_new>E</a> '. $result->title.'</li>';
- #http://localhost/php/papps/diary/index.php?recid=3&ACTION=VIEW
- # $output_html .= '<li class="todo-' . $class . '" title="' . date('F jS, Y', $result->date_due) . '">' . $result->task_desc . "</li>";
- }
- $output_html .= '</ul>';
- echo $output_html;
- }
- add_shortcode('Diary Todo', 'dak_get_todo');
- # to get todo listing
- # ============= code for getting list of recent entries ends here ====================
- # ======= Code for Dak Diary End here ====================
- # ============ Hello World Function =============
- function say_hello()
- {
- $greeting = get_option('hello_greeting');
- $target = get_option('hello_target');
- print "$greeting $target";
- }
- function set_hello_options()
- {
- add_option('hello_greeting','hello','What to Say');
- add_option('hello_target','world','To whom to Say');
- }
- function unset_hello_options()
- {
- delete_option('hello_greeting');
- delete_option('hello_target');
- }
- register_activation_hook(__FILE__,'set_hello_options');
- register_deactivation_hook(__FILE__,'unset_hello_options');
- function admin_hello_options()
- {
- ?><div class="wrap"><h2>Hello World Options</h2><?php
- if ($_REQUEST['submit'])
- {
- update_hello_options();
- }
- print_hello_form();
- ?></div><?php
- }
- function modify_menu()
- {
- add_options_page("Hello World", "Hello World", 1, __FILE__, 'admin_hello_options');
- }
- add_action('admin_menu', 'modify_menu');
- function update_hello_options()
- {
- $ok = false;
- // you probably want some input validation in here
- if ($_REQUEST['hello_greeting'])
- {
- update_option('hello_greeting', $_REQUEST['hello_greeting']);
- $ok = true;
- }
- if ($_REQUEST['hello_target'])
- {
- update_option('hello_target', $_REQUEST['hello_target']);
- $ok = true;
- }
- if ($ok)
- {
- ?><div id="message" class="updated fade"><p>Options saved.</p></div><?php
- }
- else
- {
- ?><div id="message" class="error fade"><p>Failed to save options.</p></div><?php
- }
- }
- function print_hello_form()
- {
- $default_greeting = get_option('hello_greeting');
- $default_target = get_option('hello_target');
- ?>
- <from method="post">
- <label for="hello_greeting">Greeting:
- <input type="text" name="hello_greeting" value="<?=$default_greeting?>" />
- </label>
- <br />
- <label for="hello_target">Target:
- <input type="text" name="hello_target" value="<?=$default_target?>" />
- </label>
- <br />
- <input type="submit" value="Submit" />
- </form>
- <?php
- }
- # =============== Starting code of widget ==============
- # Parameters Used by Dak
- # dak_widget_swp --> Function for display of widget
- # dak_widget_swp_control --> function for control of the widget
- function widget_DiaryWidget($args) {
- // First we grab the Wordpress theme args, which we
- // use to display the widget
- extract($args);
- // Now we sniff around to see if there are
- // any preset options
- $options = get_option("widget_DiaryWidget");
- // If no options have been set, we need to set them
- if (!is_array( $options ))
- {
- $options = array(
- 'title' => 'Widget Title',
- 'text' => 'Widget Text'
- );
- }
- // Display the widget!
- echo $before_widget;
- echo $before_title;
- #echo $options['title'];
- echo "ToDo Dak";
- echo $after_title;
- //Our Widget Content
- dak_get_todo();
- echo $after_widget;
- }
- function DiaryWidget_control() {
- // We need to grab any preset options
- $options = get_option("widget_DiaryWidget");
- // No options? No problem! We set them here.
- if (!is_array( $options )) {
- $options = array(
- 'title' => 'Widget Title',
- 'text' => 'Widget Text'
- );
- }
- // Is the user has set the options and clicked save,
- // Then we grab them using the $_POST function.
- if ($_POST['DiaryWidget-Submit']) {
- $options['title'] =
- htmlspecialchars($_POST['DiaryWidget-WidgetTitle']);
- $options['text'] =
- htmlspecialchars($_POST['DiaryWidget-WidgetText']);
- // And we also update the options in the Wordpress Database
- update_option("widget_DiaryWidget", $options);
- }
- ?>
- <p>
- <label for="DiaryWidget-WidgetTitle">Widget Title:</label>
- <input type="text"
- id="DiaryWidget-WidgetTitle"
- name="DiaryWidget-WidgetTitle"
- value="<?php echo $options['title'];?>" />
- <label for="DiaryWidget-WidgetText">Widget Text:</label>
- <textarea id="DiaryWidget-WidgetText"
- name="DiaryWidget-WidgetText"
- cols="30" rows="4">
- <?php echo $options['text'];?>
Add Comment
Please, Sign In to add comment