From: danix Date: Mon, 1 Oct 2018 11:10:16 +0000 (+0200) Subject: fixed readme and changed stable version to 0.1 to publish to WP.org directory X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=danixland-wporg-stats.git fixed readme and changed stable version to 0.1 to publish to WP.org directory --- diff --git a/danixland-wporg-stats.php b/danixland-wporg-stats.php index bad3d5c..f904dff 100644 --- a/danixland-wporg-stats.php +++ b/danixland-wporg-stats.php @@ -324,4 +324,122 @@ class dnx_WPOrg extends WP_Widget { } } +// Add Shortcode +function dnxwporg_stats_shortcode() { + + $author = sanitize_user(get_option('dnxwporg_author'), true); + $description = get_option('dnxwporg_description'); + $desc_content = get_option('dnxwporg_desc_content'); + $linkto = get_option('dnxwporg_linkto'); + $use_icons = get_option('dnxwporg_use_icons'); + + /* we recover the data from the option if it is set, otherwhise we call the retrieve function directly */ + $option_stats = get_option('dnxwporg_plugins_stats'); + $plugins = ( false === $option_stats ? dnxwporg_get_plugins_stats() : $option_stats ); + + ob_start(); ?> + +
+ +
+ +

%s plugin with %s total downloads and an average rating of %s', '%s contributed %s plugins with %s total downloads and an average rating of %s', $plugins['total_plugins'], 'dnxwporg' ), $author, $plugins['total_plugins'], $plugins['total_downloads'], $plugins['average_rating'] ); ?>

+ +

