| 1 |
<?php |
| 2 |
|
| 3 |
namespace ISC\Image_Sources; |
| 4 |
|
| 5 |
use ISC_Model; |
| 6 |
|
| 7 |
/** |
| 8 |
* Add the admin menu items für Image Sources features |
| 9 |
*/ |
| 10 |
class Admin_Notices { |
| 11 |
use \ISC\Options; |
| 12 |
|
| 13 |
/** |
| 14 |
* Constructor |
| 15 |
*/ |
| 16 |
public function __construct() { |
| 17 |
add_action( 'admin_notices', [ $this, 'admin_notices' ] ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Search for missing sources and display a warning if found some |
| 22 |
* |
| 23 |
* This message intentionally uses the `admin_notices` hook instead of the `isc_admin_notices` hook |
| 24 |
* since it is meant to be shown in the general admin area and not on ISC pages. |
| 25 |
* Someone visiting ISC pages might already be aware of the issue and does not need to be reminded there. |
| 26 |
*/ |
| 27 |
public function admin_notices() { |
| 28 |
|
| 29 |
// only check, if check-option was enabled |
| 30 |
$options = $this->get_options(); |
| 31 |
// skip the warning on the image sources screen since the list shows up there |
| 32 |
$screen = get_current_screen(); |
| 33 |
if ( empty( $options['warning_onesource_missing'] ) |
| 34 |
|| empty( $screen->id ) |
| 35 |
|| $screen->id === 'media_page_isc-sources' ) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
$missing_sources = (int) get_transient( 'isc-show-missing-sources-warning' ); |
| 40 |
|
| 41 |
// check for missing sources if the transient is empty and store that value |
| 42 |
if ( ! $missing_sources ) { |
| 43 |
$missing_sources = ISC_Model::update_missing_sources_transient(); |
| 44 |
} |
| 45 |
|
| 46 |
// attachments without sources |
| 47 |
if ( $missing_sources ) { |
| 48 |
require_once ISCPATH . '/admin/templates/notice-missing.php'; |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|