Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 _e( 'The Imagick PHP extension is not installed. Gaussholder cannot process images without it. Please, install and activate Imagick extension.', 'gaussholder' ); ?></p>
Comment thread
igmoweb marked this conversation as resolved.
Outdated
</div>
<?php
}