Spaces:
Sleeping
Sleeping
| /** | |
| * Plugin Name: Self Analysis Tool | |
| * Description: Provides a shortcode [selfanalysistool] to embed the index.html file on any page or post. | |
| * Version: 1.2.0 | |
| * Author: Muhammad Usman | |
| * Author URI: https://devusman.vercel.app | |
| * License: GPL-2.0+ | |
| * License URI: http://www.gnu.org/licenses/gpl-2.0.txt | |
| * Text Domain: selfanalysistool | |
| */ | |
| // Abort if this file is called directly | |
| if (!defined('WPINC')) { | |
| die; | |
| } | |
| /** | |
| * Shortcode callback function | |
| */ | |
| function selfanalysistool_shortcode_handler($atts) | |
| { | |
| // Enqueue styles and scripts only when shortcode is used | |
| $file_path = plugin_dir_path(__FILE__) . 'index.html'; | |
| if (file_exists($file_path)) { | |
| ob_start(); | |
| include($file_path); | |
| return ob_get_clean(); | |
| } else { | |
| if (current_user_can('manage_options')) { | |
| return 'Error: index.html not found in selfanalysistool plugin directory.'; | |
| } | |
| return ''; | |
| } | |
| } | |
| add_shortcode('selfanalysistool', 'selfanalysistool_shortcode_handler'); | |