From 25b0e4823411c4cb4a8cab6d14fea843670b6886 Mon Sep 17 00:00:00 2001 From: Tunbosun Ayinla Date: Tue, 19 Sep 2023 10:04:22 +0100 Subject: [PATCH 1/6] Refactor add metaboxes and register cpt --- admin/class-paystack-forms-cpt.php | 333 ++++++++++++++++++ .../partials/metaboxes/agreement-checkbox.php | 35 ++ .../metaboxes/email-receipt-settings.php | 85 +++++ .../metaboxes/extra-form-description.php | 194 ++++++++++ admin/partials/metaboxes/plan-start-date.php | 41 +++ admin/partials/metaboxes/quantity-payment.php | 123 +++++++ .../partials/metaboxes/recurring-payment.php | 34 ++ admin/partials/metaboxes/sub-account.php | 43 +++ 8 files changed, 888 insertions(+) create mode 100644 admin/class-paystack-forms-cpt.php create mode 100644 admin/partials/metaboxes/agreement-checkbox.php create mode 100644 admin/partials/metaboxes/email-receipt-settings.php create mode 100644 admin/partials/metaboxes/extra-form-description.php create mode 100644 admin/partials/metaboxes/plan-start-date.php create mode 100644 admin/partials/metaboxes/quantity-payment.php create mode 100644 admin/partials/metaboxes/recurring-payment.php create mode 100644 admin/partials/metaboxes/sub-account.php diff --git a/admin/class-paystack-forms-cpt.php b/admin/class-paystack-forms-cpt.php new file mode 100644 index 0000000..69d1a46 --- /dev/null +++ b/admin/class-paystack-forms-cpt.php @@ -0,0 +1,333 @@ +plugin_name = $plugin_name; + $this->version = $version; + } + + public function register_paystack_form_cpt() { + + $labels = array( + 'name' => _x( 'Paystack Forms', 'paystack_form', 'payment-forms-for-paystack' ), + 'singular_name' => _x( 'Paystack Form', 'paystack_form', 'payment-forms-for-paystack' ), + 'add_new' => _x( 'Add New', 'paystack_form', 'payment-forms-for-paystack' ), + 'add_new_item' => _x( 'Add Paystack Form', 'paystack_form', 'payment-forms-for-paystack' ), + 'edit_item' => _x( 'Edit Paystack Form', 'paystack_form', 'payment-forms-for-paystack' ), + 'new_item' => _x( 'Paystack Form', 'paystack_form', 'payment-forms-for-paystack' ), + 'view_item' => _x( 'View Paystack Form', 'paystack_form', 'payment-forms-for-paystack' ), + 'all_items' => _x( 'All Forms', 'paystack_form', 'payment-forms-for-paystack' ), + 'search_items' => _x( 'Search Paystack Forms', 'paystack_form', 'payment-forms-for-paystack' ), + 'not_found' => _x( 'No Paystack Forms found', 'paystack_form', 'payment-forms-for-paystack' ), + 'not_found_in_trash' => _x( 'No Paystack Forms found in Trash', 'paystack_form', 'payment-forms-for-paystack' ), + 'parent_item_colon' => _x( 'Parent Paystack Form:', 'paystack_form', 'payment-forms-for-paystack' ), + 'menu_name' => _x( 'Paystack Forms', 'paystack_form', 'payment-forms-for-paystack' ), + ); + + $args = array( + 'labels' => $labels, + 'hierarchical' => true, + 'description' => __( 'Paystack Forms filterable by genre', 'payment-forms-for-paystack' ), + 'supports' => array( 'title', 'editor' ), + 'public' => true, + 'show_ui' => true, + 'show_in_menu' => true, + 'menu_position' => 5, + 'menu_icon' => plugins_url( '../images/logo.png', __FILE__ ), + 'show_in_nav_menus' => false, + 'publicly_queryable' => false, + 'exclude_from_search' => true, + 'has_archive' => false, + 'query_var' => true, + 'can_export' => true, + 'rewrite' => false, + 'comments' => false, + 'capability_type' => 'post', + ); + + register_post_type( 'paystack_form', $args ); + } + + public function save_payment_form_data( $post_id ) { + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { + return; + } + + if ( empty( $_POST['payment_forms_for_paystack_nonce'] ) ) { + return; + } + + if ( ! wp_verify_nonce( $_POST['payment_forms_for_paystack_nonce'], 'payment-forms-for-paystack-nonce' ) ) { + return; + } + + $post = get_post( $post_id ); + + if ( empty( $post ) ) { + return; + } + + // Is the user allowed to edit the post or page? + if ( ! current_user_can( 'edit_post', $post->ID ) ) { + return; + } + + $form_meta['_inventory'] = $_POST['_inventory'] ?? '0'; + $form_meta['_useinventory'] = $_POST['_inventory'] ?? '0'; + $form_meta['_amount'] = $_POST['_amount']; + $form_meta['_hidetitle'] = $_POST['_hidetitle'] ?? '0'; + $form_meta['_minimum'] = $_POST['_minimum'] ?? '0'; + + $form_meta['_variableamount'] = $_POST['_variableamount']; + $form_meta['_usevariableamount'] = $_POST['_usevariableamount'] ?? '0'; + + $form_meta['_paybtn'] = $_POST['_paybtn']; + $form_meta['_currency'] = $_POST['_currency']; + $form_meta['_successmsg'] = $_POST['_successmsg']; + $form_meta['_txncharge'] = $_POST['_txncharge']; + $form_meta['_loggedin'] = $_POST['_loggedin']; + $form_meta['_filelimit'] = $_POST['_filelimit']; + $form_meta['_redirect'] = $_POST['_redirect']; + + $form_meta['_subject'] = $_POST['_subject']; + $form_meta['_merchant'] = $_POST['_merchant']; + $form_meta['_heading'] = $_POST['_heading']; + $form_meta['_message'] = $_POST['_message']; + $form_meta['_sendreceipt'] = $_POST['_sendreceipt']; + $form_meta['_sendinvoice'] = $_POST['_sendinvoice']; + + $form_meta['_recur'] = $_POST['_recur']; + $form_meta['_recurplan'] = $_POST['_recurplan']; + $form_meta['_usequantity'] = $_POST['_usequantity']; + $form_meta['_quantity'] = $_POST['_quantity'] ?? '1'; + $form_meta['_sold'] = $_POST['_sold'] ?? '0'; + $form_meta['_quantityunit'] = $_POST['_quantityunit'] ?? __( 'Quantity', 'payment-forms-for-paystack' ); + + $form_meta['_useagreement'] = $_POST['_useagreement']; + $form_meta['_agreementlink'] = $_POST['_agreementlink']; + $form_meta['_subaccount'] = $_POST['_subaccount']; + $form_meta['_txnbearer'] = $_POST['_txnbearer']; + $form_meta['_merchantamount'] = $_POST['_merchantamount']; + // Add values of $form_meta as custom fields + + //Custom Plan with Start Date + $form_meta['_startdate_days'] = $_POST['_startdate_days']; + $form_meta['_startdate_plan_code'] = $_POST['_startdate_plan_code']; + $form_meta['_startdate_enabled'] = $_POST['_startdate_enabled'] ?? '0'; + + foreach ( $form_meta as $key => $value ) { // Cycle through the $form_meta array! + if ( 'revision' === $post->post_type ) { + return; // Don't store custom data twice + } + $value = implode( ',', (array) $value ); // If $value is an array, make it a CSV (unlikely) + if ( get_post_meta( $post->ID, $key, false ) ) { // If the custom field already has a value + update_post_meta( $post->ID, $key, $value ); + } else { // If the custom field doesn't have a value + add_post_meta( $post->ID, $key, $value ); + } + if ( ! $value ) { + delete_post_meta( $post->ID, $key ); // Delete if blank + } + } + } + + public function disable_wyswyg( $default ) { + + global $post_type; + + if ( 'paystack_form' === $post_type ) { + echo ''; + add_filter( 'user_can_richedit', '__return_false', 50 ); + remove_action( 'media_buttons', 'media_buttons' ); + add_filter( 'quicktags_settings', array( $this, 'remove_fullscreen_quicktag' ) ); + } + + return $default; + } + + public function remove_fullscreen_quicktag( $qt_init ) { + $qt_init['buttons'] = 'fullscreen'; + return $qt_init; + } + + public function add_help_section_meta_box( $post ) { + do_meta_boxes( null, 'paystack_payment_forms_cpt_meta_box', $post ); + } + + public function help_section_meta_box() { + ?> + +
+

+

+ required="required" to the shortcode', 'payment-forms-for-paystack' ), + array( + 'code' => array(), + ) + ) + ?> +

+

+ [text name="Full Name" required="required" ]', 'payment-forms-for-paystack' ), + array( + 'code' => array(), + ) + ) + ?> +

+

+ Warning: Using the file input field may cause data overload on your server. Be sure you have enough server space before using it. You also have the ability to set file upload limits', 'payment-forms-for-paystack' ), + array( + 'strong' => array( + 'style' => array(), + ), + ) + ) + ?> +

+
+ +

+ + + + +

+ + version, + true, + ); + } +} diff --git a/admin/partials/metaboxes/agreement-checkbox.php b/admin/partials/metaboxes/agreement-checkbox.php new file mode 100644 index 0000000..7555744 --- /dev/null +++ b/admin/partials/metaboxes/agreement-checkbox.php @@ -0,0 +1,35 @@ +ID, '_useagreement', true ); +$agreementlink = get_post_meta( $post->ID, '_agreementlink', true ); + +if ( empty( $useagreement ) ) { + $useagreement = 'no'; +} +if ( empty( $agreementlink ) ) { + $agreementlink = ''; +} +?> + +
+

