Commit 6f0cd73f authored by Isaac Costa's avatar Isaac Costa
Browse files

init project

parent 92135ece
/.vscode
<?php
/*
* Plugin Name: Discount on Shipping
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Handle the basics with this plugin.
* Version: 0.0.1
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Otimize it
* Author URI: https://author.example.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: Discount-on-shipping
* Domain Path: /languages
*/
if (! defined('WPINC')) {
wp_die();
}
//Plugin version
if( ! defined('MY_FIRST_PLUGIN_VERSION')) {
define('MY_FIRST_PLUGIN_VERSION','1.0.0');
}
//Plugin Name
if( ! defined('MY_FIRST_PLUGIN_NAME')) {
define('MY_FIRST_PLUGIN_NAME','My First Plugin');
}
//Plugin Slug
if( ! defined('MY_FIRST_PLUGIN_PLUGIN_SLUG')) {
define('MY_FIRST_PLUGIN_PLUGIN_SLUG','my-first-plugin');
}
//Plugin Basename
if( ! defined('MY_FIRST_PLUGIN_BASENAME')) {
define('MY_FIRST_PLUGIN_BASENAME', plugin_basename(__FILE__));
}
//Plugin Folder
if( ! defined('MY_FIRST_PLUGIN_DIR')) {
define('MY_FIRST_PLUGIN_DIR', plugin_dir_path(__FILE__));
}
//JSON File Name
if( ! defined('MY_FIRST_PLUGIN_JSON_FILE')) {
define('MY_FIRST_PLUGIN_JSON_FILENAME','my-first-plugin.json');
}
// File path
// MY_FIRST_PLUGIN_DIR . 'includes/class-first-json.php';
// require_once MY_FIRST_PLUGIN_DIR . 'includes/mfp-functions.php';
if( is_admin() )
require_once MY_FIRST_PLUGIN_DIR . 'includes/class-first-admin.php';
\ No newline at end of file
<?php // Silence is Gold!
\ No newline at end of file
<div class="wrap">
<h1>Hello!</h1>
<p>This is my plugin's first page</p>
<form method="post" action="" >
<table>
<tr>
<th>Preço mínimo</th>
<th>Desconto<th>
</tr>
<tr>
<td><input type="number" id="price_min" /></td>
<td><input type="number" id="discount"/></td>
</tr>
</table>
<input type="submit" name="submit">
</form>
<?php
settings_fields($dataGroup);
?>
</div>
<?php
if (!function_exists('write_log')) {
function write_log($log) {
if (true === WP_DEBUG) {
if (is_array($log) || is_object($log)) {
error_log(print_r($log, true));
} else {
error_log($log);
}
}
}
}
/*
* Add my new menu to the Admin Control Panel
*/
add_action( 'admin_menu', 'mfp_Add_My_Admin_Link' );
add_action('admin_init', 'register_my_first_plugin_settings');
add_filter( 'wp_head', 'custom');
//
// Add a new top level menu link to the ACP
function mfp_Add_My_Admin_Link()
{
add_menu_page(
'My First Page', // Title of the page
'My First Plugin', // Text to show on the menu link
'manage_options', // Capability requirement to see the link
'nome-da-pagina-1',
'pagina1'
);
}
function pagina1() {
// require_once "mfp-first-acp-page.php";
?>
<div class="wrap">
<h1>Hello!</h1>
<p>This is my plugin's first page</p>
<form method="post" action="" >
<table>
<tr>
<th>Preço mínimo</th>
<th>Desconto<th>
</tr>
<tr>
<td><input type="number" id="price_min" /></td>
<td><input type="number" id="discount"/></td>
</tr>
</table>
<input type="submit" name="submit">
</form>
<?php
settings_fields($dataGroup);
?>
</div>
<?php
}
function register_my_first_plugin_settings() {
//register_setting( 'my_first_plugin_settings', 'my_first_plugin_keys' );
$price_min = 1;
$discount = 1;
$settings = (object)[$price_min,$discount];
write_log($settings);
update_option('my_first_plugin_keys', $settings);
}
function custom() {
// $shipping = number_format(str_replace('R$', '', $_POST['woocommerce_flat_rate_cost']), 2, '.', ' ');
// $shipping = (float)$_POST['woocommerce_flat_rate_cost'];
// echo ("O valor do frete " . $shipping) ;
}
<?php // Silence is Gold!
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment