163 lines
3.4 KiB
PHP
163 lines
3.4 KiB
PHP
<?php
|
|
/*
|
|
Plugin Name: fipfcard_plugin
|
|
Plugin URI:
|
|
Description:
|
|
Author: hugogogo
|
|
Version: 1.1.0
|
|
Author URI:
|
|
*/
|
|
|
|
/*
|
|
5.5 . 5.48
|
|
59 . 58.99
|
|
50.6 . 50.58
|
|
38.5 . 38.53
|
|
99.8 . 99.84
|
|
25.2 . 25.17
|
|
131.6 . 135
|
|
63.7 . 63.68
|
|
85 . 85.05
|
|
50.2 . 50.17
|
|
41.4 . 41.43
|
|
18.8 . 18.82
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
plugin dir root
|
|
*/
|
|
define( 'FIPFCARD_PLUGIN_DIR', plugin_dir_path(__FILE__) );
|
|
define( 'FIPFCARD_PLUGIN_URL', plugin_dir_url(__FILE__) );
|
|
|
|
include_once( plugin_dir_path(__FILE__) . '/php/utils/plugin_tools.php');
|
|
PLGNTOOLS::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) );
|
|
|
|
/*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
inclusions
|
|
*/
|
|
include_once(FIPFCARD_PLUGIN_DIR . '/php/utils/globals.php');
|
|
include_once(FIPFCARD_PLUGIN_DIR . '/php/utils/console_log.php');
|
|
include_once(FIPFCARD_PLUGIN_DIR . '/php/utils/add_to_front.php');
|
|
include_once(FIPFCARD_PLUGIN_DIR . '/php/utils/create_html.php');
|
|
|
|
include_once(FIPFCARD_PLUGIN_DIR . '/php/menu/example_menu.php');
|
|
|
|
|
|
|
|
|
|
/*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
plugin shortcode
|
|
*/
|
|
function fipfcard_main_shortcode() {
|
|
|
|
$fipfcard_tools = new PLGNTOOLS();
|
|
$test_path_plgntools = $fipfcard_tools->get_path();
|
|
$test_url_plgntools = $fipfcard_tools->get_url();
|
|
error_log("-------------");
|
|
error_log($test_path_plgntools);
|
|
error_log($test_url_plgntools);
|
|
|
|
// fipfcard_add_files_to_front( array(
|
|
// "example_style.css",
|
|
// "example_init.js",
|
|
// "example_script2.js",
|
|
// "example_script3.js",
|
|
// ));
|
|
|
|
$fipfcard_tools->add_files_to_front( array(
|
|
"example_style.css",
|
|
"example_init.js",
|
|
"example_script2.js",
|
|
"example_script3.js",
|
|
));
|
|
|
|
$myvar_1 = "I am one";
|
|
$myvar_2 = "I am two";
|
|
// fipfcard_add_var_to_front( compact(
|
|
// "myvar_1",
|
|
// "myvar_2",
|
|
// ));
|
|
|
|
$fipfcard_tools->add_var_to_front( compact(
|
|
"myvar_1",
|
|
"myvar_2",
|
|
));
|
|
|
|
|
|
$names = ["hugo", "camille"];
|
|
$ages = ["13", "34", "56"];
|
|
// $html_front = fipfcard_create_html(
|
|
// array(
|
|
// "example_index.html",
|
|
// "example_index2.html",
|
|
// ),
|
|
// compact(
|
|
// "names",
|
|
// "ages",
|
|
// )
|
|
// );
|
|
|
|
$html_front = $fipfcard_tools->create_html(
|
|
array(
|
|
"example_index.html",
|
|
"example_index2.html",
|
|
),
|
|
compact(
|
|
"names",
|
|
"ages",
|
|
)
|
|
);
|
|
|
|
return $html_front;
|
|
}
|
|
add_shortcode('fipfcard_plugin', 'fipfcard_main_shortcode');
|
|
|
|
|
|
|
|
|
|
/*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
menu plugin
|
|
*/
|
|
function fipfcard_plugin_menu() {
|
|
add_menu_page(
|
|
'fipf_card', // webpage title
|
|
'fipf_card', // menu title
|
|
'manage_options', // capability
|
|
'fipfcard-plugin', // menu_slug
|
|
'fipfcard_plugin_content' // callback function to display page content
|
|
);
|
|
}
|
|
add_action('admin_menu', 'fipfcard_plugin_menu');
|
|
|
|
|
|
|
|
|
|
/*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
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 fipfcard_ajax_handler() {
|
|
wp_send_json_success( array(
|
|
'It works',
|
|
"data_received" => $_POST['data'],
|
|
),
|
|
200
|
|
);
|
|
}
|
|
add_action( 'wp_ajax_get_data', 'fipfcard_ajax_handler' );
|
|
|
|
|
|
?>
|