+ +

+ +
+ +
+

+ +

+ +
diff --git a/admin/partials/metaboxes/email-receipt-settings.php b/admin/partials/metaboxes/email-receipt-settings.php new file mode 100644 index 0000000..917bf0d --- /dev/null +++ b/admin/partials/metaboxes/email-receipt-settings.php @@ -0,0 +1,85 @@ +ID, '_subject', true ); +$merchant = get_post_meta( $post->ID, '_merchant', true ); +$heading = get_post_meta( $post->ID, '_heading', true ); +$message = get_post_meta( $post->ID, '_message', true ); +$send_receipt = get_post_meta( $post->ID, '_sendreceipt', true ); +$send_invoice = get_post_meta( $post->ID, '_sendinvoice', true ); + +if ( empty( $subject ) ) { + $subject = __( 'Thank you for your payment', 'payment-forms-for-paystack' ); +} +if ( empty( $send_receipt ) ) { + $send_receipt = 'yes'; +} +if ( empty( $send_invoice ) ) { + $send_invoice = 'yes'; +} +if ( empty( $heading ) ) { + $heading = __( 'We’ve received your payment', 'payment-forms-for-paystack' ); +} +if ( empty( $message ) ) { + $message = __( 'Your payment was received and we appreciate it.', 'payment-forms-for-paystack' ); +} +?> + +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
diff --git a/admin/partials/metaboxes/extra-form-description.php b/admin/partials/metaboxes/extra-form-description.php new file mode 100644 index 0000000..5590760 --- /dev/null +++ b/admin/partials/metaboxes/extra-form-description.php @@ -0,0 +1,194 @@ +ID, '_amount', true ); +$paybtn = get_post_meta( $post->ID, '_paybtn', true ); +$successmsg = get_post_meta( $post->ID, '_successmsg', true ); +$txncharge = get_post_meta( $post->ID, '_txncharge', true ); +$loggedin = get_post_meta( $post->ID, '_loggedin', true ); +$currency = get_post_meta( $post->ID, '_currency', true ); +$filelimit = get_post_meta( $post->ID, '_filelimit', true ); +$redirect = get_post_meta( $post->ID, '_redirect', true ); +$minimum = get_post_meta( $post->ID, '_minimum', true ); +$usevariableamount = get_post_meta( $post->ID, '_usevariableamount', true ); +$variableamount = get_post_meta( $post->ID, '_variableamount', true ); +$hidetitle = get_post_meta( $post->ID, '_hidetitle', true ); + +if ( empty( $amount ) ) { + $amount = 0; +} +if ( empty( $filelimit ) ) { + $filelimit = 2; +} +if ( empty( $paybtn ) ) { + $paybtn = 'Pay'; +} +if ( empty( $successmsg ) ) { + $successmsg = 'Thank you for paying!'; +} +if ( empty( $currency ) ) { + $currency = 'NGN'; +} +if ( empty( $txncharge ) ) { + $txncharge = 'merchant'; +} +if ( empty( $minimum ) ) { + $minimum = 0; +} +if ( empty( $usevariableamount ) ) { + $usevariableamount = 0; +} +if ( empty( $hidetitle ) ) { + $hidetitle = 0; +} +?> + +
+

