Open MaximeCulea opened 6 years ago
On some environments, crons are not something doable, like in local, the plugin should provide an option in the backend to force the indexation IMO.
Something like this:
<?php
add_action( 'admin_init', 'add_media_indexing_button' );
/**
* Add option page for media index
*/
function add_media_indexing_button(): void {
add_settings_section(
'media_indexing',
__( 'Media Indexing' ),
'__return_null',
'media'
);
add_settings_field(
'media_indexing_button',
__( 'Trigger indexing' ),
static function() {
if ( isset( $_GET['force_media_index'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
BEA\Media_Analytics\Main::get_instance()->force_indexation();
?>
<div class="notice notice-info notice-info-stronger"><p>Media index rebuilt successfully</p></div>
<?php
}
?>
<a href="<?php echo esc_url( add_query_arg( 'force_media_index', 1, menu_page_url( 'options-media', false ) ) ); ?>" class="button">Force media index</a>
<?php
},
'media',
'media_indexing'
);
}
From https://wordpress.org/support/topic/notice-toujours-affichee :