← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Dashboard_widget.php
+38
-6
3.10.2
→
3.11.8
View file →
| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | |
| 12 | 12 | namespace ThemeisleSDK\Modules; |
| 13 | 13 | |
| 14 | 14 | use ThemeisleSDK\Common\Abstract_Module; |
| 15 | +use ThemeisleSDK\Loader; | |
| 15 | 16 | use ThemeisleSDK\Product; |
| 16 | 17 | |
| 17 | 18 | // Exit if accessed directly. |
| 18 | 19 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -75,14 +76,13 @@ | ||
| 75 | 76 | if ( apply_filters( 'themeisle_sdk_hide_dashboard_widget', false ) ) { |
| 76 | 77 | return; |
| 77 | 78 | } |
| 78 | 79 | $this->product = $product; |
| 79 | - $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' ); | |
| 80 | + $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', Loader::$labels['dashboard_widget']['title'] ); | |
| 80 | 81 | $this->feeds = apply_filters( |
| 81 | 82 | 'themeisle_sdk_dashboard_widget_feeds', |
| 82 | 83 | [ |
| 83 | 84 | 'https://themeisle.com/blog/feed', |
| 84 | - 'https://www.codeinwp.com/blog/feed', | |
| 85 | 85 | 'https://wpshout.com/feed', |
| 86 | 86 | ] |
| 87 | 87 | ); |
| 88 | 88 | add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) ); |
| @@ -279,9 +279,9 @@ | ||
| 279 | 279 | } |
| 280 | 280 | ?> |
| 281 | 281 | <div class="ti-dw-footer"> |
| 282 | 282 | <span class="ti-dw-recommend-item "> |
| 283 | - <span class="ti-dw-recommend"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_popular_label', sprintf( 'Popular %s', ucwords( $type ) ) ) ); ?> | |
| 283 | + <span class="ti-dw-recommend"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_popular_label', sprintf( Loader::$labels['dashboard_widget']['popular'], ucwords( $type ) ) ) ); ?> | |
| 284 | 284 | : </span> |
| 285 | 285 | <?php |
| 286 | 286 | echo esc_attr( |
| 287 | 287 | trim( |
| @@ -298,11 +298,11 @@ | ||
| 298 | 298 | ) |
| 299 | 299 | ); |
| 300 | 300 | ?> |
| 301 | 301 | (<a class="thickbox open-plugin-details-modal" |
| 302 | - href="<?php echo esc_url( $url . '&TB_iframe=true&width=600&height=500' ); ?>"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_install_label', 'Install' ) ); ?></a>) | |
| 302 | + href="<?php echo esc_url( $url . '&TB_iframe=true&width=600&height=500' ); ?>"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_install_label', Loader::$labels['dashboard_widget']['install'] ) ); ?></a>) | |
| 303 | 303 | </span> |
| 304 | - <span class="ti-dw-powered-by"><span><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_widget_powered_by', sprintf( 'Powered by %s', $this->product->get_friendly_name() ) ) ); ?></span></span> | |
| 304 | + <span class="ti-dw-powered-by"><span><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_widget_powered_by', sprintf( Loader::$labels['dashboard_widget']['powered'], $this->product->get_friendly_name() ) ) ); ?></span></span> | |
| 305 | 305 | </div> |
| 306 | 306 | |
| 307 | 307 | <?php |
| 308 | 308 | |
| @@ -312,10 +312,39 @@ | ||
| 312 | 312 | * Setup feed items. |
| 313 | 313 | */ |
| 314 | 314 | private function setup_feeds() { |
| 315 | 315 | if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure |
| 316 | + // Do not force the feed for the items in the sdk feeds list. | |
| 317 | + // this prevents showing notices if another plugin will force all SimplePie feeds to load, instead it will | |
| 318 | + // use the regular SimplePie validation and abort early if the feed is not valid. | |
| 319 | + $sdk_feeds = $this->feeds; | |
| 320 | + add_action( | |
| 321 | + 'wp_feed_options', | |
| 322 | + function ( $feed, $url ) use ( $sdk_feeds ) { | |
| 323 | + if ( defined( 'TI_SDK_PHPUNIT' ) && true === TI_SDK_PHPUNIT ) { | |
| 324 | + return; | |
| 325 | + } | |
| 326 | + | |
| 327 | + if ( ! is_string( $url ) && in_array( $url, $sdk_feeds, true ) ) { | |
| 328 | + $feed->force_feed( false ); | |
| 329 | + | |
| 330 | + return; | |
| 331 | + } | |
| 332 | + if ( is_array( $url ) ) { | |
| 333 | + foreach ( $url as $feed_url ) { | |
| 334 | + if ( in_array( $feed_url, $sdk_feeds, true ) ) { | |
| 335 | + $feed->force_feed( false ); | |
| 336 | + | |
| 337 | + return; | |
| 338 | + } | |
| 339 | + } | |
| 340 | + } | |
| 341 | + }, | |
| 342 | + PHP_INT_MAX, | |
| 343 | + 2 | |
| 344 | + ); | |
| 316 | 345 | // Load SimplePie Instance. |
| 317 | - $feed = fetch_feed( $this->feeds ); | |
| 346 | + $feed = fetch_feed( $sdk_feeds ); | |
| 318 | 347 | // TODO report error when is an error loading the feed. |
| 319 | 348 | if ( is_wp_error( $feed ) ) { |
| 320 | 349 | return; |
| 321 | 350 | } |
| @@ -321,8 +350,11 @@ | ||
| 321 | 350 | } |
| 322 | 351 | |
| 323 | 352 | $items = $feed->get_items( 0, 5 ); |
| 324 | 353 | $items = is_array( $items ) ? $items : []; |
| 354 | + | |
| 355 | + $items_normalized = []; | |
| 356 | + | |
| 325 | 357 | foreach ( $items as $item ) { |
| 326 | 358 | $items_normalized[] = array( |
| 327 | 359 | 'title' => $item->get_title(), |
| 328 | 360 | 'date' => $item->get_date( 'U' ), |