+ +

+
+ +
+

+ +

+ +

+ + here for more information.', 'payment-forms-for-paystack' ), + array( + 'a' => array( + 'href' => array(), + 'target' => array(), + ), + ) + ) + ?> + +

+
+ +
+

+ +

+ + + +
+ +
+
+ +
+

+ +

+ +
+ +
+
+ +
+

+ +

+ +
+ +
+

+ +

+ +

+ + Configure', 'payment-forms-for-paystack' ), + array( + 'a' => array( + 'href' => array(), + 'target' => array(), + ), + ) + ), + esc_url( get_admin_url() . 'edit.php?post_type=paystack_form&page=class-paystack-forms-admin.php#paystack_setting_fees' ) + ); + ?> + +

+
+ +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
diff --git a/admin/partials/metaboxes/plan-start-date.php b/admin/partials/metaboxes/plan-start-date.php new file mode 100644 index 0000000..246617d --- /dev/null +++ b/admin/partials/metaboxes/plan-start-date.php @@ -0,0 +1,41 @@ +ID, '_startdate_days', true ); +$plan = get_post_meta( $post->ID, '_startdate_plan_code', true ); +$enabled = get_post_meta( $post->ID, '_startdate_enabled', true ); + +if ( empty( $days ) ) { + $days = ''; +} +if ( empty( $plan ) ) { + $plan = ''; +} +if ( empty( $enabled ) ) { + $enabled = 0; +} +?> + +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+
diff --git a/admin/partials/metaboxes/quantity-payment.php b/admin/partials/metaboxes/quantity-payment.php new file mode 100644 index 0000000..b3f416a --- /dev/null +++ b/admin/partials/metaboxes/quantity-payment.php @@ -0,0 +1,123 @@ +ID, '_usequantity', true ); +$useinventory = get_post_meta( $post->ID, '_useinventory', true ); +$inventory = get_post_meta( $post->ID, '_inventory', true ); +$sold = get_post_meta( $post->ID, '_sold', true ); +$quantity = get_post_meta( $post->ID, '_quantity', true ); +$quantityunit = get_post_meta( $post->ID, '_quantityunit', true ); +$recur = get_post_meta( $post->ID, '_recur', true ); + +if ( empty( $usequantity ) ) { + $usequantity = 'no'; +} +if ( empty( $useinventory ) ) { + $useinventory = 'no'; +} +if ( empty( $quantity ) ) { + $quantity = '1'; +} +if ( empty( $inventory ) ) { + if ( '' !== $sold ) { + $inventory = $sold; + } else { + $inventory = '1'; + } +} +if ( empty( $sold ) ) { + $sold = '0'; +} +$stock = $inventory - $sold; +if ( empty( $quantityunit ) ) { + $quantityunit = __( 'Quantity', 'payment-forms-for-paystack' ); +} +?> + +
+