+ +
+ +
+
    + $data) { + if (is_array($data) ) : ?> +
  • + + + <?php echo $name; ?> + + + +

    + + +

    +
  • + +
+
+
+ + 0, + 'avg_dloads' => 0, + 'pl_count' => 0, + ), + $atts + ); + + /* we recover the data from the option if it is set, otherwhise we call the retrieve function directly */ + $option_stats = get_option('dnxwporg_plugins_stats'); + $plugins = ( false === $option_stats ? dnxwporg_get_plugins_stats() : $option_stats ); + + // Build the $output variable + $output = ""; + + if ($a['total_dl']) { + $output = $plugins['total_downloads']; + } elseif ($a['avg_dloads']) { + $output = $plugins['average_rating']; + } elseif ($a['pl_count']) { + $output = $plugins['total_plugins']; + } + + return $output; + +} +add_shortcode( 'dnxwporg_single_stat', 'dnxwporg_single_stats_shortcode' ); + +/** + * Shortcode that returns the plugin icon if existing + */ +function dnxwporg_plugin_icon( $atts ) { + + // Attributes + $a = shortcode_atts( + array( + 'plugin_name' => '', + ), + $atts + ); + + /* we recover the data from the option if it is set, otherwhise we call the retrieve function directly */ + $option_stats = get_option('dnxwporg_plugins_stats'); + $plugins = ( false === $option_stats ? dnxwporg_get_plugins_stats() : $option_stats ); + + $name = $a['plugin_name']; + + // Build the $output variable + $output = ""; + + if (array_key_exists($name, $plugins) && ! empty($plugins[$name]['icon'])) { + $output = $plugins[$name]['icon']; + } else { + $output = ""; + } + + return $output; + +} +add_shortcode( 'plugin_icon', 'dnxwporg_plugin_icon' ); ?> diff --git a/readme.txt b/readme.txt index 16dee62..cc98f3d 100644 --- a/readme.txt +++ b/readme.txt @@ -4,15 +4,16 @@ Donate link: http://danix.xyz Tags: widget, sidebar, links, plugins, list Requires at least: 4.6 Tested up to: 4.9.7 -Stable tag: 1.0 +Stable tag: 0.1 This widget will display a list of plugins by the same author hosted on the WordPress.org plugins directory. == Description == -danixland-wporg.stats is a plugin that adds a new widget to be used on the Sidebar (or wherever you like). +danixland-wporg.stats is a plugin that adds a new widget to be used on the Sidebar (or wherever you like) and some useful shortcodes. This widget will show a list of plugins by the same author, hosted on the WordPress Plugins directory. It uses the wordpress.org API to fetch all the details and it's able to show links to the plugin page on wordpress.org or to the URI specified by the author inside the plugin itself. Other stats displayed by the plugin are the total number of downloads for all the plugins, average rating per plugin and total average. Soon the plugin will be able to display even more stats. If an author has used the assets directory to store the plugin's icons, danixland-wporg-stats is able to fetch and display the icons as well. +The plugin ships with a few shortcodes to embed your stats inside your posts or pages. You can use it on a landing page for your plugins or, like I do, inside a custom post type page to display stats about the plugins I write. == Installation == @@ -38,11 +39,21 @@ Contained in that element you'll find a div with the description and following t Here's every single id and class used in this plugin: * `.widget_danixland-wporg-stats` -* `.dnxwporg_container` -* `.dnxwporg_description` -* `.dnxwporg-pl-count` -* `.dnxwporg-pl-dloads` -* `.dnxwporg-pl-link-desc` + * `.dnxwporg_container` + * `.dnxwporg_description` + * `.dnxwporg-pl-standard-desc` + * `.dnxwporg-pl-custom-desc` + * `.dnxwporg_pl_list_container` + * `.dnxwporg_pl_list` + * `.dnxwporg_pl_item` + * `.dnxwporg-pl-link` + * `.dnxwporg-pl-link-icon` + * `.dnxwporg-pl-link-name` + * `.dnxwporg-pl-stats` + * `.dnxwporg-pl-tot-dloads` + * `.dnxwporg-pl-avg-vote` + +This plugin ships with no styling on pourpose, it's up to you to add the styling needed for it to look at it's best on your pages. = I'm stuck with your plugin and don't seem to be able to customize it/make it work, can you help me? = @@ -50,9 +61,7 @@ Of course, you can ask for help on [the forums](http://wordpress.org/support/) o = I'd like this plugin to be translated in my language, can you do this for me? = -This plugin ships with a .POT file that can be used to create a translation of the plugin in your language, so if you're familiar with english you can help by providing a translation and it will be added to future versions of the plugin along with a link to your site on these pages ;) - -To provide a translation simply edit the file "danixland-wporg.stats.pot" and fill every line with the traduction in your language, then save it as *yourlanguagecode.po* (E.G. it_IT.po for Italian), then contact me via the forums or my site and I'll tell you how to send this file to me. I'll add your translation ASAP. +Soon I'll publish a .POT file that can be used to create a translation of the plugin in your language, so if you're familiar with english you can help by providing a translation and it will be added to future versions of the plugin along with a link to your site on these pages ;) A number of softwares exists to help you with .po files, like [POEdit](http://sourceforge.net/projects/poedit/) or [Lokalize](http://userbase.kde.org/Lokalize "for kde users") @@ -61,24 +70,27 @@ A number of softwares exists to help you with .po files, like [POEdit](http://so == Screenshots == 1. The plugin widget as seen in the admin area. -2. The widget with standard description as seen in the twentysixteen theme. -3. The widget rocking a custom description. +2. The widget with standard description as seen in the TwentySeventeen theme without any styling. +3. The widget In my custom theme with styling added to it. +3. The widget In my custom theme with a custom description. == Changelog == -= 1.0 = += 0.1 = * This is the first version of the plugin. == Upgrade Notice == -= 1.0 = += 0.1 = No upgrade since this is the first version ;) == ToDo list == -* I'll work on supporting themes as well. -* custom tags inside the description -* average downloads and more stats coming soon +* .POT file to allow translators to translate the plugin. +* bugfixing. +* theme directory support. +* custom tags inside the description. +* average downloads and more stats coming soon... * I'm open to suggestions, so don't be shy.