Posted By

Ijaas on 02/08/11


Tagged

php plugin wordpress mod


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mintcold


myCategoryOrder Custom Taxonomy mod


 / Published in: PHP
 

replaced taxonomy = 'category' with taxonomy = '".myTAXONOMY."' add lines 51, 52, 93 - 123

  1. <?php
  2. /*
  3. Plugin Name: My Category Order
  4. Plugin URI: http://www.geekyweekly.com/mycategoryorder
  5. Description: My Category Order allows you to set the order in which categories will appear in the sidebar. Uses a drag and drop interface for ordering. Adds a widget with additional options for easy installation on widgetized themes.
  6. Version: 3.0.1
  7. Author: Andrew Charlton & modified by Ijaas (http://www.dex-labs.com)
  8. Author URI: http://www.geekyweekly.com
  9. Author Email: [email protected]
  10. */
  11.  
  12. function mycategoryorder_init() {
  13.  
  14. function mycategoryorder_menu()
  15. {
  16. add_posts_page(__('My Category Order', 'mycategoryorder'), __('My Category Order', 'mycategoryorder'), 'manage_categories', 'mycategoryorder', 'mycategoryorder');
  17. }
  18.  
  19. function mycategoryorder_js_libs() {
  20. if ( isset($_GET['page']) && $_GET['page'] == "mycategoryorder" )
  21. {
  22. wp_enqueue_script('jquery');
  23. wp_enqueue_script('jquery-ui-core');
  24. wp_enqueue_script('jquery-ui-sortable');
  25. }
  26. }
  27.  
  28. //Switch page target depending on version
  29. function mycategoryorder_getTarget() {
  30. return "edit.php";
  31. }
  32.  
  33. function mycategoryorder_set_plugin_meta($links, $file) {
  34. $plugin = plugin_basename(__FILE__);
  35. // create link
  36. if ($file == $plugin) {
  37. return array_merge( $links, array(
  38. '<a href="' . mycategoryorder_getTarget() . '">' . __('Order Categories', 'mycategoryorder') . '</a>',
  39. '<a href="http://wordpress.org/tags/my-category-order?forum_id=10#postform">' . __('Support Forum') . '</a>',
  40. '<a href="http://geekyweekly.com/gifts-and-donations">' . __('Donate') . '</a>'
  41. ));
  42. }
  43. return $links;
  44. }
  45.  
  46. add_filter('plugin_row_meta', 'mycategoryorder_set_plugin_meta', 10, 2 );
  47. add_action('admin_menu', 'mycategoryorder_menu');
  48. add_action('admin_print_scripts', 'mycategoryorder_js_libs');
  49.  
  50. //Define selected taxonomy
  51. $tax = ($_GET['mytax'])? $_GET['mytax'] : 'category';
  52. define('myTAXONOMY', $tax, true);
  53.  
  54. function mycategoryorder()
  55. {
  56. global $wpdb;
  57.  
  58. $parentID = 0;
  59.  
  60. $wpdb->show_errors();
  61.  
  62. $query1 = $wpdb->query("SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order'");
  63.  
  64. if ($query1 == 0) {
  65. $wpdb->query("ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT '0'");
  66. }
  67.  
  68. if (isset($_POST['btnSubCats'])) {
  69. $parentID = $_POST['cats'];
  70. }
  71. elseif (isset($_POST['hdnParentID'])) {
  72. $parentID = $_POST['hdnParentID'];
  73. }
  74.  
  75. if (isset($_POST['btnReturnParent'])) {
  76. $parentsParent = $wpdb->get_row("SELECT parent FROM $wpdb->term_taxonomy WHERE term_id = " . $_POST['hdnParentID'], ARRAY_N);
  77. $parentID = $parentsParent[0];
  78. }
  79.  
  80. if(isset($_GET['hideNote']))
  81. update_option('mycategoryorder_hideNote', '1');
  82.  
  83. $success = "";
  84. if (isset($_POST['btnOrderCats'])) {
  85. $success = mycategoryorder_updateOrder();
  86. }
  87.  
  88. $subCatStr = mycategoryorder_getSubCats($parentID);
  89.  
  90. ?>
  91. <div class='wrap'>
  92.  
  93. <?php //Start of Custom taxonomy ?>
  94. <form name="frmMyCatOrderTax" method="get" action="">
  95. <input type="hidden" name="page" value="<?php echo $_GET['page']; ?>" />
  96. <h2><?php _e('My Category Order','mycategoryorder'); ?></h2>
  97. <?php
  98. if (get_option("mycategoryorder_hideNote") != "1")
  99. { ?>
  100. <div class="updated">
  101. <strong><p><?php _e('If you like my plugin please consider donating. Every little bit helps me provide support and continue development.','mycategoryorder'); ?> <a href="http://geekyweekly.com/gifts-and-donations"><?php _e('Donate', 'mycategoryorder'); ?></a>&nbsp;&nbsp;<small><a href="<?php echo mycategoryorder_getTarget(); ?>&hideNote=true"><?php _e('No thanks, hide this', 'mycategoryorder'); ?></a></small></p></strong>
  102. </div>
  103. <?php
  104. } ?>
  105.  
  106. <p><?php _e('Choose a taxonomy from the drop down to order its terms','mycategoryorder'); ?></p>
  107. <?php
  108. // Custom Taxonomy dropdown
  109. $taxes = get_taxonomies(); $taxlist = array();
  110. echo "<select name='mytax'>";
  111. foreach($taxes as $tax):
  112. if(is_taxonomy_hierarchical($tax)):
  113. $tax = get_taxonomy($tax);
  114. $s = (myTAXONOMY == $tax->name)? "selected='selected'" : '';
  115. echo "<option ".$s." value='".$tax->name."'>".$tax->label."</option>";
  116. endif;
  117. endforeach;
  118. echo "</select>";
  119.  
  120. ?>
  121. <input type="submit" class="button" value="<?php _e('Change Taxonomy', 'mycategoryorder') ?>" />
  122. </form>
  123. <?php //End of Custom taxonomy ?>
  124.  
  125. <form name="frmMyCatOrder" method="post" action="">
  126.  
  127. <?php
  128. echo $success;
  129. ?>
  130.  
  131. <p><?php _e('Choose a category from the drop down to order subcategories in that category or order the categories on this level by dragging and dropping them into the desired order.','mycategoryorder'); ?></p>
  132.  
  133. <?php
  134. if($subCatStr != "")
  135. {
  136. ?>
  137. <h3><?php _e('Order Subcategories','mycategoryorder'); ?></h3>
  138. <select id="cats" name="cats">
  139. <?php echo $subCatStr; ?>
  140. </select>
  141. &nbsp;<input type="submit" name="btnSubCats" class="button" id="btnSubCats" value="<?php _e('Order Subcategories','mycategoryorder'); ?>" />
  142. <?php } ?>
  143.  
  144. <h3><?php _e('Order Categories','mycategoryorder'); ?></h3>
  145. <ul id="myCategoryOrderList">
  146. <?php
  147. $results= mycategoryorder_catQuery($parentID);
  148. foreach($results as $row)
  149. echo "<li id='id_$row->term_id' class='lineitem'>".__($row->name)."</li>";
  150. ?>
  151. </ul>
  152.  
  153. <input type="submit" name="btnOrderCats" id="btnOrderCats" class="button-primary" value="<?php _e('Click to Order Categories', 'mycategoryorder') ?>" onclick="javascript:orderCats(); return true;" />
  154. <?php echo mycategoryorder_getParentLink($parentID); ?>
  155. &nbsp;&nbsp;<strong id="updateText"></strong>
  156. <br /><br />
  157. <p>
  158. <a href="http://geekyweekly.com/mycategoryorder"><?php _e('Plugin Homepage', 'mycategoryorder') ?></a>&nbsp;|&nbsp;<a href="http://geekyweekly.com/gifts-and-donations"><?php _e('Donate', 'mycategoryorder') ?></a>&nbsp;|&nbsp;<a href="http://wordpress.org/tags/my-category-order?forum_id=10"><?php _e('Support Forum', 'mycategoryorder') ?></a>
  159. </p>
  160. <input type="hidden" id="hdnMyCategoryOrder" name="hdnMyCategoryOrder" />
  161. <input type="hidden" id="hdnParentID" name="hdnParentID" value="<?php echo $parentID; ?>" />
  162. </form>
  163.  
  164. </div>
  165.  
  166. <style type="text/css">
  167. #myCategoryOrderList {
  168. width: 90%;
  169. border:1px solid #B2B2B2;
  170. margin:10px 10px 10px 0px;
  171. padding:5px 10px 5px 10px;
  172. list-style:none;
  173. background-color:#fff;
  174. -moz-border-radius:3px;
  175. -webkit-border-radius:3px;
  176. }
  177.  
  178. li.lineitem {
  179. border:1px solid #B2B2B2;
  180. -moz-border-radius:3px;
  181. -webkit-border-radius:3px;
  182. background-color:#F1F1F1;
  183. color:#000;
  184. cursor:move;
  185. font-size:13px;
  186. margin-top:5px;
  187. margin-bottom:5px;
  188. padding: 2px 5px 2px 5px;
  189. height:1.5em;
  190. line-height:1.5em;
  191. }
  192.  
  193. .sortable-placeholder{
  194. border:1px dashed #B2B2B2;
  195. margin-top:5px;
  196. margin-bottom:5px;
  197. padding: 2px 5px 2px 5px;
  198. height:1.5em;
  199. line-height:1.5em;
  200. }
  201. </style>
  202.  
  203. <script type="text/javascript">
  204. // <![CDATA[
  205.  
  206. function mycategoryrderaddloadevent(){
  207. jQuery("#myCategoryOrderList").sortable({
  208. placeholder: "sortable-placeholder",
  209. revert: false,
  210. tolerance: "pointer"
  211. });
  212. };
  213.  
  214. addLoadEvent(mycategoryrderaddloadevent);
  215.  
  216. function orderCats() {
  217. jQuery("#updateText").html("<?php _e('Updating Category Order...', 'mycategoryorder') ?>");
  218. jQuery("#hdnMyCategoryOrder").val(jQuery("#myCategoryOrderList").sortable("toArray"));
  219. }
  220.  
  221. // ]]>
  222. </script>
  223.  
  224. <?php
  225. }
  226. }
  227.  
  228. function mycategoryorder_getSubCats($parentID)
  229. {
  230. global $wpdb;
  231.  
  232. $subCatStr = "";
  233. $results=$wpdb->get_results("SELECT t.term_id, t.name FROM $wpdb->term_taxonomy tt, $wpdb->terms t, $wpdb->term_taxonomy tt2 WHERE tt.parent = $parentID AND tt.taxonomy = '".myTAXONOMY."' AND t.term_id = tt.term_id AND tt2.parent = tt.term_id GROUP BY t.term_id, t.name HAVING COUNT(*) > 0 ORDER BY t.term_order ASC");
  234. foreach($results as $row)
  235. {
  236. $subCatStr = $subCatStr."<option value='$row->term_id'>$row->name</option>";
  237. }
  238.  
  239. return $subCatStr;
  240. }
  241.  
  242. function mycategoryorder_updateOrder()
  243. {
  244. if (isset($_POST['hdnMyCategoryOrder']) && $_POST['hdnMyCategoryOrder'] != "") {
  245. global $wpdb;
  246.  
  247. $hdnMyCategoryOrder = $_POST['hdnMyCategoryOrder'];
  248. $IDs = explode(",", $hdnMyCategoryOrder);
  249. $result = count($IDs);
  250.  
  251. for($i = 0; $i < $result; $i++)
  252. {
  253. $str = str_replace("id_", "", $IDs[$i]);
  254. $wpdb->query("UPDATE $wpdb->terms SET term_order = '$i' WHERE term_id ='$str'");
  255. }
  256.  
  257. return '<div id="message" class="updated fade"><p>'. __('Categories updated successfully.', 'mycategoryorder').'</p></div>';
  258. }
  259. else
  260. return '<div id="message" class="updated fade"><p>'. __('An error occured, order has not been saved.', 'mycategoryorder').'</p></div>';
  261. }
  262.  
  263. function mycategoryorder_catQuery($parentID)
  264. {
  265. global $wpdb;
  266. return $wpdb->get_results("SELECT * FROM $wpdb->terms t inner join $wpdb->term_taxonomy tt on t.term_id = tt.term_id WHERE taxonomy = '".myTAXONOMY."' and parent = $parentID ORDER BY term_order ASC");
  267. }
  268.  
  269. function mycategoryorder_getParentLink($parentID)
  270. {
  271. if($parentID != 0)
  272. return "&nbsp;&nbsp;<input type='submit' class='button' id='btnReturnParent' name='btnReturnParent' value='" . __('Return to parent category', 'mycategoryorder') ."' />";
  273. else
  274. return "";
  275. }
  276.  
  277. function mycategoryorder_applyorderfilter($orderby, $args)
  278. {
  279. if($args['orderby'] == 'order')
  280. return 't.term_order';
  281. else
  282. return $orderby;
  283. }
  284.  
  285. add_filter('get_terms_orderby', 'mycategoryorder_applyorderfilter', 10, 2);
  286.  
  287. add_action('plugins_loaded', 'mycategoryorder_init');
  288.  
  289. /* Load Translations */
  290. add_action('init', 'mycategoryorder_loadtranslation');
  291.  
  292. function mycategoryorder_loadtranslation() {
  293. load_plugin_textdomain('mycategoryorder', PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)), dirname(plugin_basename(__FILE__)));
  294. }
  295.  
  296.  
  297. class mycategoryorder_Widget extends WP_Widget {
  298.  
  299. function mycategoryorder_Widget() {
  300. $widget_ops = array('classname' => 'widget_mycategoryorder', 'description' => __( 'Enhanced Category widget provided by My Category Order') );
  301. $this->WP_Widget('mycategoryorder', __('My Category Order'), $widget_ops); }
  302.  
  303. function widget( $args, $instance ) {
  304. extract( $args );
  305.  
  306. $title_li = apply_filters('widget_title', empty( $instance['title_li'] ) ? __( 'Categories' ) : $instance['title_li']);
  307. $orderby = empty( $instance['orderby'] ) ? 'order' : $instance['orderby'];
  308. $order = empty( $instance['order'] ) ? 'asc' : $instance['order'];
  309. $show_dropdown = (bool) $instance['show_dropdown'];
  310. $show_last_updated = (bool) $instance['show_last_updated'];
  311. $show_count = (bool) $instance['show_count'];
  312. $hide_empty = (bool) $instance['hide_empty'];
  313. $use_desc_for_title = (bool) $instance['use_desc_for_title'];
  314. $child_of = empty( $instance['child_of'] ) ? '' : $instance['child_of'];
  315. $feed = empty( $instance['feed'] ) ? '' : $instance['feed'];
  316. $feed_image = empty( $instance['feed_image'] ) ? '' : $instance['feed_image'];
  317. $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
  318. $exclude_tree = empty( $instance['exclude_tree'] ) ? '' : $instance['exclude_tree'];
  319. $include = empty( $instance['include'] ) ? '' : $instance['include'];
  320. $hierarchical = empty( $instance['hierarchical'] ) ? '1' : $instance['hierarchical'];
  321. $number = empty( $instance['number'] ) ? '' : $instance['number'];
  322. $depth = empty( $instance['depth'] ) ? '0' : $instance['depth'];
  323.  
  324. echo $before_widget;
  325. if ( $title_li )
  326. echo $before_title . $title_li . $after_title;
  327.  
  328. $cat_args = array('orderby' => $orderby, 'order' => $order, 'show_last_updated' => $show_last_updated, 'show_count' => $show_count,
  329. 'hide_empty' => $hide_empty, 'use_desc_for_title' => $use_desc_for_title, 'child_of' => $child_of, 'feed' => $feed,
  330. 'feed_image' => $feed_image, 'exclude' => $exclude, 'exclude_tree' => $exclude_tree, 'include' => $include,
  331. 'hierarchical' => $hierarchical, 'number' => $number, 'depth' => $depth, );
  332.  
  333. if ( $show_dropdown ) {
  334. static $dropdown_count = 0;
  335.  
  336. $cat_id = 'dropdown_'.$args['widget_id'];
  337. $cat_args['id'] = $cat_args['name'] = $cat_id;
  338. $cat_args['show_option_none'] = __('Select Category');
  339. wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
  340. ?>
  341.  
  342. <script type='text/javascript'>
  343. /* <![CDATA[ */
  344. <?php if ( $dropdown_count == 0 ) { ?>
  345. function onCatChange( dropdownID ) {
  346. var dropdown = document.getElementById(dropdownID);
  347. if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
  348. location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
  349. }
  350. }
  351. <?php } ?>
  352. document.getElementById("<?php echo $cat_id; ?>").onchange = function(){onCatChange(this.id)};
  353. /* ]]> */
  354. </script>
  355.  
  356. <?php
  357. $dropdown_count++;
  358. } else {
  359. ?>
  360. <ul>
  361. <?php
  362. $cat_args['title_li'] = '';
  363. wp_list_categories(apply_filters('widget_categories_args', $cat_args));
  364. ?>
  365. </ul>
  366. <?php
  367. }
  368.  
  369. echo $after_widget;
  370. }
  371.  
  372. function update( $new_instance, $old_instance ) {
  373. $instance = $old_instance;
  374.  
  375. if ( in_array( $new_instance['orderby'], array( 'order', 'name', 'count', 'ID', 'slug', 'term_group' ) ) ) {
  376. $instance['orderby'] = $new_instance['orderby'];
  377. } else {
  378. $instance['orderby'] = 'order';
  379. }
  380.  
  381. if ( in_array( $new_instance['order'], array( 'asc', 'desc' ) ) ) {
  382. $instance['order'] = $new_instance['order'];
  383. } else {
  384. $instance['order'] = 'asc';
  385. }
  386.  
  387. $instance['title_li'] = strip_tags( $new_instance['title_li'] );
  388. $instance['show_dropdown'] = strip_tags( $new_instance['show_dropdown'] );
  389. $instance['show_last_updated'] = strip_tags( $new_instance['show_last_updated'] );
  390. $instance['show_count'] = strip_tags( $new_instance['show_count'] );
  391. $instance['hide_empty'] = strip_tags( $new_instance['hide_empty'] );
  392. $instance['use_desc_for_title'] = strip_tags( $new_instance['use_desc_for_title'] );
  393. $instance['child_of'] = strip_tags( $new_instance['child_of'] );
  394. $instance['feed'] = strip_tags( $new_instance['feed'] );
  395. $instance['feed_image'] = $new_instance['feed_image'];
  396. $instance['exclude'] = strip_tags( $new_instance['exclude'] );
  397. $instance['exclude_tree'] = strip_tags( $new_instance['exclude_tree'] );
  398. $instance['include'] = strip_tags( $new_instance['include'] );
  399. $instance['hierarchical'] = strip_tags( $new_instance['hierarchical'] );
  400. $instance['number'] = $new_instance['number'];
  401. $instance['depth'] = $new_instance['depth'];
  402.  
  403. return $instance;
  404. }
  405.  
  406. function form( $instance ) {
  407. //Defaults
  408. $instance = wp_parse_args( (array) $instance, array( 'orderby' => 'order', 'order' => 'asc', 'title_li' => '', 'show_dropdown' => '', 'show_last_updated' => '', 'show_count' => '', 'hide_empty' => '1', 'use_desc_for_title' => '1', 'child_of' => '', 'feed' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'include' => '', 'hierarchical' => '1', 'number' => '', 'depth' => '' ) );
  409.  
  410. $orderby = esc_attr( $instance['orderby'] );
  411. $order = esc_attr( $instance['order'] );
  412. $title_li = esc_attr( $instance['title_li'] );
  413.  
  414. $show_dropdown = esc_attr( $instance['show_dropdown'] );
  415. $show_last_updated = esc_attr( $instance['show_last_updated'] );
  416. $show_count = esc_attr( $instance['show_count'] );
  417. $hide_empty = esc_attr( $instance['hide_empty'] );
  418. $use_desc_for_title = esc_attr( $instance['use_desc_for_title'] );
  419. $hierarchical = esc_attr( $instance['hierarchical'] );
  420.  
  421. $child_of = esc_attr( $instance['child_of'] );
  422. $feed = esc_attr( $instance['feed'] );
  423. $feed_image = esc_attr( $instance['feed_image'] );
  424. $exclude = esc_attr( $instance['exclude'] );
  425. $exclude_tree = esc_attr( $instance['exclude_tree'] );
  426. $include = esc_attr( $instance['include'] );
  427.  
  428. $number = esc_attr( $instance['number'] );
  429. $depth = esc_attr( $instance['depth'] );
  430.  
  431. ?>
  432. <p>
  433. <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Order By:', 'mycategoryorder' ); ?></label>
  434. <select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
  435. <option value="order"<?php selected( $instance['orderby'], 'order' ); ?>><?php _e('My Order', 'mycategoryorder'); ?></option>
  436. <option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e('Name', 'mycategoryorder'); ?></option>
  437. <option value="count"<?php selected( $instance['orderby'], 'count' ); ?>><?php _e( 'Count', 'mycategoryorder' ); ?></option>
  438. <option value="ID"<?php selected( $instance['orderby'], 'ID' ); ?>><?php _e( 'ID', 'mycategoryorder' ); ?></option>
  439. <option value="slug"<?php selected( $instance['orderby'], 'slug' ); ?>><?php _e( 'Slug', 'mycategoryorder' ); ?></option>
  440. <option value="term_group"<?php selected( $instance['orderby'], 'term_group' ); ?>><?php _e( 'Term Group', 'mycategoryorder' ); ?></option>
  441. </select>
  442. </p>
  443. <p>
  444. <label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Order:', 'mycategoryorder' ); ?></label>
  445. <select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('category_order'); ?>" class="widefat">
  446. <option value="asc"<?php selected( $instance['order'], 'asc' ); ?>><?php _e('Ascending', 'mycategoryorder'); ?></option>
  447. <option value="desc"<?php selected( $instance['order'], 'desc' ); ?>><?php _e('Descending', 'mycategoryorder'); ?></option>
  448. </select>
  449. </p>
  450. <p>
  451. <label for="<?php echo $this->get_field_id('title_li'); ?>"><?php _e( 'Title:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $title_li; ?>" name="<?php echo $this->get_field_name('title_li'); ?>" id="<?php echo $this->get_field_id('title_li'); ?>" class="widefat" />
  452. <br />
  453. <small><?php _e( 'Default to Categories.', 'mycategoryorder' ); ?></small>
  454. </p>
  455. <p>
  456. <label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />
  457. <br />
  458. <small><?php _e( 'Category IDs, separated by commas.', 'mycategoryorder' ); ?></small>
  459. </p>
  460. <p>
  461. <label for="<?php echo $this->get_field_id('exclude_tree'); ?>"><?php _e( 'Exclude Tree:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $exclude_tree; ?>" name="<?php echo $this->get_field_name('exclude_tree'); ?>" id="<?php echo $this->get_field_id('exclude_tree'); ?>" class="widefat" />
  462. <br />
  463. <small><?php _e( 'Category IDs, separated by commas.', 'mycategoryorder' ); ?></small>
  464. </p>
  465. <p>
  466. <label for="<?php echo $this->get_field_id('include'); ?>"><?php _e( 'Include:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $include; ?>" name="<?php echo $this->get_field_name('include'); ?>" id="<?php echo $this->get_field_id('include'); ?>" class="widefat" />
  467. <br />
  468. <small><?php _e( 'Category IDs, separated by commas.', 'mycategoryorder' ); ?></small>
  469. </p>
  470. <p>
  471. <label for="<?php echo $this->get_field_id('child_of'); ?>"><?php _e( 'Child Of:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $child_of; ?>" name="<?php echo $this->get_field_name('child_of'); ?>" id="<?php echo $this->get_field_id('child_of'); ?>" class="widefat" />
  472. <br />
  473. <small><?php _e( 'Only display children of this Category ID.', 'mycategoryorder' ); ?></small>
  474. </p>
  475. <p>
  476. <label for="<?php echo $this->get_field_id('feed'); ?>"><?php _e( 'Feed Text:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $feed; ?>" name="<?php echo $this->get_field_name('feed'); ?>" id="<?php echo $this->get_field_id('feed'); ?>" class="widefat" />
  477. <br />
  478. <small><?php _e( 'Text for RSS Feed', 'mycategoryorder' ); ?></small>
  479. </p>
  480. <p>
  481. <label for="<?php echo $this->get_field_id('feed_image'); ?>"><?php _e( 'Feed Image:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $feed_image; ?>" name="<?php echo $this->get_field_name('feed_image'); ?>" id="<?php echo $this->get_field_id('feed_image'); ?>" class="widefat" />
  482. <br />
  483. <small><?php _e( 'URL to RSS Image, copy url of this image', 'mycategoryorder' ); ?></small><img src="<?php bloginfo('url'); ?>/wp-includes/images/rss.png" alt="RSS" />
  484. </p>
  485. <p>
  486. <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number to Display:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $number; ?>" name="<?php echo $this->get_field_name('number'); ?>" id="<?php echo $this->get_field_id('number'); ?>" class="widefat" />
  487. <br />
  488. <small><?php _e( 'Max number of categories to display', 'mycategoryorder' ); ?></small>
  489. </p>
  490. <p>
  491. <label for="<?php echo $this->get_field_id('depth'); ?>"><?php _e( 'Depth:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $depth; ?>" name="<?php echo $this->get_field_name('depth'); ?>" id="<?php echo $this->get_field_id('depth'); ?>" class="widefat" />
  492. <br />
  493. <small><?php _e( '0 = All, -1 = Flat, 1 = Top Level Only, n = display n levels', 'mycategoryorder' ); ?></small>
  494. </p>
  495. <p>
  496. <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_dropdown'], true) ?> id="<?php echo $this->get_field_id('show_dropdown'); ?>" name="<?php echo $this->get_field_name('show_dropdown'); ?>" />
  497. <label for="<?php echo $this->get_field_id('show_dropdown'); ?>"><?php _e('Show As Dropdown', 'mycategoryorder'); ?></label><br />
  498. <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_last_updated'], true) ?> id="<?php echo $this->get_field_id('show_last_updated'); ?>" name="<?php echo $this->get_field_name('show_last_updated'); ?>" />
  499. <label for="<?php echo $this->get_field_id('show_last_updated'); ?>"><?php _e('Show Last Updated', 'mycategoryorder'); ?></label><br />
  500. <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_count'], true) ?> id="<?php echo $this->get_field_id('show_count'); ?>" name="<?php echo $this->get_field_name('show_count'); ?>" />
  501. <label for="<?php echo $this->get_field_id('show_count'); ?>"><?php _e('Show Count', 'mycategoryorder'); ?></label><br />
  502. <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hide_empty'], true) ?> id="<?php echo $this->get_field_id('hide_empty'); ?>" name="<?php echo $this->get_field_name('hide_empty'); ?>" />
  503. <label for="<?php echo $this->get_field_id('hide_empty'); ?>"><?php _e('Hide Empty', 'mycategoryorder'); ?></label><br />
  504. <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['use_desc_for_title'], true) ?> id="<?php echo $this->get_field_id('use_desc_for_title'); ?>" name="<?php echo $this->get_field_name('use_desc_for_title'); ?>" />
  505. <label for="<?php echo $this->get_field_id('use_desc_for_title'); ?>"><?php _e('Use Desc as Title', 'mycategoryorder'); ?></label><br />
  506. <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hierarchical'], true) ?> id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>" />
  507. <label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e('Show Hierarchical', 'mycategoryorder'); ?></label><br />
  508. </p>
  509. <?php
  510. }
  511. }
  512.  
  513. function mycategoryorder_widgets_init() {
  514. register_widget('mycategoryorder_Widget');
  515. }
  516.  
  517. add_action('widgets_init', 'mycategoryorder_widgets_init');
  518.  
  519. ?>

Report this snippet  

You need to login to post a comment.