+ +

+ + + + + +

+

+ + + +
+

+ +

+ +

+

+
+ +
+

+ +

+ +

+ + Quantity', 'payment-forms-for-paystack' ), + array( + 'code' => array(), + ) + ) + ?> + +

+
+ +
+

+ +

+ +
+ + + + + +
+

+ +

+ +
+ +
+

+ +

+ +
+ + diff --git a/admin/partials/metaboxes/recurring-payment.php b/admin/partials/metaboxes/recurring-payment.php new file mode 100644 index 0000000..0af4c9e --- /dev/null +++ b/admin/partials/metaboxes/recurring-payment.php @@ -0,0 +1,34 @@ +ID, '_recur', true ); +$recurplan = get_post_meta( $post->ID, '_recurplan', true ); + +if ( empty( $recur ) ) { + $recur = 'no'; +} +if ( empty( $recurplan ) ) { + $recurplan = ''; +} +?> + +
+

+ +

+ +
+ +
+

+ +

+ +

+

+
diff --git a/admin/partials/metaboxes/sub-account.php b/admin/partials/metaboxes/sub-account.php new file mode 100644 index 0000000..581ef4a --- /dev/null +++ b/admin/partials/metaboxes/sub-account.php @@ -0,0 +1,43 @@ +ID, '_subaccount', true ); +$txnbearer = get_post_meta( $post->ID, '_txnbearer', true ); +$merchantamount = get_post_meta( $post->ID, '_merchantamount', true ); + +if ( empty( $subaccount ) ) { + $subaccount = ''; +} +if ( empty( $merchantamount ) ) { + $merchantamount = ''; +} +?> + +
+

+ +

+ +
+ +
+

+ +

+ +
+ +
+

+ +

