← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Recommendation.php
+52
-12
3.10.13
→
3.4.9
View file →
| @@ -63,9 +63,9 @@ | ||
| 63 | 63 | * @param array $themes_list - list of useful themes (in slug => nicename format). |
| 64 | 64 | * @param array $strings - list of translated strings. |
| 65 | 65 | * @param array $preferences - list of preferences. |
| 66 | 66 | */ |
| 67 | - public function render_products_box( $plugins_list, $themes_list, $strings, $preferences = array() ) { | |
| 67 | + function render_products_box( $plugins_list, $themes_list, $strings, $preferences = array() ) { | |
| 68 | 68 | |
| 69 | 69 | if ( empty( $plugins_list ) && empty( $themes_list ) ) { |
| 70 | 70 | return; |
| 71 | 71 | } |
| @@ -89,9 +89,9 @@ | ||
| 89 | 89 | echo '<div class="recommend-product">'; |
| 90 | 90 | |
| 91 | 91 | foreach ( $list as $theme ) { |
| 92 | 92 | echo '<div class="plugin_box">'; |
| 93 | - echo ' <img class="theme-banner" src="' . esc_url( $theme->screenshot_url ) . '">'; | |
| 93 | + echo ' <img class="theme-banner" src="' . $theme->screenshot_url . '">'; | |
| 94 | 94 | echo ' <div class="title-action-wrapper">'; |
| 95 | 95 | echo ' <span class="plugin-name">' . esc_html( $theme->custom_name ) . '</span>'; |
| 96 | 96 | if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) { |
| 97 | 97 | echo '<span class="plugin-desc">' . esc_html( substr( $theme->description, 0, strpos( $theme->description, '.' ) ) ) . '.</span>'; |
| @@ -117,9 +117,9 @@ | ||
| 117 | 117 | echo '<div class="recommend-product">'; |
| 118 | 118 | |
| 119 | 119 | foreach ( $list as $current_plugin ) { |
| 120 | 120 | echo '<div class="plugin_box">'; |
| 121 | - echo ' <img class="plugin-banner" src="' . esc_url( $current_plugin->custom_image ) . '">'; | |
| 121 | + echo ' <img class="plugin-banner" src="' . $current_plugin->custom_image . '">'; | |
| 122 | 122 | echo ' <div class="title-action-wrapper">'; |
| 123 | 123 | echo ' <span class="plugin-name">' . esc_html( $current_plugin->custom_name ) . '</span>'; |
| 124 | 124 | if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) { |
| 125 | 125 | echo '<span class="plugin-desc">' . esc_html( substr( $current_plugin->short_description, 0, strpos( $current_plugin->short_description, '.' ) ) ) . '. </span>'; |
| @@ -184,9 +184,9 @@ | ||
| 184 | 184 | if ( false !== $theme ) { |
| 185 | 185 | return $theme; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $products = $this->safe_get( | |
| 188 | + $products = wp_remote_get( | |
| 189 | 189 | 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[theme]=' . $slug . '&request[per_page]=1' |
| 190 | 190 | ); |
| 191 | 191 | $products = json_decode( wp_remote_retrieve_body( $products ) ); |
| 192 | 192 | if ( is_object( $products ) ) { |
| @@ -238,8 +238,51 @@ | ||
| 238 | 238 | return $list; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
| 242 | + * Call plugin api | |
| 243 | + * | |
| 244 | + * @param string $slug plugin slug. | |
| 245 | + * | |
| 246 | + * @return array|mixed|object | |
| 247 | + */ | |
| 248 | + private function call_plugin_api( $slug ) { | |
| 249 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); | |
| 250 | + | |
| 251 | + $call_api = get_transient( 'ti_plugin_info_' . $slug ); | |
| 252 | + | |
| 253 | + if ( false === $call_api ) { | |
| 254 | + $call_api = plugins_api( | |
| 255 | + 'plugin_information', | |
| 256 | + array( | |
| 257 | + 'slug' => $slug, | |
| 258 | + 'fields' => array( | |
| 259 | + 'downloaded' => false, | |
| 260 | + 'rating' => false, | |
| 261 | + 'description' => false, | |
| 262 | + 'short_description' => true, | |
| 263 | + 'donate_link' => false, | |
| 264 | + 'tags' => false, | |
| 265 | + 'sections' => true, | |
| 266 | + 'homepage' => true, | |
| 267 | + 'added' => false, | |
| 268 | + 'last_updated' => false, | |
| 269 | + 'compatibility' => false, | |
| 270 | + 'tested' => false, | |
| 271 | + 'requires' => false, | |
| 272 | + 'downloadlink' => false, | |
| 273 | + 'icons' => true, | |
| 274 | + 'banners' => true, | |
| 275 | + ), | |
| 276 | + ) | |
| 277 | + ); | |
| 278 | + set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS ); | |
| 279 | + } | |
| 280 | + | |
| 281 | + return $call_api; | |
| 282 | + } | |
| 283 | + | |
| 284 | + /** | |
| 242 | 285 | * Load css and scripts for the plugin recommend page. |
| 243 | 286 | */ |
| 244 | 287 | public function enqueue() { |
| 245 | 288 | $screen = get_current_screen(); |
| @@ -259,32 +302,29 @@ | ||
| 259 | 302 | flex-wrap: wrap; |
| 260 | 303 | } |
| 261 | 304 | |
| 262 | 305 | .recommend-product .theme-banner { |
| 263 | - width: 200px; | |
| 306 | + width:200px; | |
| 264 | 307 | margin: auto; |
| 265 | 308 | } |
| 266 | - | |
| 267 | 309 | .recommend-product .plugin-banner { |
| 268 | 310 | width: 100px; |
| 269 | 311 | margin: auto; |
| 270 | 312 | } |
| 271 | 313 | |
| 272 | - .recommend-product .plugin_box .button span { | |
| 314 | + .recommend-product .plugin_box .button span{ | |
| 273 | 315 | |
| 274 | 316 | margin-top: 2px; |
| 275 | 317 | margin-right: 7px; |
| 276 | 318 | } |
| 277 | - | |
| 278 | - .recommend-product .plugin_box .button { | |
| 279 | - margin-bottom: 10px; | |
| 319 | + .recommend-product .plugin_box .button{ | |
| 320 | + margin-bottom:10px; | |
| 280 | 321 | } |
| 281 | - | |
| 282 | 322 | .recommend-product .plugin_box { |
| 283 | 323 | margin-bottom: 20px; |
| 284 | 324 | padding-top: 5px; |
| 285 | 325 | display: flex; |
| 286 | - box-shadow: 0px 0px 10px -5px rgba(0, 0, 0, 0.55); | |
| 326 | + box-shadow: 0px 0px 10px -5px rgba(0,0,0,0.55); | |
| 287 | 327 | background: #fff; |
| 288 | 328 | border-radius: 5px; |
| 289 | 329 | flex-direction: column; |
| 290 | 330 | justify-content: flex-start; |