Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added admin notice when Imagick is not installed #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gaussholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

require_once __DIR__ . '/inc/class-plugin.php';
require_once __DIR__ . '/inc/frontend/namespace.php';
require_once __DIR__ . '/inc/admin/namespace.php';
require_once __DIR__ . '/inc/jpeg/namespace.php';

if ( defined( 'WP_CLI' ) && WP_CLI ) {
Expand All @@ -27,8 +28,10 @@
}

add_action( 'plugins_loaded', __NAMESPACE__ . '\\Frontend\\bootstrap' );
add_action( 'admin_init', __NAMESPACE__ . '\\Admin\\bootstrap' );
add_filter( 'wp_update_attachment_metadata', __NAMESPACE__ . '\\queue_generate_placeholders_on_save', 10, 2 );
add_action( 'gaussholder.generate_placeholders', __NAMESPACE__ . '\\generate_placeholders' );

// We <3 you!
if ( WP_DEBUG && ! defined( 'WP_I_AM_A_GRUMPY_PANTS' ) ) {
add_action( 'admin_head-plugins.php', function () {
Expand Down
27 changes: 27 additions & 0 deletions inc/admin/namespace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Gaussholder\Admin;

/**
* Set up hooked callbacks on admin_init
*/
function bootstrap() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}

if ( ! class_exists( 'Imagick' ) ) {
add_action( 'admin_notices', __NAMESPACE__ . '\\display_imagick_notice' );
}
}

/**
* Display a notice when Imagick PHP extension is not available.
*/
function display_imagick_notice() {
?>
<div class="notice notice-error">
<p><?php esc_html_e( 'The Imagick PHP extension is not installed. Gaussholder cannot process images without it. Please, install and activate Imagick extension.', 'gaussholder' ); ?></p>
</div>
<?php
}