+ +
From 87524e293b7da6fa27cb04850ef67f58984c3ec1 Mon Sep 17 00:00:00 2001 From: Tunbosun Ayinla Date: Tue, 19 Sep 2023 10:04:57 +0100 Subject: [PATCH 2/6] Add quicktags.js script --- admin/js/quicktags.js | 93 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 admin/js/quicktags.js diff --git a/admin/js/quicktags.js b/admin/js/quicktags.js new file mode 100644 index 0000000..1d5f7e2 --- /dev/null +++ b/admin/js/quicktags.js @@ -0,0 +1,93 @@ +//this function is used to retrieve the selected text from the text editor +function getSel() { + var txtarea = document.getElementById( "content" ); + var start = txtarea.selectionStart; + var finish = txtarea.selectionEnd; + return txtarea.value.substring( start, finish ); +} + +QTags.addButton( + "t_shortcode", + "Insert Text", + insertText +); + +function insertText() { + QTags.insertContent( '[text name="Text Title"]' ); +} +QTags.addButton( + "ta_shortcode", + "Insert Textarea", + insertTextarea +); + +function insertTextarea() { + QTags.insertContent( '[textarea name="Text Title"]' ); +} +QTags.addButton( + "s_shortcode", + "Insert Select Dropdown", + insertSelectb +); + +function insertSelectb() { + QTags.insertContent( '[select name="Text Title" options="option 1,option 2,option 3"]' ); +} +QTags.addButton( + "r_shortcode", + "Insert Radio Options", + insertRadiob +); + +function insertRadiob() { + QTags.insertContent( '[radio name="Text Title" options="option 1,option 2,option 3"]' ); +} +QTags.addButton( + "cb_shortcode", + "Insert Checkbox Options", + insertCheckboxb +); + +function insertCheckboxb() { + QTags.insertContent( '[checkbox name="Text Title" options="option 1,option 2,option 3"]' ); +} +QTags.addButton( + "dp_shortcode", + "Insert Datepicker", + insertDatepickerb +); + +function insertDatepickerb() { + QTags.insertContent( '[datepicker name="Datepicker Title"]' ); +} +QTags.addButton( + "i_shortcode", + "Insert File Upload", + insertInput +); + +function insertInput() { + QTags.insertContent( '[input name="File Name"]' ); +} +QTags.addButton( + "ngs_shortcode", + "Insert Nigerian States", + insertSelectStates +); + +function insertSelectStates() { + QTags.insertContent( + '[select name="State" options="Abia,Adamawa,Akwa Ibom,Anambra,Bauchi,Bayelsa,Benue,Borno,Cross River,Delta,Ebonyi,Edo,Ekiti,Enugu,FCT,Gombe,Imo,Jigawa,Kaduna,Kano,Katsina,Kebbi,Kogi,Kwara,Lagos,Nasarawa,Niger,Ogun,Ondo,Osun,Oyo,Plateau,Rivers,Sokoto,Taraba,Yobe,Zamfara"]' + ); +} +QTags.addButton( + "ctys_shortcode", + "Insert All Countries", + insertSelectCountries +); + +function insertSelectCountries() { + QTags.insertContent( + '[select name="country" options="Afghanistan, Albania, Algeria, American Samoa, Andorra, Angola, Anguilla, Antarctica, Antigua and Barbuda, Argentina, Armenia, Aruba, Australia, Austria, Azerbaijan, Bahamas, Bahrain, Bangladesh, Barbados, Belarus, Belgium, Belize, Benin, Bermuda, Bhutan, Bolivia, Bosnia and Herzegovina, Botswana, Bouvet Island, Brazil, British Indian Ocean Territory, Brunei Darussalam, Bulgaria, Burkina Faso, Burundi, Cambodia, Cameroon, Canada, Cape Verde, Cayman Islands, Central African Republic, Chad, Chile, China, Christmas Island, Cocos (Keeling) Islands, Colombia, Comoros, Congo, Congo, The Democratic Republic of The, Cook Islands, Costa Rica, Cote D’ivoire, Croatia, Cuba, Cyprus, Czech Republic, Denmark, Djibouti, Dominica, Dominican Republic, Ecuador, Egypt, El Salvador, Equatorial Guinea, Eritrea, Estonia, Ethiopia, Falkland Islands (Malvinas), Faroe Islands, Fiji, Finland, France, French Guiana, French Polynesia, French Southern Territories, Gabon, Gambia, Georgia, Germany, Ghana, Gibraltar, Greece, Greenland, Grenada, Guadeloupe, Guam, Guatemala, Guinea, Guinea-bissau, Guyana, Haiti, Heard Island and Mcdonald Islands, Holy See (Vatican City State), Honduras, Hong Kong, Hungary, Iceland, India, Indonesia, Iran, Islamic Republic of, Iraq, Ireland, Israel, Italy, Jamaica, Japan, Jordan, Kazakhstan, Kenya, Kiribati, Korea, Democratic People’s Republic of, Korea, Republic of, Kuwait, Kyrgyzstan, Lao People’s Democratic Republic, Latvia, Lebanon, Lesotho, Liberia, Libyan Arab Jamahiriya, Liechtenstein, Lithuania, Luxembourg, Macao, Macedonia, The Former Yugoslav Republic of, Madagascar, Malawi, Malaysia, Maldives, Mali, Malta, Marshall Islands, Martinique, Mauritania, Mauritius, Mayotte, Mexico, Micronesia, Federated States of, Moldova, Republic of, Monaco, Mongolia, Montserrat, Morocco, Mozambique, Myanmar, Namibia, Nauru, Nepal, Netherlands, Netherlands Antilles, New Caledonia, New Zealand, Nicaragua, Niger, Nigeria, Niue, Norfolk Island, Northern Mariana Islands, Norway, Oman, Pakistan, Palau, Palestinian Territory, Occupied, Panama, Papua New Guinea, Paraguay, Peru, Philippines, Pitcairn, Poland, Portugal, Puerto Rico, Qatar, Reunion, Romania, Russian Federation, Rwanda, Saint Helena, Saint Kitts and Nevis, Saint Lucia, Saint Pierre and Miquelon, Saint Vincent and The Grenadines, Samoa, San Marino, Sao Tome and Principe, Saudi Arabia, Senegal, Serbia and Montenegro, Seychelles, Sierra Leone, Singapore, Slovakia, Slovenia, Solomon Islands, Somalia, South Africa, South Georgia and The South Sandwich Islands, Spain, Sri Lanka, Sudan, Suriname, Svalbard and Jan Mayen, Swaziland, Sweden, Switzerland, Syrian Arab Republic, Taiwan, Province of China, Tajikistan, Tanzania, United Republic of, Thailand, Timor-leste, Togo, Tokelau, Tonga, Trinidad and Tobago, Tunisia, Turkey, Turkmenistan, Turks and Caicos Islands, Tuvalu, Uganda, Ukraine, United Arab Emirates, United Kingdom, United States, United States Minor Outlying Islands, Uruguay, Uzbekistan, Vanuatu, Venezuela, Viet Nam, Virgin Islands, British, Virgin Islands, U.S., Wallis and Futuna, Western Sahara, Yemen, Zambia, Zimbabwe"] ' + ); +} \ No newline at end of file From 8e7a5c6ca2b5528acf8c26aeb4192ee6b33c0ebb Mon Sep 17 00:00:00 2001 From: Tunbosun Ayinla Date: Tue, 19 Sep 2023 10:11:36 +0100 Subject: [PATCH 3/6] Remove unused file --- ...s-paystack-forms-public-for-old-themes.php | 1932 ----------------- 1 file changed, 1932 deletions(-) delete mode 100644 public/class-paystack-forms-public-for-old-themes.php diff --git a/public/class-paystack-forms-public-for-old-themes.php b/public/class-paystack-forms-public-for-old-themes.php deleted file mode 100644 index d1fac5e..0000000 --- a/public/class-paystack-forms-public-for-old-themes.php +++ /dev/null @@ -1,1932 +0,0 @@ -plugin_name = $plugin_name; - $this->version = $version; - } - public function enqueue_styles() - { - wp_enqueue_style($this->plugin_name.'1', plugin_dir_url(__FILE__) . 'css/pff-paystack-style.css', array(), $this->version, 'all'); - wp_enqueue_style($this->plugin_name.'2', plugin_dir_url(__FILE__) . 'css/font-awesome.min.css', array(), $this->version, 'all'); - } - - public static function fetchPublicKey() - { - $mode = esc_attr(get_option('mode')); - if ($mode == 'test') { - $key = esc_attr(get_option('tpk')); - } else { - $key = esc_attr(get_option('lpk')); - } - return $key; - } - - public static function fetchFeeSettings() - { - $ret = []; - $ret['prc'] = intval(floatval(esc_attr(get_option('prc', 1.5))) * 100) / 10000; - $ret['ths'] = intval(floatval(esc_attr(get_option('ths', 2500))) * 100); - $ret['adc'] = intval(floatval(esc_attr(get_option('adc', 100))) * 100); - $ret['cap'] = intval(floatval(esc_attr(get_option('cap', 2000))) * 100); - return $ret; - } - - public function enqueue_scripts() - { - wp_enqueue_script('blockUI', plugin_dir_url(__FILE__) . 'js/jquery.blockUI.min.js', false, $this->version); - wp_enqueue_script('jquery-ui-core'); - wp_register_script('Paystack', 'https://js.paystack.co/v1/inline.js', false, '1'); - wp_enqueue_script('Paystack'); - wp_enqueue_script('paystack_frontend', plugin_dir_url(__FILE__) . 'js/paystack-forms-public.js', false, $this->version); - wp_localize_script('paystack_frontend', 'kkd_pff_settings', array('key'=> Kkd_Pff_Paystack_Public::fetchPublicKey(), 'fee'=>Kkd_Pff_Paystack_Public::fetchFeeSettings()), $this->version, true, true); - } -} - -define('KKD_PFF_PAYSTACK_PERCENTAGE', 0.015); -define('KKD_PFF_PAYSTACK_CROSSOVER_TOTAL', 250000); -define('KKD_PFF_PAYSTACK_ADDITIONAL_CHARGE', 10000); -define('KKD_PFF_PAYSTACK_LOCAL_CAP', 200000); - -define('KKD_PFF_PAYSTACK_CHARGE_DIVIDER', floatval(1-KKD_PFF_PAYSTACK_PERCENTAGE)); -define('KKD_PFF_PAYSTACK_CROSSOVER_AMOUNT', intval((KKD_PFF_PAYSTACK_CROSSOVER_TOTAL*KKD_PFF_PAYSTACK_CHARGE_DIVIDER)-KKD_PFF_PAYSTACK_ADDITIONAL_CHARGE)); -define('KKD_PFF_PAYSTACK_FLATLINE_AMOUNT_PLUS_CHARGE', intval((KKD_PFF_PAYSTACK_LOCAL_CAP-KKD_PFF_PAYSTACK_ADDITIONAL_CHARGE)/KKD_PFF_PAYSTACK_PERCENTAGE)); -define('KKD_PFF_PAYSTACK_FLATLINE_AMOUNT', KKD_PFF_PAYSTACK_FLATLINE_AMOUNT_PLUS_CHARGE - KKD_PFF_PAYSTACK_LOCAL_CAP); - -function kkd_pff_paystack_add_paystack_charge($amount) -{ - // $amountinkobo = $amount; // * 100; - $charge = 0; - $amount = intval($amount); - if ($amount <= 2500) { - $charge = floatval($amount*KKD_PFF_PAYSTACK_PERCENTAGE); - } else { - $charge = floatval($amount*KKD_PFF_PAYSTACK_PERCENTAGE)+100; - } - // echo $charge; - if ($charge > 2000) { - $charge = 2000; - } - $amount += $charge; - return $amount; - // if ($amountinkobo > KKD_PFF_PAYSTACK_FLATLINE_AMOUNT) - // return ($amountinkobo + KKD_PFF_PAYSTACK_LOCAL_CAP)/100; - // elseif ($amountinkobo > KKD_PFF_PAYSTACK_CROSSOVER_AMOUNT) - // return (intval(($amountinkobo + KKD_PFF_PAYSTACK_ADDITIONAL_CHARGE) / KKD_PFF_PAYSTACK_CHARGE_DIVIDER))/100; - // else - // return (intval($amountinkobo / KKD_PFF_PAYSTACK_CHARGE_DIVIDER))/100; -} - -add_filter("wp_mail_content_type", "kkd_pff_paystack_mail_content_type"); -function kkd_pff_paystack_mail_content_type() -{ - return "text/html"; -} -add_filter("wp_mail_from_name", "kkd_pff_paystack_mail_from_name"); -function kkd_pff_paystack_mail_from_name() -{ - $name = get_option('blogname'); - return $name; -} - - -function kkd_pff_paystack_send_invoice($currency, $amount, $name, $email, $code) -{ - // echo date('F j,Y'); - $user_email = stripslashes($email); - - $email_subject = "Payment Invoice for ".$currency.' '.number_format($amount); - - ob_start(); ?> - - - - - - - - - - - - - - - - - - - " . "\r\n"); - $headers = "From: ".$website."<$admin_email>" . "\r\n"; - wp_mail($user_email, $email_subject, $message, $headers); -} -function kkd_pff_paystack_send_receipt($id, $currency, $amount, $name, $email, $code, $metadata) -{ - // echo date('F j,Y'); - $user_email = stripslashes($email); - $subject = get_post_meta($id, '_subject', true); - $merchant = get_post_meta($id, '_merchant', true); - $heading = get_post_meta($id, '_heading', true); - $sitemessage = get_post_meta($id, '_message', true); - - $email_subject =$subject; - - ob_start(); ?> - - - - - - - - - - - - - - - - - - - - " . "\r\n"); - $headers = "From: ".$website."<$admin_email>" . "\r\n"; - wp_mail($user_email, $email_subject, $message, $headers); -} -function kkd_pff_paystack_send_receipt_owner($id, $currency, $amount, $name, $email, $code, $metadata) -{ - // echo date('F j,Y'); - $user_email = stripslashes($email); - $subject = "You just received a payment"; - $heading = get_post_meta($id, '_heading', true); - $sitemessage = get_post_meta($id, '_message', true); - - $email_subject =$subject; - - ob_start(); ?> - - - - - - - - - - - - - - - - - - - - " . "\r\n"); - $headers = "From: ".$website."<$admin_email>" . "\r\n"; - wp_mail($admin_email, $email_subject, $message, $headers); -} -function kkd_pff_paystack_fetch_plan($code) -{ - $mode = esc_attr(get_option('mode')); - if ($mode == 'test') { - $key = esc_attr(get_option('tsk')); - } else { - $key = esc_attr(get_option('lsk')); - } - $paystack_url = 'https://api.paystack.co/plan/' . $code; - $headers = array( - 'Authorization' => 'Bearer ' . $key - ); - $args = array( - 'headers' => $headers, - 'timeout' => 60 - ); - $request = wp_remote_get($paystack_url, $args); - if (! is_wp_error($request)) { - $paystack_response = json_decode(wp_remote_retrieve_body($request)); - } - return $paystack_response; -} -function kkd_pff_paystack_form_shortcode($atts) -{ - ob_start(); - - global $current_user; - $user_id = $current_user->ID; - $email = $current_user->user_email; - $fname = $current_user->user_firstname; - $lname = $current_user->user_lastname; - if ($fname == '' && $lname == '') { - $fullname = ''; - } else { - $fullname = $fname.' '.$lname; - } - extract( - shortcode_atts( - array( - 'id' => 0, - ), - $atts - ) - ); - $pk = Kkd_Pff_Paystack_Public::fetchPublicKey(); - if (!$pk) { - $settingslink = get_admin_url().'edit.php?post_type=paystack_form&page=class-paystack-forms-admin.php'; - echo "
You must set your Paystack API keys first settings
"; - } elseif ($id != 0) { - $obj = get_post($id); - if ($obj->post_type == 'paystack_form') { - $amount = get_post_meta($id, '_amount', true); - $thankyou = get_post_meta($id, '_successmsg', true); - $paybtn = get_post_meta($id, '_paybtn', true); - $loggedin = get_post_meta($id, '_loggedin', true); - $txncharge = get_post_meta($id, '_txncharge', true); - $currency = get_post_meta($id, '_currency', true); - $recur = get_post_meta($id, '_recur', true); - $recurplan = get_post_meta($id, '_recurplan', true); - $usequantity = get_post_meta($id, '_usequantity', true); - $quantity = get_post_meta($id, '_quantity', true); - $useagreement = get_post_meta($id, '_useagreement', true); - $agreementlink = get_post_meta($id, '_agreementlink', true); - $minimum = get_post_meta($id, '_minimum', true); - $variableamount = get_post_meta($id, '_variableamount', true); - $usevariableamount = get_post_meta($id, '_usevariableamount', true); - $hidetitle = get_post_meta($id, '_hidetitle', true); - if ($minimum == "") { - $minimum = 0; - } - if ($usevariableamount == "") { - $usevariableamount = 0; - } - - if ($usevariableamount == 1) { - $paymentoptions = explode(',', $variableamount); - // echo "
";
-                // print_r($paymentoptions);
-                // echo "
"; - // die(); - } - $showbtn = true; - $planerrorcode = 'Input Correct Recurring Plan Code'; - if ($recur == 'plan') { - if ($recurplan == '' || $recurplan == null) { - $showbtn = false; - } else { - $plan = kkd_pff_paystack_fetch_plan($recurplan); - if (isset($plan->data->amount)) { - $planamount = $plan->data->amount/100; - } else { - $showbtn = false; - } - } - } - if ((($user_id != 0) && ($loggedin == 'yes')) || $loggedin == 'no') { - if ($hidetitle != 1) { - echo "

