Plugin Directory

Changeset 3210586


Ignore:
Timestamp:
12/19/2024 03:42:13 PM (16 months ago)
Author:
mgplugin
Message:

updates code

Location:
roi-calculator/trunk
Files:
10 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • roi-calculator/trunk/readme.txt

    r3195705 r3210586  
    33Requires at least: 5.5
    44Tested up to: 6.7.1
    5 Stable tag: 1.0
     5Stable tag: 1.1
    66License: GPLv3 or later
    77License URI: https://www.gnu.org/licenses/gpl-3.0.txt
  • roi-calculator/trunk/roi-calculator.php

    r3203719 r3210586  
    33* Plugin Name: Roi Calculator
    44* Description: For Using This Plugin you Can Know profitability of an investment.
    5 * Version: 1.0
     5* Version: 1.1
    66* Copyright: 2023
    77* License: GPLv3 or later
     
    1515
    1616
    17 // define for base name
    18 define('ROI_BASE_NAME', plugin_basename(__FILE__));
    19 
    20 
    21 // define for plugin file
    22 define('roi_plugin_file', __FILE__);
    23 
    24 
    25 // define for plugin dir path
    26 define('ROI_PLUGIN_DIR',plugins_url('', __FILE__));
    2717
    2818
    2919// Include function files
    30 include_once('inc/admin/roi_menu.php');
    31 include_once('inc/roi_fronted.php');
     20include_once('frontend/frontend.php');
     21include_once('backend/backend.php');
    3222
     23function roi_load_script_style() {
     24    // Define version variable using file modification time for cache busting
     25    $roi_custom_js_version = filemtime( plugin_dir_path( __FILE__ ) . '/frontend/asset/js/script.js' );
     26    $chart_js_version = '1.0.0'; // Static version for chart.js as it is unlikely to change
     27    $roi_style_css_version = filemtime( plugin_dir_path( __FILE__ ) . '/frontend/asset/css/style.css' );
    3328
    34 function roi_load_script_style(){
    35     wp_enqueue_script( 'jquery-roi-calculator', ROI_PLUGIN_DIR . '/asset/js/roi_custom.js', array('jquery'), filemtime( ROI_PLUGIN_DIR . '/asset/js/roi_custom.js' ), true );
    36     wp_enqueue_script( 'chart-js', ROI_PLUGIN_DIR . '/asset/js/chart.js', false, '1.0.0' ,true);
    37     wp_enqueue_style( 'jquery-calculator-style', ROI_PLUGIN_DIR . '/asset/css/roi_style.css', '', filemtime( ROI_PLUGIN_DIR . '/asset/css/roi_style.css' ) );
     29    // Enqueue scripts and styles with versioning
     30    wp_enqueue_script( 'jquery-roi-calculator', plugin_dir_url( __FILE__ ) . '/frontend/asset/js/script.js', array('jquery'), $roi_custom_js_version, true );
     31    wp_enqueue_script( 'chart-js', plugin_dir_url( __FILE__ ) . '/frontend/asset/js/chart.js', false, $chart_js_version, true );
     32    wp_enqueue_style( 'jquery-calculator-style', plugin_dir_url( __FILE__ ) . '/frontend/asset/css/style.css', false, $roi_style_css_version );
    3833
     34    // Localize PHP variables to be used in JS
    3935    $roi_color_var = array(
    40         'roi_investd_chart_color' => sanitize_hex_color(get_option('roi_investamount_color', '#BCDCFF')),
    41         'roi_profit_chart_color' => sanitize_hex_color(get_option('roi_profitamount_color', '#153A5B')),
    42         'calc_with_chart' => get_option('roi_enable_chart', 'true'),
    43         'calc_chart_type' => sanitize_text_field(get_option('roi_chart_type', 'doughnut_chart')),
    44         'roi_calc_invest_gain_text' => sanitize_text_field(get_option('roi_invest_gain_text', 'Invest Gain')),
    45         'roi_calc_roi_text' => sanitize_text_field(get_option('roi_text', 'ROI')),
    46         'roi_calc_annualized_roi_text' => sanitize_text_field(get_option('annualized_roi_text', 'Annualized ROI')),
    47         'roi_calc_roi_investment_length_text' => sanitize_text_field(get_option('roi_investment_length_text', 'Investment Length')),
    48         'roi_calc_invest_amount_text' => sanitize_text_field(get_option('roi_invest_amount_text', 'Investment Amount')),
    49         'roi_calc_roi_profit_earned_text' => sanitize_text_field(get_option('roi_profit_earned_text', 'Profit Earned')),
    50         'roi_calc_min_investment_amount' => absint(get_option('min_investment_amount', '1')),
    51         'roi_calc_max_investment_amount' => absint(get_option('max_investment_amount', '100000')),
    52         'roi_calc_min_return_amount' => absint(get_option('min_return_amount', '1')),
    53         'roi_calc_max_return_amount' => absint(get_option('max_return_amount', '100000')),
    54         'roi_calc_min_investment_period' => absint(get_option('min_investment_period', '1')),
    55         'roi_calc_max_investment_period' => absint(get_option('max_investment_period', '30')),
     36        'roi_investd_chart_color' => sanitize_hex_color( get_option( 'roi_investamount_color', '#BCDCFF' ) ),
     37        'roi_profit_chart_color' => sanitize_hex_color( get_option( 'roi_profitamount_color', '#153A5B' ) ),
     38        'calc_with_chart' => get_option( 'roi_enable_chart', 'true' ),
     39        'calc_chart_type' => sanitize_text_field( get_option( 'roi_chart_type', 'doughnut_chart' ) ),
     40        'roi_calc_invest_gain_text' => sanitize_text_field( get_option( 'roi_invest_gain_text', 'Invest Gain' ) ),
     41        'roi_calc_roi_text' => sanitize_text_field( get_option( 'roi_text', 'ROI' ) ),
     42        'roi_calc_annualized_roi_text' => sanitize_text_field( get_option( 'annualized_roi_text', 'Annualized ROI' ) ),
     43        'roi_calc_roi_investment_length_text' => sanitize_text_field( get_option( 'roi_investment_length_text', 'Investment Length' ) ),
     44        'roi_calc_invest_amount_text' => sanitize_text_field( get_option( 'roi_invest_amount_text', 'Investment Amount' ) ),
     45        'roi_calc_roi_profit_earned_text' => sanitize_text_field( get_option( 'roi_profit_earned_text', 'Profit Earned' ) ),
     46        'roi_calc_min_investment_amount' => absint( get_option( 'min_investment_amount', '1' ) ),
     47        'roi_calc_max_investment_amount' => absint( get_option( 'max_investment_amount', '100000' ) ),
     48        'roi_calc_min_return_amount' => absint( get_option( 'min_return_amount', '1' ) ),
     49        'roi_calc_max_return_amount' => absint( get_option( 'max_return_amount', '100000' ) ),
     50        'roi_calc_min_investment_period' => absint( get_option( 'min_investment_period', '1' ) ),
     51        'roi_calc_max_investment_period' => absint( get_option( 'max_investment_period', '30' ) ),
    5652    );
    5753
     54    // Localize the PHP variables to JavaScript
    5855    wp_localize_script( 'jquery-roi-calculator', 'roi_calc_style', $roi_color_var );
    5956}
Note: See TracChangeset for help on using the changeset viewer.