<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit();
}

/**
 * Show a notice to update the PHP version
 * Since 3.0.35
 */
function naga_rankmath_php_notice() {
	?>
	<div class="notice notice-error">
		<p>
			<?php
			echo sprintf(
			
				__( 'According to {%1$s} the PHP version of your host must be at least {%2$s} or higher! Please update your host PHP version to be able to activate {%3$s} and use the pro version. %4$s', 'naga-rankmath-notices' ),
				
				'<a href="https://wordpress.org/about/requirements/" target="_blank" rel="noopener noreferrer">' . __('WordPress Requirements', 'naga-rankmath-notices').'</a>',
				
				naga_rankmath_min_reqiered_php,
				
				naga_rankmath_get_plugin_name(),
				
				'<a href="https://nagatheme.com/how-to-change-host-php-version/" target="_blank" rel="noopener noreferrer">' . __('Please check this article for more informations!', 'naga-rankmath-notices').'</a>'
				
				);
				
			?>
		</p>
	</div>
	<?php
}

/**
 * Show a notice to activate ionCube on server
 * Since 3.0.35
 */
function naga_rankmath_ioncube_notice() {
	?>
	<div class="notice notice-error">
		<p>
			<?php
			echo sprintf(
			
				__( 'Unfortunately, {%1$s} settings are Disabled! The Product PHP files are encrypted for more performance and security! ionCube Loader is required to be installed in your host! Please contact your hosting support and ask them to install the ioncube loader! %2$s', 'naga-rankmath-notices' ),
				
				naga_rankmath_get_plugin_name(),
				
				'<a href="https://nagatheme.com/how-to-install-ioncube-and-sourceguardian-loader/" target="_blank" rel="noopener noreferrer">' . __('Please check this article for more informations!', 'naga-rankmath-notices').'</a>'
				
				);
			?>
		</p>
	</div>
	
	<?php
}

/**
 * Show a notice to update the ionCube version
 * Since 3.0.35
 */
function naga_rankmath_ioncube_version_notice() {
	?>
	<div class="notice notice-error">
		<p>
			<?php
			
			echo sprintf(
			
				__( 'Unfortunately, {%1$s} settings are Disabled! The Product PHP files are encrypted for more performance and security by ioncube! The ioncube loader is active in your host but its version is {%2$s} while it must be at least {%3$s} so that you can use this product. Please contact your hosting support and ask them to update the ioncube loader! %4$s', 'naga-rankmath-notices' ),
				
				naga_rankmath_get_plugin_name(),
				
				naga_rankmath_get_ioncube_loader_version(),
				
				naga_rankmath_min_reqiered_ioncube,
				
				'<a href="https://nagatheme.com/how-to-install-ioncube-and-sourceguardian-loader/" target="_blank" rel="noopener noreferrer">' . __('Please check this article for more informations!', 'naga-rankmath-notices').'</a>'
				
				);
				
			?>
		</p>
	</div>
	<?php
}

/**
 * Get the server ionCube version to show in the notice
 * Since 3.0.35
 */
function naga_rankmath_get_ioncube_loader_version() {
	
	if( is_admin() ) {
		
		if( function_exists( 'ioncube_loader_version' ) ) {
			
			$ioncube_loader_version = ioncube_loader_version();
			
			return $ioncube_loader_version;
			
		} else {
			
			return __( 'NAN', 'naga-rankmath-notices' );
			
		}
		
	}
	
}

/**
 * Get the plugin name to show in the notice
 * Since 3.0.35
 */
function naga_rankmath_get_plugin_name() {
	
	if( is_admin() ) {
		
		if( is_plugin_active( 'seo-by-rank-math-pro/rank-math-pro.php' ) ) {
			
			$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/seo-by-rank-math-pro/rank-math-pro.php' );
			
			$plugin_name = $plugin_data['Name'];
		
			return $plugin_name;
			
		}
		
	}
	
}

/**
 * Disable options to protect the user from confusing about License!
 * Even if this function were removed, options still don't work,
 * Untill the user activate the License
 * Since 3.0.35
 */
function naga_rankmath_deactivate_licenses() {
	
	remove_submenu_page( 'rank-math', 'rank-math' );
	
	remove_submenu_page( 'rank-math', 'rank-math-analytics' );
	
	remove_submenu_page( 'rank-math', 'rank-math-options-general' );
	
	remove_submenu_page( 'rank-math', 'rank-math-options-titles' );
	
	remove_submenu_page( 'rank-math', 'rank-math-options-sitemap' );
	
	remove_submenu_page( 'rank-math', 'edit.php?post_type=rank_math_schema' );
	
	remove_submenu_page( 'rank-math', 'rank-math-404-monitor' );
	
	remove_submenu_page( 'rank-math', 'rank-math-seo-analysis' );
	
	remove_submenu_page( 'rank-math', 'rank-math-status' );
	
	remove_submenu_page( 'rank-math', 'rank-math-options-instant-indexing' );
	
	remove_submenu_page( 'rank-math', 'rank-math-role-manager' );
	
	remove_submenu_page( 'rank-math', 'rank-math-redirections' );
	
	remove_submenu_page( 'rank-math', 'nagatheme-knowledge-base' );
	
}