checkDbSchema(); } private function checkDbSchema() { //Copied across from knrAuthorList_init global $wpdb; $wpdb->show_errors(); $query1 = $wpdb->query("SHOW COLUMNS FROM $wpdb->users LIKE 'knr_author_order'"); if ($query1 == 0) { $wpdb->query("ALTER TABLE $wpdb->users ADD `knr_author_order` INT( 4 ) NULL DEFAULT '0'"); } } private function checkForSkip($pattern, $currUrl) { if (!$pattern) return false; return ereg($pattern, $currUrl); } public function widget($args, $instance) { if (!isset($knral_defaults)) global $knral_defaults; $instance = wp_parse_args($instance, $knral_defaults); $options = $instance; //if ($instance == null || count($instance) == 0) { // $options = get_option('widget_knrAuthorList'); //supporting legacy code //} $retValSkip = $this->checkForSkip($options['noShowUrlFilter'], $_SERVER['REQUEST_URI']); if ($retValSkip === 1) { return; } extract($args); echo $before_widget; echo $before_title; echo $options['title']; echo $after_title; writeMarkup_knrAuthorList($options); echo $after_widget; } public function update($new_instance, $old_instance) { if (!isset($knral_defaults)) global $knral_defaults; $instance = wp_parse_args($old_instance, $knral_defaults); foreach($instance as $i_key => $i_val) { if (is_bool($instance[$i_key])) $instance[$i_key] = isset($new_instance[$i_key])?true:false; else $instance[$i_key] = isset($new_instance[$i_key])?$new_instance[$i_key]:null; } return $instance; } public function form($instance) { //if ($instance == null || count($instance) == 0) { // $instance = get_option('widget_knrAuthorList'); //supporting legacy code //} if (!isset($knral_defaults)) global $knral_defaults; $instance = wp_parse_args($instance, $knral_defaults); $title = esc_attr(htmlspecialchars($instance['title'], ENT_QUOTES)); $title_fieldId = $this->get_field_id('title'); $title_fieldName = $this->get_field_name('title'); $includeAuthorsWoPosts = esc_attr(htmlspecialchars($instance['includeAuthorsWoPosts'], ENT_QUOTES)); $includeAuthorsWoPosts_fieldId = $this->get_field_id('includeAuthorsWoPosts'); $includeAuthorsWoPosts_fieldName = $this->get_field_name('includeAuthorsWoPosts'); $includeContributors = esc_attr(htmlspecialchars($instance['includeContributors'], ENT_QUOTES)); $includeContributors_fieldId = $this->get_field_id('includeContributors'); $includeContributors_fieldName = $this->get_field_name('includeContributors'); $includeAdmin = esc_attr(htmlspecialchars($instance['includeAdmin'], ENT_QUOTES)); $includeAdmin_fieldId = $this->get_field_id('includeAdmin'); $includeAdmin_fieldName = $this->get_field_name('includeAdmin'); $includeEditors = esc_attr(htmlspecialchars($instance['includeEditors'], ENT_QUOTES)); $includeEditors_fieldId = $this->get_field_id('includeEditors'); $includeEditors_fieldName = $this->get_field_name('includeEditors'); $authorLimit = esc_attr(htmlspecialchars($instance['authorLimit'], ENT_QUOTES)); $authorLimit_fieldId = $this->get_field_id('authorLimit'); $authorLimit_fieldName = $this->get_field_name('authorLimit'); $sortOrder = esc_attr(htmlspecialchars($instance['sort'], ENT_QUOTES)); $sortOrder_fieldId = $this->get_field_id('sort'); $sortOrder_fieldName = $this->get_field_name('sort'); $sortOrderReverse = esc_attr(htmlspecialchars($instance['sortReverse'], ENT_QUOTES)); $sortOrderReverse_fieldId = $this->get_field_id('sortReverse'); $sortOrderReverse_fieldName = $this->get_field_name('sortReverse'); $unorderedListClass = esc_attr(htmlspecialchars($instance['unorderedListClass'], ENT_QUOTES)); $unorderedListClass_fieldId = $this->get_field_id('unorderedListClass'); $unorderedListClass_fieldName = $this->get_field_name('unorderedListClass'); $listItemClass = esc_attr(htmlspecialchars($instance['listItemClass'], ENT_QUOTES)); $listItemClass_fieldId = $this->get_field_id('listItemClass'); $listItemClass_fieldName = $this->get_field_name('listItemClass'); $spanCountClass = esc_attr(htmlspecialchars($instance['spanCountClass'], ENT_QUOTES)); $spanCountClass_fieldId = $this->get_field_id('spanCountClass'); $spanCountClass_fieldName = $this->get_field_name('spanCountClass'); $spanAuthorClass = esc_attr(htmlspecialchars($instance['spanAuthorClass'], ENT_QUOTES)); $spanAuthorClass_fieldId = $this->get_field_id('spanAuthorClass'); $spanAuthorClass_fieldName = $this->get_field_name('spanAuthorClass'); $authorLinkClass = esc_attr(htmlspecialchars($instance['authorLinkClass'], ENT_QUOTES)); $authorLinkClass_fieldId = $this->get_field_id('authorLinkClass'); $authorLinkClass_fieldName = $this->get_field_name('authorLinkClass'); $showCount = esc_attr(htmlspecialchars($instance['showCount'], ENT_QUOTES)); $showCount_fieldId = $this->get_field_id('showCount'); $showCount_fieldName = $this->get_field_name('showCount'); $countBeforeName = esc_attr(htmlspecialchars($instance['countBeforeName'], ENT_QUOTES)); $countBeforeName_fieldId = $this->get_field_id('countBeforeName'); $countBeforeName_fieldName = $this->get_field_name('countBeforeName'); $moreAuthorsLink = esc_attr(htmlspecialchars($instance['moreAuthorsLink'], ENT_QUOTES)); $moreAuthorsLink_fieldId = $this->get_field_id('moreAuthorsLink'); $moreAuthorsLink_fieldName = $this->get_field_name('moreAuthorsLink'); $moreAuthorsText = esc_attr(htmlspecialchars($instance['moreAuthorsText'], ENT_QUOTES)); $moreAuthorsText_fieldId = $this->get_field_id('moreAuthorsText'); $moreAuthorsText_fieldName = $this->get_field_name('moreAuthorsText'); $showAvatarMode = esc_attr(htmlspecialchars($instance['showAvatarMode'], ENT_QUOTES)); $showAvatarMode_fieldId = $this->get_field_id('showAvatarMode'); $showAvatarMode_fieldName = $this->get_field_name('showAvatarMode'); $showAsDropdown = esc_attr(htmlspecialchars($instance['showAsDropdown'], ENT_QUOTES)); $showAsDropdown_fieldId = $this->get_field_id('showAsDropdown'); $showAsDropdown_fieldName = $this->get_field_name('showAsDropdown'); $dropdownUnselectedText = esc_attr(htmlspecialchars($instance['dropdownUnselectedText'], ENT_QUOTES)); $dropdownUnselectedText_fieldId = $this->get_field_id('dropdownUnselectedText'); $dropdownUnselectedText_fieldName = $this->get_field_name('dropdownUnselectedText'); $showAsOrderedList = esc_attr(htmlspecialchars($instance['showAsOrderedList'], ENT_QUOTES)); $showAsOrderedList_fieldId = $this->get_field_id('showAsOrderedList'); $showAsOrderedList_fieldName = $this->get_field_name('showAsOrderedList'); $noShowUrlFilter = esc_attr(htmlspecialchars($instance['noShowUrlFilter'], ENT_QUOTES)); $noShowUrlFilter_fieldId = $this->get_field_id('noShowUrlFilter'); $noShowUrlFilter_fieldName = $this->get_field_name('noShowUrlFilter'); echo '
General Options
'; echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo '
Enter -1 or 0 for no limit
Leave blank for no "more" link
'; echo '
'; echo '
With "Custom" sort order, you have to go to the "KNR Author List" setting page to manually set the sort order
Reverses the sort order set by "Sort with"
'; echo '
'; echo '
'; echo '
'; echo '
Markup Options
'; echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; } } add_action('widgets_init', create_function('', 'return register_widget(\'knrAuthorListWidget\');')); ?>