The plugin generated 198 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds,,, Where the error ?
if ( ! defined( 'ABSPATH' ) ) { exit; }
define('CUSTOM_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ));
define('CUSTOM_PLUGIN_URL',plugins_url());
define('VERSION','1.0.0');
add_action( 'admin_menu', 'add_custom_menu' );
function add_custom_menu(){
// add_menu_page( $page_title, $menu_title, $capability, $menu_slug, '', '', null );
add_menu_page( 'CustomPlugin', 'Custom Plugin', 'manage_options', 'custom_plugin', 'add_new_function', 'dashicons-smiley', 11 );
// add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, '' );
add_submenu_page('custom_plugin', 'Add New', 'General', 'manage_options', 'custom_plugin', 'add_new_function' );
add_submenu_page('custom_plugin', 'All Pages', 'All Pages', 'manage_options', 'all-pages', 'add_new_function2' );
}
// General menu function
function add_new_function(){
include_once CUSTOM_PLUGIN_DIR_PATH.'/templates/general.php';
}
// all pages menun function
function add_new_function2(){
echo "sub menu ";
}
add_action( 'admin_enqueue_scripts', 'custom_plugin_asset' );
function custom_plugin_asset(){
// css and js file
wp_enqueue_style('custom-css', CUSTOM_PLUGIN_URL.'/custom-plugin/assets/css/custom.css','',VERSION );
wp_enqueue_script('custom-js', CUSTOM_PLUGIN_URL.'/custom-plugin/assets/js/custom.js', array('jquery'),VERSION);
// wp_enqueue_script( $handle, '', array( '' ), false, false );
}
function custom_plugin_tables(){
global $wpdb;
require_once (ABSPATH.'wp-admin/includes/upgrade.php');
if (count($wpdb->get_var('SHOW TABLES LIKE "wp_custom_plugin"')) == 0) {
$sql_query_to_create_table = "CREATE TABLE `wp_custom_plugin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(150) DEFAULT NULL,
`email` varchar(150) DEFAULT NULL,
`phone` varchar(50) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1" ;// sql query to create table
dbDelta( $sql_query_to_create_table);
}
}
register_activation_hook( __FILE__, 'custom_plugin_tables' );