File size: 1,086 Bytes
9c9f9cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
 * 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');