".$obj->post_title."

"; - } - echo '
-
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
- -
- -
-
'; - echo '
- -
- -
-
'; - echo '
- -
'; - if ($usevariableamount == 0) { - if ($minimum == 1) { - echo ' Minimum payable amount '.$currency.' '.number_format($amount).''; - } - if ($recur == 'plan') { - if ($showbtn) { - echo ''; - } else { - echo '
- -
'; - } - } elseif ($recur == 'optional') { - echo ''; - } else { - if ($amount == 0) { - echo ''; - } elseif ($amount != 0 && $minimum == 1) { - echo ''; - } else { - echo ''; - } - } - } else { - if ($usevariableamount == "") { - echo "Form Error, set variable amount string"; - } else { - if (count($paymentoptions) > 0) { - echo '
- - -
'; - } - } - } - if ($txncharge != 'merchant' && $recur != 'plan') { - echo 'Transaction Charge: , Total:'; - } - - echo '
-
'; - if ($recur == 'no' && $usequantity == 'yes' && ($usevariableamount == 1 || $amount != 0)) { - // if ($minimum == 0 && $recur == 'no' && $usequantity == 'yes' && $amount != 0) { - echo '
- -
- - - -
-
'; - } - - if ($recur == 'optional') { - echo '
- -
- - -
-
'; - } elseif ($recur == 'plan') { - if ($showbtn) { - echo ''; - echo '
- -
'; - } else { - echo '
- -
'; - } - } - - - echo(do_shortcode($obj->post_content)); - - if ($useagreement == 'yes') { - echo '
- -

