$plugin ) { if ( ! array_key_exists( 'copy', $plugins[ $key ] ) ) { $api = plugins_api( 'plugin_information', array( 'slug' => $plugin['product'], 'fields' => array( 'short_description' => true, ), ) ); if ( is_wp_error( $api ) ) { continue; } $plugins[ $key ]['copy'] = $api->short_description; } } $plugins_data = array( 'recommendations' => $plugins, 'updated' => time(), ); set_transient( self::RECOMMENDED_PLUGINS_TRANSIENT, $plugins_data, // Expire transient in 15 minutes if remote get failed. // Cache an empty result to avoid repeated failed requests. empty( $plugins ) ? 900 : 3 * DAY_IN_SECONDS ); } return array_values( $plugins_data['recommendations'] ); } /** * Should recommendations be displayed? * * @return bool */ private function allow_recommendations() { // Suggestions are only displayed if user can install plugins. if ( ! current_user_can( 'install_plugins' ) ) { return false; } // Suggestions may be disabled via a setting under Accounts & Privacy. if ( 'no' === get_option( 'woocommerce_show_marketplace_suggestions', 'yes' ) ) { return false; } // User can disabled all suggestions via filter. return apply_filters( 'woocommerce_allow_payment_recommendations', true ); } }