reenadak

dak wordpress plugin

Sep 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.09 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Plugin Name: DakWP
  5. Plugin URI: http://reena.in/DakWP
  6. 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.
  7. Version: v9.12.27
  8. Author: Mukesh Dak
  9. Author URI: http://mukeshdak.com
  10.  
  11.    
  12.    Copyright 2009  Mukesh Dak  (email : [email protected])
  13.  
  14.     This program is free software; you can redistribute it and/or modify
  15.     it under the terms of the GNU General Public License as published by
  16.     the Free Software Foundation; either version 2 of the License, or
  17.     (at your option) any later version.
  18.  
  19.     This program is distributed in the hope that it will be useful,
  20.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.     GNU General Public License for more details.
  23.  
  24.     You should have received a copy of the GNU General Public License
  25.     along with this program; if not, write to the Free Software
  26.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  27.  
  28. ====
  29. HELP
  30. ====
  31.  
  32. For Help See Menu DakWP in Dashboard
  33.  
  34. ======
  35. README
  36. ======
  37.  
  38. This plugin in can be divided in following simple parts
  39.  
  40. 1. Simple Shorcode [ line 062 ]
  41.    a. Dak Profile
  42.    b. Twitter
  43.    c. Subscribe
  44.    d. Dak Header
  45.    e. Rss
  46.    f. Dak Recent Posts
  47.    g. Dak Popular Posts
  48.    h. Test
  49.  
  50. 2. Installation of Table for Dak Diary [ Line 173 ]
  51.    a. Diary List
  52.    b. Diary Todo
  53.  
  54. 3. Install Function Hello World [ Line 283]
  55.  
  56. 4. Diary Widget [ Line 390 ]
  57.  
  58. 5. Menu and Option Pages [ Line 470 ]
  59.  
  60. 6. Hyperlink to Del.icio.us
  61.  
  62. 7. Copy Plugin Interlinks for internal post links
  63.  
  64.  
  65. */
  66.  
  67.  
  68. // Code for [Dak Profile] ========
  69.  
  70. function DakProfile()
  71.     {
  72.     return '<script type="text/javascript" src="http://pub.mybloglog.com/newwithme.php?b=inpage&id=QV7EcrwRqdF4.vRNdB.KVj2AsZXxewWmWpm.uQ--"></script>';    
  73.     }
  74. add_shortcode('Dak Profile', 'DakProfile');
  75.  
  76.  
  77. // Code for [Twitter] ============
  78.  
  79. function twitt()
  80.     {
  81.   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>';
  82.     }
  83. add_shortcode('Twitter', 'twitt');
  84.  
  85.  
  86.  
  87. // code for [Subscribe] ============
  88.  
  89. function subscribeRss()
  90.     {
  91.     return '<div class="rss-box"><a href="http://feeds.feedburner.com/wprecipes">Enjoyed this post? Subscribe to my RSS feeds!</a></div>';
  92.     }
  93. add_shortcode('Subscribe', 'subscribeRss');
  94.  
  95.  
  96. // code for [Dak Header] =============
  97.  
  98. // code  for display of some fixed content
  99. function DakHeader()
  100.     {
  101.     wp_register();
  102.     echo "<li>";
  103.     wp_loginout();
  104.     wp_list_bookmarks('title_li=&categorize=0');       
  105.     }
  106. add_shortcode('Dak Header', 'DakHeader');
  107.  
  108.  
  109. // code for [Rss] ===========
  110.  
  111. //This file is needed to be able to use the wp_rss() function.
  112. include_once(ABSPATH.WPINC.'/rss.php');
  113.  
  114. function readRss($atts) {
  115.     extract(shortcode_atts(array(
  116.     "feed" => 'http://',
  117.       "num" => '1',
  118.     ), $atts));
  119.  
  120.     return wp_rss($feed, $num);
  121. }
  122. add_shortcode('Rss', 'readRss');
  123.  
  124. // Usage: To use the shortcode, type in:  [Rss feed="http://feeds.feedburner.com/reenain" num="5"]
  125. // it is successful but it shows list-of-posts on the top of the post
  126.  
  127.  
  128.  
  129. #========= [Dak Recent Posts] ==========================
  130.  
  131. function sc_liste($atts, $content = null) {
  132.         extract(shortcode_atts(array(
  133.                 "num" => '5',
  134.                 "cat" => ''
  135.         ), $atts));
  136.         global $post;
  137.         $myposts = get_posts('numberposts='.$num.'&order=DESC&orderby=post_date&category='.$cat);
  138.         $retour='<ul>';
  139.         foreach($myposts as $post) :
  140.                 setup_postdata($post);
  141.              $retour.='<li><a href="'.get_permalink().'">'.the_title("","",false).'</a></li>';
  142.         endforeach;
  143.         $retour.='</ul> ';
  144.         return $retour;
  145. }
  146. add_shortcode("Dak Recent Posts", "sc_liste");
  147. # To Use write: [Dak Recent Posts num="3" cat="1"]
  148. # If you dont use 'num' and 'cat' attributes, you will get most recent 5 posts
  149.  
  150.  
  151. #========= [Dak Popular Posts] ==========================
  152.  
  153. # for display of some fixed content
  154. function PopularPosts()
  155. {
  156. echo "Developement of this shortcode is under progess<p>Mukesh Dak<p>27 March 2009<p>";
  157.     }
  158. add_shortcode('Dak Popular Posts', 'PopularPosts');
  159.  
  160.  
  161.  
  162. #========= [Test] ==========================
  163.  
  164. # for display of some fixed content
  165. function FunTest()
  166.     {
  167.     return "Hi<p>Your testing is successful";
  168.     }
  169. add_shortcode('Test', 'FunTest');
  170.  
  171.  
  172. //--------------------------------------------------------------
  173. add_filter('widget_text', 'do_shortcode');
  174.  
  175. /* this line above allows our short codes to be used in widgets.
  176.  
  177. --------------------------------------------------------------
  178.  
  179.  ShortCodes Ends Here
  180.  
  181. --------------------------------------------------------------*/
  182.  
  183.  
  184. # ========== Install table for Dak Diary ==============
  185. function table_install()
  186.     {
  187.             global $wpdb;
  188.             $table_name = $wpdb->prefix . 'dak_diary';
  189.  
  190.             // Now check is table is already present
  191.                 if($wpdb->get_var("SHOW TABLES LIKE '" . $table_name ."'") != $table_name)
  192.                     {
  193.                         $sql ="CREATE TABLE  $table_name (
  194.                           `recid` int(10) unsigned NOT NULL auto_increment,
  195.                           `title` varchar(50) NOT NULL COMMENT 'Heading of the item',
  196.                           `linkurl` varchar(60) default NULL COMMENT 'Link related to topic if any',
  197.                           `category` varchar(20) default NULL COMMENT 'category',
  198.                           `created` datetime default NULL,
  199.                           `modified` datetime default NULL,
  200.                           `details` varchar(3999) default NULL,
  201.                           `priority` char(1) default '5',
  202.                           PRIMARY KEY  (`recid`)
  203.                         ) ;";
  204.  
  205.                         $results = $wpdb->query($sql);
  206.                     } // table install finish
  207.         } // function table install finish.
  208.  
  209. register_activation_hook(__FILE__,'table_install');
  210.  
  211.  
  212. # ============= code for getting list of recent entries start here ====================
  213.  
  214. function dak_get_diary()
  215. {
  216.  
  217.     global $wpdb;
  218.  
  219.     $table_name = $wpdb->prefix . 'dak_diary';
  220.  
  221.     $sql = "SELECT * from `$table_name` ORDER by created  DESC Limit 10";
  222.    
  223.     $results = $wpdb->get_results($sql);
  224.        
  225.     $output_html = '<p><a href=http://localhost/php/papps/diary/index.php?ACTION=NEW target=_new>New Record.....</a><br>';
  226.    
  227.     $output_html .= '<ul>';
  228.    
  229.     foreach($results as $result)
  230.     {
  231.         #$output_html .= '<li>' . $result->title. "</li>";
  232.         $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>';
  233.  
  234.         #http://localhost/php/papps/diary/index.php?recid=3&ACTION=VIEW
  235.  
  236.         #   $output_html .= '<li class="todo-' . $class . '" title="' . date('F jS, Y', $result->date_due) . '">' . $result->task_desc . "</li>";
  237.     }
  238.     $output_html .= '</ul>';
  239.  
  240.     echo $output_html;
  241. }
  242.  
  243. add_shortcode('Diary List', 'dak_get_diary');
  244.  
  245. # ============= code for getting list of recent entries start here ====================
  246.  
  247.  
  248.  
  249. # ============= code for getting list of todo start here ====================
  250.  
  251. function dak_get_todo()
  252. {
  253.  
  254.     global $wpdb;
  255.  
  256.     $table_name = $wpdb->prefix . 'dak_diary';
  257.  
  258.     $sql = "SELECT * from `$table_name` WHERE category like 'todo'  ORDER by priority LIMIT 100";
  259.    
  260.    
  261.     $results = $wpdb->get_results($sql);
  262.        
  263.    
  264.     $output_html = '<ul>';
  265.    
  266.     foreach($results as $result)
  267.     {
  268.         #$output_html .= '<li>' . $result->title. "</li>";
  269.  
  270.         $output_html .= '<li><a href=http://localhost/php/papps/diary/index.php?recid='.$result->recid.'&ACTION=VIEW target=_new>E</a> '. $result->title.'</li>';
  271.  
  272.         #http://localhost/php/papps/diary/index.php?recid=3&ACTION=VIEW
  273.  
  274.         #   $output_html .= '<li class="todo-' . $class . '" title="' . date('F jS, Y', $result->date_due) . '">' . $result->task_desc . "</li>";
  275.     }
  276.     $output_html .= '</ul>';
  277.  
  278.     echo $output_html;
  279. }
  280.  
  281. add_shortcode('Diary Todo', 'dak_get_todo');
  282. # to get todo listing
  283.  
  284. # ============= code for getting list of recent entries ends here ====================
  285. # ======= Code for Dak Diary End here ====================
  286.  
  287.  
  288.  
  289. # ============ Hello World Function =============
  290. function say_hello()
  291.     {
  292.         $greeting = get_option('hello_greeting');
  293.         $target = get_option('hello_target');
  294.         print "$greeting $target";
  295.     }
  296.  
  297. function set_hello_options()
  298.     {
  299.     add_option('hello_greeting','hello','What to Say');
  300.     add_option('hello_target','world','To whom to Say');
  301.     }
  302.  
  303. function unset_hello_options()
  304.     {
  305.     delete_option('hello_greeting');
  306.     delete_option('hello_target');
  307.     }
  308.  
  309.     register_activation_hook(__FILE__,'set_hello_options');
  310.     register_deactivation_hook(__FILE__,'unset_hello_options');
  311.  
  312.     function admin_hello_options()
  313.     {
  314.         ?><div class="wrap"><h2>Hello World Options</h2><?php
  315.                
  316.         if ($_REQUEST['submit'])
  317.         {
  318.             update_hello_options();
  319.         }
  320.         print_hello_form();
  321.  
  322.         ?></div><?php
  323.     }
  324.  
  325.     function modify_menu()
  326.     {
  327.         add_options_page("Hello World", "Hello World", 1, __FILE__,  'admin_hello_options');
  328.     }
  329.     add_action('admin_menu', 'modify_menu');
  330.  
  331.     function update_hello_options()
  332.     {
  333.         $ok = false;
  334.         // you probably want some input validation in here
  335.         if ($_REQUEST['hello_greeting'])
  336.         {
  337.                 update_option('hello_greeting', $_REQUEST['hello_greeting']);
  338.                 $ok = true;
  339.         }
  340.            
  341.             if ($_REQUEST['hello_target'])
  342.         {
  343.                 update_option('hello_target', $_REQUEST['hello_target']);
  344.                 $ok = true;
  345.         }
  346.  
  347.         if ($ok)
  348.         {
  349.             ?><div id="message" class="updated fade"><p>Options saved.</p></div><?php
  350.         }
  351.             else
  352.         {
  353.                 ?><div id="message" class="error fade"><p>Failed to save options.</p></div><?php
  354.         }
  355.     }
  356.  
  357. function print_hello_form()
  358. {
  359.     $default_greeting = get_option('hello_greeting');
  360.     $default_target = get_option('hello_target');
  361.     ?>
  362.     <from method="post">
  363.     <label for="hello_greeting">Greeting:
  364.         <input type="text" name="hello_greeting" value="<?=$default_greeting?>" />
  365.         </label>
  366.         <br />
  367.         <label for="hello_target">Target:
  368.         <input type="text" name="hello_target" value="<?=$default_target?>" />
  369.         </label>
  370.         <br />
  371.         <input type="submit" value="Submit" />
  372.         </form>
  373.         <?php
  374. }
  375.  
  376.  
  377.  
  378. # =============== Starting code of widget ==============
  379.  
  380. # Parameters Used by Dak
  381. #  dak_widget_swp  --> Function for display of widget
  382. #  dak_widget_swp_control   --> function for control of the widget
  383.  
  384. function widget_DiaryWidget($args) {
  385.     // First we grab the Wordpress theme args, which we
  386.     // use to display the widget
  387.     extract($args);
  388.    
  389.     // Now we sniff around to see if there are
  390.     // any preset options
  391.     $options = get_option("widget_DiaryWidget");
  392.    
  393.     // If no options have been set, we need to set them
  394.     if (!is_array( $options ))
  395.         {
  396.         $options = array(
  397.         'title' => 'Widget Title',
  398.         'text' => 'Widget Text'
  399.         );
  400.     }  
  401.     // Display the widget!
  402.     echo $before_widget;
  403.     echo $before_title;
  404.     #echo $options['title'];
  405.     echo "ToDo Dak";
  406.     echo $after_title;
  407.     //Our Widget Content
  408.     dak_get_todo();
  409.     echo $after_widget;
  410. }
  411.  
  412.  
  413.  
  414. function DiaryWidget_control() {
  415.    
  416.     // We need to grab any preset options
  417.     $options = get_option("widget_DiaryWidget");
  418.    
  419.     // No options? No problem! We set them here.
  420.     if (!is_array( $options )) {
  421.         $options = array(
  422.         'title' => 'Widget Title',
  423.         'text' => 'Widget Text'
  424.         );
  425.     }      
  426.    
  427.     // Is the user has set the options and clicked save,
  428.     // Then we grab them using the $_POST function.
  429.     if ($_POST['DiaryWidget-Submit']) {
  430.         $options['title'] =
  431.           htmlspecialchars($_POST['DiaryWidget-WidgetTitle']);
  432.         $options['text'] =
  433.           htmlspecialchars($_POST['DiaryWidget-WidgetText']);
  434.         // And we also update the options in the Wordpress Database
  435.         update_option("widget_DiaryWidget", $options);
  436.     }
  437.    
  438. ?>
  439. <p>
  440.     <label for="DiaryWidget-WidgetTitle">Widget Title:</label>
  441.     <input type="text"
  442.       id="DiaryWidget-WidgetTitle"
  443.       name="DiaryWidget-WidgetTitle"
  444.       value="<?php echo $options['title'];?>" />
  445.  
  446.     <label for="DiaryWidget-WidgetText">Widget Text:</label>
  447.     <textarea id="DiaryWidget-WidgetText"
  448.       name="DiaryWidget-WidgetText"
  449.       cols="30" rows="4">
  450.     <?php echo $options['text'];?>
Add Comment
Please, Sign In to add comment