Skip to content

Commit

Permalink
Links (Inline Descriptions) 1.0.1
Browse files Browse the repository at this point in the history
- Renamed from "Links Widget Improved"
- Improve description
- Consistent function naming.
- Update the translation template and add a Finnish translation.
- Use echo instead of print.
  • Loading branch information
knomepasi committed Oct 13, 2016
1 parent 7983538 commit 5bf6fba
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 96 deletions.
Binary file not shown.
@@ -0,0 +1,37 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-13 20:23+0300\n"
"PO-Revision-Date: 2016-10-13 20:24+0300\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7.1\n"
"Last-Translator: Pasi Lallinaho <pasi@shimmerproject.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: fi\n"

#: links-inline-descriptions.php:37
msgctxt "widget name"
msgid "Links (Inline Descriptions)"
msgstr "Linkit (ja selitteet)"

#: links-inline-descriptions.php:39
msgid "Links with inline descriptions."
msgstr "Linkit selitteiden kanssa."

#: links-inline-descriptions.php:74
msgid "Link category:"
msgstr "Linkkien kategoria:"

#: links-inline-descriptions.php:76
msgctxt "widget option"
msgid "-- All link categories --"
msgstr "-- Kaikki linkkikategoriat --"
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-12 12:53+0200\n"
"POT-Creation-Date: 2016-10-13 20:22+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -17,20 +17,20 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../plugins/better-links/better-links.php:35
msgid "Show easy-clickable links with inline descriptions."
#: links-inline-descriptions.php:37
msgctxt "widget name"
msgid "Links (Inline Descriptions)"
msgstr ""

#: ../plugins/better-links/better-links.php:37
msgctxt "widget name"
msgid "Better links"
#: links-inline-descriptions.php:39
msgid "Links with inline descriptions."
msgstr ""

#: ../plugins/better-links/better-links.php:75
#: links-inline-descriptions.php:74
msgid "Link category:"
msgstr ""

#: ../plugins/better-links/better-links.php:77
#: links-inline-descriptions.php:76
msgctxt "widget option"
msgid "All link categories"
msgid "-- All link categories --"
msgstr ""
86 changes: 86 additions & 0 deletions plugins/links-inline-descriptions/links-inline-descriptions.php
@@ -0,0 +1,86 @@
<?php
/*
* Plugin Name: Links (Inline Descriptions)
* Description: A links widget with inline descriptions.
* Author: Pasi Lallinaho
* Version: 1.0.1
* Author URI: http://open.knome.fi/
* Plugin URI: http://wordpress.knome.fi/
*
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
*/

/*
* Load text domain for translations
*
*/

add_action( 'plugins_loaded', 'links_inline_descriptions_init' );

function links_inline_descriptions_init( ) {
load_plugin_textdomain( 'links-inline-descriptions', false, dirname( plugin_basename( FILE ) ) . '/languages/' );
}

/*
* Register the widget
*
*/

add_action( 'widgets_init', function( ) { register_widget( 'links_inline_descriptions_Widget' ); } );

class links_inline_descriptions_Widget extends WP_Widget {
public function __construct( ) {
parent::__construct(
'links-inline-descriptions',
_x( 'Links (Inline Descriptions)', 'widget name', 'links-inline-descriptions' ),
array(
'description' => __( 'Links with inline descriptions.', 'links-inline-descriptions' ),
)
}

public function widget( $args, $instance ) {
extract( $args );
$links = get_bookmarks( array( 'category' => $instance['category'] ) );

if( is_array( $links ) ) {
echo '<div class="links-improved">';
echo $before_widget;
$cat_info = get_term( $instance['category'], 'link_category' );
echo $before_title . $cat_info->name . $after_title;
echo '<ul>';
foreach( $links as $link ) {
echo '<li><a href="' . $link->link_url . '">';
echo '<span class="name">' . $link->link_name . '</span><span class="description">' . $link->link_description . '</span>';
echo '</a></li>';
}
echo '</ul>';
echo $after_widget;
echo '</div>';
}
}

public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['category'] = $new_instance['category'];
return $instance;
}

public function form( $instance ) {
$link_cats = get_terms( 'link_category' );
?>
<p>
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Link category:', 'links-inline-descriptions' ); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>">
<option value=""><?php _ex( '-- All link categories --', 'widget option', 'links-inline-descriptions' ); ?></option>
<?php
foreach( $link_cats as $link_cat ) {
echo '<option value="' . $link_cat->term_id . '" ' . selected( $instance['category'], $link_cat->term_id, false ) . '>' . $link_cat->name . '</option>';
}
?>
</select>
</p>
<?php
}
}
87 changes: 0 additions & 87 deletions plugins/links-widget-improved/links-widget-improved.php

This file was deleted.

0 comments on commit 5bf6fba

Please sign in to comment.