From 3710e83fc0053530c178d219c6499dfe2e0cee2f Mon Sep 17 00:00:00 2001 From: krishana7911 Date: Fri, 18 Apr 2025 12:19:01 +0530 Subject: [PATCH] Feat: Add Notice for GoDAM Plugin --- admin/rt-transcoder-admin.php | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/admin/rt-transcoder-admin.php b/admin/rt-transcoder-admin.php index 570d7590..6b1f2730 100755 --- a/admin/rt-transcoder-admin.php +++ b/admin/rt-transcoder-admin.php @@ -88,8 +88,13 @@ public function __construct() { } if ( is_multisite() ) { add_action( 'network_admin_notices', array( $this, 'subscribe_transcoder_admin_notice' ) ); + add_action( 'network_admin_notices', array( $this, 'install_godam_admin_notice' ) ); + add_action( 'network_admin_enqueue_scripts', array( $this, 'enqueue_thickbox_on_transcoder_settings' ) ); } add_action( 'admin_notices', array( $this, 'subscribe_transcoder_admin_notice' ) ); + add_action( 'admin_notices', array( $this, 'install_godam_admin_notice' ) ); + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_thickbox_on_transcoder_settings' ) ); + } if ( class_exists( 'RTMedia' ) ) { @@ -501,4 +506,64 @@ public function rtmedia_hide_encoding_tab() { public function mediaelement_add_class( $output, $url ) { return sprintf( '%1$s', esc_url( $url ) ); } + + /** + * Display GoDAM installation recommendation admin notice on specific pages. + */ + public function install_godam_admin_notice() { + $current_screen = get_current_screen(); + + // Define allowed pages + $allowed_pages = array( + 'rt-transcoder', + 'rt-retranscoder', + 'dashboard', + ); + + // Check if we’re on allowed page using screen ID or $_GET['page'] + $current_page = isset( $_GET['page'] ) ? $_GET['page'] : ''; + $screen_id = isset( $current_screen->id ) ? $current_screen->id : ''; + + // Skip if not in our allowed pages + if ( + ( ! in_array( $current_page, $allowed_pages, true ) && ! in_array( $screen_id, $allowed_pages, true ) ) || + get_user_meta( get_current_user_id(), '_godam_notice_dismissed', true ) + ) { + return; + } + + // Check if GoDAM is already active + if ( is_plugin_active( 'godam/godam.php' ) ) { + return; + } + + $plugin_slug = 'godam'; + $plugin_modal_url = is_multisite() + ? network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&TB_iframe=true&width=772&height=666' ) + : admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&TB_iframe=true&width=772&height=666' ); + + $class = 'notice notice-info'; + $valid_tags = array( + 'div' => array( 'class' => array(), 'id' => array() ), + 'p' => array(), + 'strong' => array(), + 'a' => array( 'href' => array(), 'class' => array(), 'target' => array() ), + ); + + printf( + wp_kses( + __( '

NOTICE: Transcoder plugin will be retired on May 31, 2025. We recommend removing this plugin and switching to our new plugin, GoDAM which includes powerful Digital Asset Management features along with video transcoding services. Install GoDAM now!

', 'transcoder' ), + $valid_tags + ), + esc_attr( $class ), + esc_url( $plugin_modal_url ) + ); + } + + /** + * Enqueue thickbox on transcoder settings page. + */ + public function enqueue_thickbox_on_transcoder_settings() { + add_thickbox(); + } }