cost-calculator-for-elementor
Last commit date
fields
2 years ago
free
2 years ago
languages
2 years ago
libs
2 years ago
superaddons
2 years ago
add-ons.php
2 years ago
cost-calculator-for-elementor.php
2 years ago
readme.txt
2 years ago
cost-calculator-for-elementor.php
140 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Cost Calculator For Elementor |
| 4 | * Plugin URI: https://add-ons.org/plugin/elementor-forms-cost-calculator/ |
| 5 | * Description: Create forms with field values calculated based in other form field values for Elementor |
| 6 | * Version: 1.2.8 |
| 7 | * Author: add-ons.org |
| 8 | * Requires Plugins: elementor |
| 9 | * Text Domain: cost-calculator-for-elementor |
| 10 | * Domain Path: /languages |
| 11 | * Elementor tested up to: 3.20.1 |
| 12 | * Author URI: https://add-ons.org/ |
| 13 | */ |
| 14 | define( 'ELEMENTOR_COST_CALCULATOR_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 15 | define( 'ELEMENTOR_COST_CALCULATOR_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 16 | class Eelementor_Cost_Calculator_Init { |
| 17 | function __construct(){ |
| 18 | add_action("elementor/frontend/after_register_scripts",array($this,"add_lib")); |
| 19 | add_action("elementor/editor/before_enqueue_scripts",array($this,"add_lib_backend")); |
| 20 | add_action( 'elementor/widgets/register', array($this,'register_calculator_widget') ); |
| 21 | add_action( 'elementor_pro/init', array($this,'add_form_pro') ); |
| 22 | } |
| 23 | function register_calculator_widget($widgets_manager){ |
| 24 | include ELEMENTOR_COST_CALCULATOR_PLUGIN_PATH."free/number.php"; |
| 25 | include ELEMENTOR_COST_CALCULATOR_PLUGIN_PATH."free/total.php"; |
| 26 | $widgets_manager->register( new \Number_Format_Cost_Calculator_Widget() ); |
| 27 | $widgets_manager->register( new \Total_Format_Cost_Calculator_Widget() ); |
| 28 | } |
| 29 | function add_form_pro(){ |
| 30 | include ELEMENTOR_COST_CALCULATOR_PLUGIN_PATH."fields/number_formats.php"; |
| 31 | include ELEMENTOR_COST_CALCULATOR_PLUGIN_PATH."fields/total.php"; |
| 32 | include ELEMENTOR_COST_CALCULATOR_PLUGIN_PATH."superaddons/check_purchase_code.php"; |
| 33 | new Superaddons_Check_Purchase_Code( |
| 34 | array("plugin" => "cost-calculator-for-elementor/cost-calculator-for-elementor.php", |
| 35 | "id"=>"1529", |
| 36 | "pro"=>"https://add-ons.org/plugin/elementor-forms-cost-calculator/", |
| 37 | "plugin_name"=> "Cost Calculator For Elementor", |
| 38 | "document"=> "https://add-ons.org/demo-wpforms-cost-calculator/", |
| 39 | ) |
| 40 | ); |
| 41 | } |
| 42 | function add_lib_backend(){ |
| 43 | wp_enqueue_style( |
| 44 | 'tribute', |
| 45 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/tribute/tribute.css' |
| 46 | ); |
| 47 | wp_enqueue_script( |
| 48 | 'tribute', |
| 49 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/tribute/tribute.js', |
| 50 | ); |
| 51 | wp_enqueue_script( |
| 52 | 'elementor-calculator', |
| 53 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/calculator_editor.js', |
| 54 | array("jquery","tribute"), |
| 55 | '1.0', |
| 56 | true |
| 57 | ); |
| 58 | $check = get_option( '_redmuber_item_1529'); |
| 59 | $datas = array(); |
| 60 | $datas_done = array(); |
| 61 | $text_pro = ""; |
| 62 | $disable_pro = ""; |
| 63 | if($check != "ok"){ |
| 64 | $text_pro = "-Pro version"; |
| 65 | $disable_pro = " disabled"; |
| 66 | } |
| 67 | $datas[] = array("key"=>"if( condition, true, false)", "value"=>"if( condition, true, false)"); |
| 68 | $datas[] = array("key"=>"if( condition, true, if(condition, true, false))", "value"=>"if( condition, true, if( condition, true, false))"); |
| 69 | $datas[] = array("key"=>"days( date_end, date_start)", "value"=>"days( end, start)"); |
| 70 | $datas[] = array("key"=>"months( date_end, date_start)", "value"=>"months( end, start)"); |
| 71 | $datas[] = array("key"=>"years( date_end, date_start)", "value"=>"years( end, start)"); |
| 72 | $datas[] = array("key"=>"round( number )", "value"=>"round( number )"); |
| 73 | $datas[] = array("key"=>"round2( number, decimal)", "value"=>"round2( number, 2)"); |
| 74 | $datas[] = array("key"=>"floor( number )", "value"=>"floor( number )"); |
| 75 | $datas[] = array("key"=>"floor2( number, decimal)", "value"=>"floor2( number, 2)"); |
| 76 | $datas[] = array("key"=>"ceil( number )", "value"=>"ceil( number )"); |
| 77 | $datas[] = array("key"=>"mod( number % number)", "value"=>"mod( number, number)"); |
| 78 | $datas[] = array("key"=>"age( Birth date )", "value"=>"age()"); |
| 79 | $datas[] = array("key"=>"age2( Birth date, Age at the Date of)", "value"=>"age2( birth_date, date)"); |
| 80 | $datas[] = array("key"=>"now (Current date)", "value"=>"now"); |
| 81 | |
| 82 | $datas[] = array("key"=>"==", "value"=>"=="); |
| 83 | $datas[] = array("key"=>"pi = 3.14", "value"=>"pi"); |
| 84 | $datas[] = array("key"=>"e = 2.71", "value"=>"e"); |
| 85 | $datas[] = array("key"=>"abs( -3 ) = 3", "value"=>"abs( number )"); |
| 86 | $datas[] = array("key"=>"sqrt( 16 ) = 4", "value"=>"sqrt( number )"); |
| 87 | $datas[] = array("key"=>"sin( 0 ) = 0", "value"=>"sin( number )"); |
| 88 | $datas[] = array("key"=>"cos( 0 ) = 1", "value"=>"cos( number )"); |
| 89 | $datas[] = array("key"=>"pow( 2,3 ) = 8", "value"=>"pow( number , number )"); |
| 90 | $datas[] = array("key"=>"random( number start , number end ) ", "value"=>"random( number, number )"); |
| 91 | $datas[] = array("key"=>"mod( 2,3) = 1", "value"=>"mod( number, number )"); |
| 92 | $datas[] = array("key"=>"avg( 10,20,60,...) = 30", "value"=>"avg( number, number )"); |
| 93 | $datas[] = array("key"=>"min( number 1, number 2, ...)", "value"=>"min( number1, number2)"); |
| 94 | $datas[] = array("key"=>"max( number 1, number 2, ...)", "value"=>"max( number1, number2)"); |
| 95 | foreach( $datas as $data ){ |
| 96 | $datas_done[] = array("key"=>$data["key"].$text_pro,"value"=>$data["value"]); |
| 97 | } |
| 98 | $datas_done[] = array("key"=>"a + b", "value"=>"+"); |
| 99 | $datas_done[] = array("key"=>"a - b", "value"=>"-"); |
| 100 | $datas_done[] = array("key"=>"a / b", "value"=>"/"); |
| 101 | $datas_done[] = array("key"=>"a * b", "value"=>"*"); |
| 102 | wp_localize_script( "elementor-calculator", "elementor_calculator", array("data"=>$datas_done) ); |
| 103 | } |
| 104 | function add_lib(){ |
| 105 | wp_enqueue_script( |
| 106 | 'evaluator', |
| 107 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/formula_evaluator-min.js', |
| 108 | array("jquery"), |
| 109 | '1.3.8', |
| 110 | true |
| 111 | ); |
| 112 | wp_enqueue_script( |
| 113 | 'autoNumeric', |
| 114 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/autoNumeric-1.9.45.js', |
| 115 | array("jquery"), |
| 116 | '1.9.45', |
| 117 | true |
| 118 | ); |
| 119 | wp_enqueue_script( |
| 120 | 'tribute', |
| 121 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/tribute/tribute.js', |
| 122 | ); |
| 123 | wp_enqueue_script( |
| 124 | 'elementor-calculator', |
| 125 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/calculator.js', |
| 126 | array("jquery","evaluator","autoNumeric","tribute"), |
| 127 | '1.0', |
| 128 | true |
| 129 | ); |
| 130 | wp_enqueue_style( |
| 131 | 'elementor-calculator', |
| 132 | ELEMENTOR_COST_CALCULATOR_PLUGIN_URL . 'libs/calculator.css' |
| 133 | ); |
| 134 | |
| 135 | } |
| 136 | } |
| 137 | new Eelementor_Cost_Calculator_Init; |
| 138 | if(!class_exists('Superaddons_List_Addons')) { |
| 139 | include ELEMENTOR_COST_CALCULATOR_PLUGIN_PATH."add-ons.php"; |
| 140 | } |