Skip to content

Commit

Permalink
fix: dashboard widget issues and recommended module inconsistency fix
Browse files Browse the repository at this point in the history
…#50, #49, #47
  • Loading branch information
selul committed Mar 7, 2019
1 parent 9e17427 commit 757eb02
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 167 deletions.
64 changes: 0 additions & 64 deletions assets/css/upsell.css

This file was deleted.

2 changes: 1 addition & 1 deletion src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class Loader {
'logger',
'translate',
'review',
'upsell',
'recommendation',

];

Expand Down
33 changes: 22 additions & 11 deletions src/Modules/Dashboard_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function add_widget() {
'themeisle',
$this->dashboard_name,
[
&$this,
$this,
'render_dashboard_widget',
]
);
Expand Down Expand Up @@ -281,6 +281,8 @@ class="ti-dw-month-container"><?php echo substr( date( 'M', $item['date'] ), 0,
array(
'lite',
'Lite',
'(Lite)',
'(lite)',
),
'',
$recommend['name']
Expand Down Expand Up @@ -372,30 +374,39 @@ function recommend_plugin_or_theme() {
*/
function get_product_from_api() {
if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) {
$products = array();
$themeisle_themes = $this->get_themes_from_wporg( 'themeisle' );
$codeinwp_themes = $this->get_themes_from_wporg( 'codeinwp' );

$themeisle_plugins = $this->get_plugins_from_wporg( 'themeisle' );
$codeinwp_plugins = $this->get_plugins_from_wporg( 'codeinwp' );

$all_themes = array_merge( $themeisle_themes, $codeinwp_themes );
$products = array();
$all_themes = $this->get_themes_from_wporg( 'themeisle' );
$all_plugins = $this->get_plugins_from_wporg( 'themeisle' );
static $allowed_products = [
'hestia' => true,
'neve' => true,
'visualizer' => true,
'feedzy-rss-feeds' => true,
'wp-product-review' => true,
'otter-blocks' => true,
'themeisle-companion' => true,
];
foreach ( $all_themes as $theme ) {
if ( $theme->active_installs < 4999 ) {
continue;
}
if ( ! isset( $allowed_products[ $theme->slug ] ) ) {
continue;
}
$products[] = array(
'name' => $theme->name,
'type' => 'theme',
'slug' => $theme->slug,
'installs' => $theme->active_installs,
);
}
$all_plugins = array_merge( $themeisle_plugins, $codeinwp_plugins );
foreach ( $all_plugins as $plugin ) {
if ( $plugin->active_installs < 4999 ) {
continue;
}
if ( ! isset( $allowed_products[ $plugin->slug ] ) ) {
continue;
}
$products[] = array(
'name' => $plugin->name,
'type' => 'plugin',
Expand Down Expand Up @@ -439,7 +450,7 @@ function get_themes_from_wporg( $author ) {
*/
function get_plugins_from_wporg( $author ) {
$products = wp_remote_get(
'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=20&request[fields][active_installs]=true'
'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true'
);
$products = json_decode( wp_remote_retrieve_body( $products ) );
if ( is_object( $products ) ) {
Expand Down
Loading

0 comments on commit 757eb02

Please sign in to comment.