Search code examples
wordpresswordpress-plugin-creation

Wordpress Plugin does not appear in Admin Screen


I created a wordpress plugin. It is not reflecting in the admin module.

Code and screen shots given below.

Code in structure in Visual Studio Code

Admin Screen

<?php

/**
 * EndpointHelper File Doc Comment.
 *
 * PHP version 7.4.1
 *
 * @category EndpointHelper
 * @package  Helper
 * @author   Bonson Mampilli <bonson.mampilli@company.com>
 * @license  GNU General Public License version 2 or later; see LICENSE
 * @link     http://test site.com
 * @return   empty string
 */
add_action('admin_init', 'do_something');
/**
 * EndpointHelper File Doc Comment.
 *
 * PHP version 7.4.1
 *
 * @category EndpointHelper
 * @package  Helper
 * @author   Bonson Mampilli <bonson.mampilli@company.com>
 * @license  GNU General Public License version 2 or later; see LICENSE
 * @link     http://test site.com
 * @return   empty string
 */
function Do_something() 
{
     wp_die('Hello World');
}

Solution

  • I had to add the following lines in the beginning and it starting showing up as a control in the admin screens:

    Few additional changes:

    1. ?> was missing at the end
    2. Added certain items at the beginning. I understand now that they are mandatory for the plugin to be visible.
    <?php
    /**
     * PHP version 7.4.1
     * Plugin Name: My New Plugin
     * Plugin URI: http://yourdomain.com/
     * Description: My new wordpress plugin
     * Version: 1.0
     * Author: Bonson Mampilli
     * Author URI: http://yourdomain.com
     * License: GPL
     *
     * @category EndpointHelper
     * @package  Helper
     * @author   Bonson Mampilli <bonson.mampilli@company.com>
     * @license  GNU General Public License version 2 or later; see LICENSE
     * @link     http://test site.com
     * @return   empty string
     */
    add_action('admin_init', 'Do_something');
    /**
     * PHP version 7.4.1
     * Plugin Name: My New Plugin
     * Plugin URI: http://yourdomain.com/
     * Description: My new wordpress plugin
     * Version: 1.0
     * Author: Bonson Mampilli
     * Author URI: http://yourdomain.com
     * License: GPL
     *
     * @category EndpointHelper
     * @package  Helper
     * @author   Bonson Mampilli <bonson.mampilli@company.com>
     * @license  GNU General Public License version 2 or later; see LICENSE
     * @link     http://test site.com
     * @return   empty string
     */
    function Do_something() 
    {
         wp_die('Hello World');
    }
    ?>