PageRenderTime 54ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/transposh-translation-filter-for-wordpress/widgets/dropdown/tpw_image_dropdown.php

https://bitbucket.org/lgorence/quickpress
PHP | 56 lines | 18 code | 9 blank | 29 comment | 0 complexity | 077d16d64d89aa7f41f7a621c66db97f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /*
  3. Plugin Name: Dropdown selection with image
  4. Plugin URI: http://transposh.org/
  5. Description: A widget using javascript to present a dropdown selection box with images - adapted from: http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.asp
  6. Author: Team Transposh
  7. Version: 1.0
  8. Author URI: http://transposh.org/
  9. License: GPL (http://www.gnu.org/licenses/gpl.txt)
  10. */
  11. /*
  12. * Transposh v0.8.3
  13. * http://transposh.org/
  14. *
  15. * Copyright 2012, Team Transposh
  16. * Licensed under the GPL Version 2 or higher.
  17. * http://transposh.org/license
  18. *
  19. * Date: Mon, 28 May 2012 14:38:35 +0300
  20. */
  21. class tpw_image_dropdown extends transposh_base_widget {
  22. /**
  23. * This function makes sure that the jquery dependency will be met
  24. * @global transposh_plugin $my_transposh_plugin
  25. */
  26. static function tp_widget_js($file, $dir, $url) {
  27. wp_enqueue_script("transposh_widget", "$url/widgets/dropdown/tpw_image_dropdown.js", array('jquery'), TRANSPOSH_PLUGIN_VER);
  28. }
  29. /**
  30. * This function does the actual HTML for the widget
  31. * @param array $args - http://trac.transposh.org/wiki/WidgetWritingGuide#functiontp_widgets_doargs
  32. */
  33. static function tp_widget_do($args) {
  34. global $my_transposh_plugin;
  35. // we calculate the plugin path part, so we can link the images there
  36. $plugpath = parse_url($my_transposh_plugin->transposh_plugin_url, PHP_URL_PATH);
  37. echo '<dl id="tp_dropdown" class="dropdown">';
  38. /* TRANSLATORS: this is what appears in the select box in dropdown subwidget */
  39. echo '<dt><a href="#"><span>' . __('Select language', TRANSPOSH_TEXT_DOMAIN) . '</span></a></dt><dd><ul class="' . NO_TRANSLATE_CLASS . '">';
  40. foreach ($args as $langrecord) {
  41. $is_selected = $langrecord['active'] ? " selected=\"selected\"" : "";
  42. echo '<li><a href="#"><img class="flag" src="' . "$plugpath/img/flags/{$langrecord['flag']}" . '.png" alt="' . $langrecord['langorig'] . '"/> ' . $langrecord['langorig'] . '<span class="value">' . $langrecord['url'] . '</span></a></li>';
  43. }
  44. echo '</ul></dd></dl>';
  45. }
  46. }
  47. ?>