changed plugin name to cipf

This commit is contained in:
asus
2024-03-07 22:35:39 +01:00
parent be79310404
commit 9b5e44dfd3
45 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* menu plugin
*/
function cipfcard_plugin_menu()
{
add_menu_page
(
'cipf_card', // webpage title
'cipf_card', // menu title
'manage_options', // capability
'cipfcard-plugin', // menu_slug
'cipfcard_plugin_content' // callback function to display page content
);
}
add_action('admin_menu', 'cipfcard_plugin_menu');
/**
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function cipfcard_plugin_content() {
$cipfcard = new PLGNTLS_class();
$my_css = '
#mytext {
background-color: lightblue;
}
#mytext_2 {
background-color: lightgreen;
}
';
echo $cipfcard->add_to_front( array(
array("js/menu/example_menu.js", 'type'=>'module'),
"css/menu/menu.css",
"PLGNTLS_menu_css" => array('css'=>$my_css),
"js/menu/example_menu_2.js",
"html/menu/example_menu.html",
));
}
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ajax
- https://stackoverflow.com/questions/43557755/how-to-call-ajax-in-wordpress
- in `add_action( 'wp_ajax_get_data', 'my_ajax_handler' );`
the 'wp_ajax_get_data' is a hooks formated as 'wp_ajax_{$action}'
the `$action` param is passed in the data object of the ajax call
- to access the content of the data object properties of the ajax call :
use $_POST['property_name']
*/
function cipfcard_menu_fetch_handler()
{
return new WP_REST_Response('hello', 200);
}
function cipfcard_menu_endpoint()
{
register_rest_route('plgntls', '/get_data', array(
'methods' => 'POST',
'callback' => 'cipfcard_menu_fetch_handler',
));
};
add_action('rest_api_init', 'cipfcard_menu_endpoint');
?>