<?php
/**
 * WP PHP Version Display
 *
 *
 * @package WP PHP Version Display
 * @since 1.0
 */

/**
 * Plugin Name: WP PHP Version Display
 * Plugin URI:  https://wordpress.org/plugins/wp-php-version-display/
 * Description: Displays the current running PHP version inside "At a Glance" admin dashboard widget.
 * Author:      Arul Prasad J
 * Author URI:  https://profiles.wordpress.org/arulprasadj/
 * Version:     1.0
 * Text Domain: wp-php-version-display
 * Domain Path: /languages
 * License:     GPLv2 or later (license.txt)
 
 
Copyright (C)  2020-2021 arulprasadj

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
function apj_wpvd_enqueue_script( $hook ) {
	// only run on dashboard page
	global $wpdb;
	$screen = get_current_screen();
	if ( $screen->id != 'dashboard' ){
	        return;
	}
	// enqueue script
	wp_enqueue_script( 'apj_wpvd_script', plugin_dir_url( __FILE__ ) . 'apjwpvd.js' );
	// Send the PHP version to JavaScript
	wp_localize_script( 'apj_wpvd_script', 'PHPObj', array(
		'phpVersion' => phpversion()
	) );
}
add_action( 'admin_enqueue_scripts', 'apj_wpvd_enqueue_script' );