'; - } - echo '
- * are compulsory
- cardlogos - - '; - if ($showbtn) { - echo ''; - } - echo '
'; - - echo '
-
'; - } else { - echo "
You must be logged in to make payment
"; - } - } - } - - - - return ob_get_clean(); -} -add_shortcode('pff-paystack', 'kkd_pff_paystack_form_shortcode'); - -function kkd_pff_paystack_datepicker_shortcode($atts) -{ - extract( - shortcode_atts( - array( - 'name' => 'Title', - 'required' => '0', - ), - $atts - ) - ); - $code = '
- -
- 'Title', - 'required' => '0', - ), - $atts - ) - ); - $code = '
- -
- 'Title', - 'options' => '', - 'required' => '0', - ), - $atts - ) - ); - $code = '
- -
-
'; - return $code; -} -add_shortcode('select', 'kkd_pff_paystack_select_shortcode'); -function kkd_pff_paystack_radio_shortcode($atts) -{ - extract( - shortcode_atts( - array( - 'name' => 'Title', - 'options' => '', - 'required' => '0', - ), - $atts - ) - ); - $code = '
- -
- '; - $soptions = explode(',', $options); - if (count($soptions) > 0) { - foreach ($soptions as $key => $option) { - // $code.= ''; - $code.= '
'; - return $code; -} -add_shortcode('radio', 'kkd_pff_paystack_radio_shortcode'); -function kkd_pff_paystack_checkbox_shortcode($atts) -{ - extract( - shortcode_atts( - array( - 'name' => 'Title', - 'options' => '', - 'required' => '0', - ), - $atts - ) - ); - $code = '
- -
- '; - //
- //
- // - // - // - // - // - // - //
- //
- - $soptions = explode(',', $options); - if (count($soptions) > 0) { - foreach ($soptions as $key => $option) { - // $code.= ''; - $code.= '
'; - return $code; -} -add_shortcode('checkbox', 'kkd_pff_paystack_checkbox_shortcode'); -function kkd_pff_paystack_textarea_shortcode($atts) -{ - extract( - shortcode_atts( - array( - 'name' => 'Title', - 'required' => '0', - ), - $atts - ) - ); - $code = '
- -
-