' . __('Order Links') . '',
'' . __('Support Forum') . ' ',
'' . __('Donate') . ' '
));
}
return $links;
}
add_filter( 'plugin_row_meta', 'mylinkorder_set_plugin_meta', 10, 2 );
add_action('admin_menu', 'mylinkorder_menu');
add_action('admin_menu', 'mylinkorder_js_libs');
function mylinkorder()
{
global $wpdb;
$mode = "";
$mode = $_GET['mode'];
$success = "";
$catID = "";
if(isset($_GET['hideNote']))
update_option('mylinkorder_hideNote', '1');
$wpdb->show_errors();
$query1 = $wpdb->query("SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order'");
if ($query1 == 0)
$wpdb->query("ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT '0'");
$query2 = $wpdb->query("SHOW COLUMNS FROM $wpdb->links LIKE 'link_order'");
if ($query2 == 0)
$wpdb->query("ALTER TABLE $wpdb->links ADD `link_order` INT( 4 ) NULL DEFAULT '0'");
if($mode == "act_OrderCategories")
{
$idString = $_GET['idString'];
$catIDs = explode(",", $idString);
$result = count($catIDs);
for($i = 0; $i <= $result; $i++)
$wpdb->query("UPDATE $wpdb->terms SET term_order = '$i' WHERE term_id ='$catIDs[$i]'");
$success = '
'. __('Link Categories updated successfully.', 'mylinkorder').'
';
}
if($mode == "act_OrderLinks")
{
$idString = $_GET['idString'];
$linkIDs = explode(",", $idString);
$result = count($linkIDs);
for($i = 0; $i <= $result; $i++)
$wpdb->query("UPDATE $wpdb->links SET link_order = '$i' WHERE link_id ='$linkIDs[$i]'");
$success = ''. __('Links updated successfully.', 'mylinkorder').'
';
$mode = "dsp_OrderLinks";
}
if($mode == "dsp_OrderLinks")
{
$catID = $_GET['catID'];
$results=$wpdb->get_results("SELECT * FROM $wpdb->links l inner join $wpdb->term_relationships tr on l.link_id = tr.object_id inner join $wpdb->term_taxonomy tt on tt.term_taxonomy_id = tr.term_taxonomy_id inner join $wpdb->terms t on t.term_id = tt.term_id WHERE t.term_id = $catID ORDER BY link_order ASC");
$cat_name = $wpdb->get_var("SELECT name FROM $wpdb->terms WHERE term_id=$catID");
?>
get_results("SELECT DISTINCT t.term_id, name FROM $wpdb->term_taxonomy tt inner join $wpdb->term_relationships tr on tt.term_taxonomy_id = tr.term_taxonomy_id inner join $wpdb->terms t on t.term_id = tt.term_id where taxonomy = 'link_category' ORDER BY t.term_order ASC");
?>
'widget_mylinkorder', 'description' => __( 'Enhanced Link widget provided by My Link Order') );
$this->WP_Widget('mylinkorder', __('My Link Order'), $widget_ops); }
function widget( $args, $instance ) {
extract( $args );
$title_li = apply_filters('widget_title', empty( $instance['title_li'] ) ? __( 'Bookmarks' ) : $instance['title_li']);
$category_orderby = empty( $instance['category_orderby'] ) ? 'order' : $instance['category_orderby'];
$category_order = empty( $instance['category_order'] ) ? 'asc' : $instance['category_order'];
$orderby = empty( $instance['orderby'] ) ? 'order' : $instance['orderby'];
$order = empty( $instance['order'] ) ? 'asc' : $instance['order'];
$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
$include = empty( $instance['include'] ) ? '' : $instance['include'];
$category = empty( $instance['category'] ) ? '' : $instance['category'];
$exclude_category = empty( $instance['exclude_category'] ) ? '' : $instance['exclude_category'];
$limit = empty( $instance['limit'] ) ? '-1' : $instance['limit'];
$categorize = empty( $instance['categorize'] ) ? '1' : '0';
$show_images = empty( $instance['show_images'] ) ? '0' : $instance['show_images'];
$show_description = empty( $instance['show_description'] ) ? '0' : $instance['show_description'];
$show_name = empty( $instance['show_name'] ) ? '0' : $instance['show_name'];
$show_rating = empty( $instance['show_rating'] ) ? '0' : $instance['show_rating'];
$show_updated = empty( $instance['show_updated'] ) ? '0' : $instance['show_updated'];
$hide_invisible = empty( $instance['hide_invisible'] ) ? '1' : '0';
$between = empty( $instance['between'] ) ? "\n" : $instance['between'];
$link_before = empty( $instance['link_before'] ) ? '' : $instance['link_before'];
$link_after = empty( $instance['link_after'] ) ? '' : $instance['link_after'];
$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
wp_list_bookmarks(apply_filters('widget_links_args', array('title_before' => $before_title, 'title_after' => $after_title, 'class' => 'linkcat widget',
'category_before' => $before_widget, 'category_after' => $after_widget, 'exclude' => $exclude, 'include' => $include,
'title_li' => $title_li, 'category_orderby' => $category_orderby, 'category_order' => $category_order, 'orderby' => $orderby, 'order' => $order,
'category' => $category, 'exclude_category' => $exclude_category, 'limit' => $limit, 'categorize' => $categorize,
'show_images' => $show_images, 'show_description' => $show_description, 'show_name' => $show_name,
'show_rating' => $show_rating, 'show_updated' => $show_updated, 'hide_invisible' => $hide_invisible, 'between' => $between,
'link_before' => $link_before, 'link_after' => $link_after
)));
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
if ( in_array( $new_instance['category_orderby'], array( 'order', 'name', 'count', 'ID', 'slug' ) ) ) {
$instance['category_orderby'] = $new_instance['category_orderby'];
} else {
$instance['category_orderby'] = 'order';
}
if ( in_array( $new_instance['category_order'], array( 'asc', 'desc' ) ) ) {
$instance['category_order'] = $new_instance['category_order'];
} else {
$instance['category_order'] = 'asc';
}
if ( in_array( $new_instance['orderby'], array( 'order', 'name', 'rand', 'ID', 'description', 'length', 'notes', 'owner', 'rel', 'rss', 'target', 'updated', 'url' ) ) ) {
$instance['orderby'] = $new_instance['orderby'];
} else {
$instance['orderby'] = 'order';
}
if ( in_array( $new_instance['order'], array( 'asc', 'desc' ) ) ) {
$instance['order'] = $new_instance['order'];
} else {
$instance['order'] = 'asc';
}
$instance['title_li'] = strip_tags( $new_instance['title_li'] );
$instance['exclude'] = strip_tags( $new_instance['exclude'] );
$instance['include'] = strip_tags( $new_instance['include'] );
$instance['category'] = strip_tags( $new_instance['category'] );
$instance['exclude_category'] = strip_tags( $new_instance['exclude_category'] );
$instance['limit'] = strip_tags( $new_instance['limit'] );
$instance['categorize'] = strip_tags( $new_instance['categorize'] );
$instance['show_images'] = strip_tags( $new_instance['show_images'] );
$instance['show_description'] = strip_tags( $new_instance['show_description'] );
$instance['show_name'] = strip_tags( $new_instance['show_name'] );
$instance['show_rating'] = strip_tags( $new_instance['show_rating'] );
$instance['show_updated'] = strip_tags( $new_instance['show_updated'] );
$instance['hide_invisible'] = strip_tags( $new_instance['hide_invisible'] );
$instance['between'] = $new_instance['between'];
$instance['link_before'] = $new_instance['link_before'];
$instance['link_after'] = $new_instance['link_after'];
return $instance;
}
function form( $instance ) {
//Defaults
$instance = wp_parse_args( (array) $instance, array( 'categorize' => '','category' => '', 'category_orderby' => 'order', 'category_order' => 'asc', '_orderby' => 'order', 'order' => 'asc', 'exclude' => '', 'exclude_category' => '', 'include' => '', 'limit' => '', 'title_li' => '', 'link_before' => '', 'link_after' => '', 'between' => '', 'show_images' => '', 'show_description' => '', 'show_name' => '', 'show_rating' => '', 'show_updated' => '', 'hide_invisible' => '' ) );
$categorize = esc_attr( $instance['categorize'] );
$category = esc_attr( $instance['category'] );
$category_orderby = esc_attr( $instance['category_orderby'] );
$category_order = esc_attr( $instance['category_order'] );
$orderby = esc_attr( $instance['orderby'] );
$order = esc_attr( $instance['order'] );
$exclude_category = esc_attr( $instance['exclude_category'] );
$title_li = esc_attr( $instance['title_li'] );
$include = esc_attr( $instance['include'] );
$exclude = esc_attr( $instance['exclude'] );
$limit = esc_attr( $instance['limit'] );
$link_before = esc_attr( $instance['link_before'] );
$link_after = esc_attr( $instance['link_after'] );
$between = esc_attr( $instance['between'] );
$show_images = esc_attr( $instance['show_images'] );
$show_description = esc_attr( $instance['show_description'] );
$show_name = esc_attr( $instance['show_name'] );
$show_rating = esc_attr( $instance['show_rating'] );
$show_updated = esc_attr( $instance['show_updated'] );
$hide_invisible = esc_attr( $instance['hide_invisible'] );
?>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
id="get_field_id('categorize'); ?>" name="get_field_name('categorize'); ?>" />
id="get_field_id('show_images'); ?>" name="get_field_name('show_images'); ?>" />
id="get_field_id('show_name'); ?>" name="get_field_name('show_name'); ?>" />
id="get_field_id('show_description'); ?>" name="get_field_name('show_description'); ?>" />
id="get_field_id('show_rating'); ?>" name="get_field_name('show_rating'); ?>" />
id="get_field_id('show_updated'); ?>" name="get_field_name('show_updated'); ?>" />
id="get_field_id('hide_invisible'); ?>" name="get_field_name('hide_invisible'); ?>" />