@@ -39,7 +39,7 @@ function kkd_pff_paystack_txncheck($name, $txncharge)
3939 }
4040 function kkd_pff_paystack_setting_page ()
4141 {
42- ?>
42+ ?>
4343 <div class="wrap">
4444 <h1>Paystack Forms Settings</h1>
4545
@@ -112,7 +112,7 @@ function kkd_pff_paystack_setting_page()
112112
113113 </form>
114114 </div>
115- <?php
115+ <?php
116116 }
117117 add_action ('init ' , 'register_kkd_pff_paystack ' );
118118 function register_kkd_pff_paystack ()
@@ -231,34 +231,34 @@ function kkd_pff_paystack_dashboard_table_data($column, $post_id)
231231 $ table = $ wpdb ->prefix . KKD_PFF_PAYSTACK_TABLE ;
232232
233233 switch ($ column ) {
234- case 'shortcode ' :
235- echo '<span class="shortcode">
234+ case 'shortcode ' :
235+ echo '<span class="shortcode">
236236 <input type="text" class="large-text code" value="[pff-paystack id=" ' . $ post_id . '"]"
237237 readonly="readonly" onfocus="this.select();"></span> ' ;
238238
239- break ;
240- case 'payments ' :
239+ break ;
240+ case 'payments ' :
241241
242- $ count_query = ' select count (*) from ' . $ table . ' WHERE post_id = " ' . $ post_id . ' " AND paid = "1" ' ;
243- $ num = $ wpdb ->get_var ($ count_query );
242+ $ count_query = $ wpdb -> prepare ( " SELECT COUNT (*) FROM { $ table} WHERE post_id = %d AND paid = '1' " , $ post_id ) ;
243+ $ num = $ wpdb ->get_var ($ count_query );
244244
245- echo '<u><a href=" ' . admin_url ('admin.php?page=submissions&form= ' . $ post_id ) . '"> ' . $ num . '</a></u> ' ;
246- break ;
247- default :
248- break ;
245+ echo '<u><a href=" ' . admin_url ('admin.php?page=submissions&form= ' . $ post_id ) . '"> ' . $ num . '</a></u> ' ;
246+ break ;
247+ default :
248+ break ;
249249 }
250250 }
251251 add_filter ('default_content ' , 'kkd_pff_paystack_editor_content ' , 10 , 2 );
252252
253253 function kkd_pff_paystack_editor_content ($ content , $ post )
254254 {
255255 switch ($ post ->post_type ) {
256- case 'paystack_form ' :
257- $ content = '[text name="Phone Number"] ' ;
258- break ;
259- default :
260- $ content = '' ;
261- break ;
256+ case 'paystack_form ' :
257+ $ content = '[text name="Phone Number"] ' ;
258+ break ;
259+ default :
260+ $ content = '' ;
261+ break ;
262262 }
263263
264264 return $ content ;
@@ -284,18 +284,18 @@ function kkd_pff_paystack_editor_help_metabox_details($post)
284284
285285 </div>
286286
287- <?php
287+ <?php
288288 }
289289 function kkd_pff_paystack_editor_shortcode_details ($ post )
290290 {
291- ?>
291+ ?>
292292 <p class="description">
293293 <label for="wpcf7-shortcode">Copy this shortcode and paste it into your post, page, or text widget content:</label>
294294 <span class="shortcode wp-ui-highlight">
295- <input type="text" id="wpcf7-shortcode" onfocus="this.select();" readonly="readonly" class="large-text code" value="[pff-paystack id="<?php echo $ post ->ID ; ?> "]"></span>
295+ <input type="text" id="wpcf7-shortcode" onfocus="this.select();" readonly="readonly" class="large-text code" value="[pff-paystack id="<?php echo esc_html ( $ post ->ID ) ; ?> "]"></span>
296296 </p>
297297
298- <?php
298+ <?php
299299 }
300300
301301 add_action ('add_meta_boxes ' , 'kkd_pff_paystack_editor_add_extra_metaboxes ' );
@@ -767,7 +767,7 @@ public function enqueue_scripts()
767767 /**
768768 * Add settings action link to the plugins page.
769769 *
770- * @since 1.0.0
770+ * @since 1.0.0
771771 */
772772 public function add_action_links ($ links )
773773 {
@@ -800,17 +800,17 @@ function kkd_pff_paystack_payment_submissions()
800800 $ data = $ exampleListTable ->prepare_items (); ?>
801801 <div id="welcome-panel" class="welcome-panel">
802802 <div class="welcome-panel-content">
803- <h1 style="margin: 0px;"><?php echo $ obj ->post_title ; ?> Payments </h1>
803+ <h1 style="margin: 0px;"><?php echo esc_html ( $ obj ->post_title ) ; ?> Payments </h1>
804804 <p class="about-description">All payments made for this form</p>
805805 <?php if ($ data > 0 ) {
806- ?>
806+ ?>
807807
808808 <form action="<?php echo admin_url ('admin-post.php ' ); ?> " method="post">
809809 <input type="hidden" name="action" value="kkd_pff_export_excel">
810- <input type="hidden" name="form_id" value="<?php echo $ id ; ?> ">
810+ <input type="hidden" name="form_id" value="<?php echo esc_html ( $ id) ; ?> ">
811811 <button type="submit" class="button button-primary button-hero load-customize">Export Data to Excel</button>
812812 </form>
813- <?php
813+ <?php
814814 } ?>
815815
816816 <br><br>
@@ -820,7 +820,7 @@ function kkd_pff_paystack_payment_submissions()
820820 <div id="icon-users" class="icon32"></div>
821821 <?php $ exampleListTable ->display (); ?>
822822 </div>
823- <?php
823+ <?php
824824 }
825825}
826826add_action ('admin_post_kkd_pff_export_excel ' , 'Kkd_pff_export_excel ' );
@@ -843,7 +843,9 @@ function Kkd_pff_export_excel()
843843 }
844844 $ table = $ wpdb ->prefix . KKD_PFF_PAYSTACK_TABLE ;
845845 $ data = array ();
846- $ alldbdata = $ wpdb ->get_results ("SELECT * FROM $ table WHERE (post_id = ' " . $ post_id . "' AND paid = '1') ORDER BY `id` ASC " );
846+ $ table = sanitize_text_field ($ table );
847+
848+ $ alldbdata = $ wpdb ->get_results ($ wpdb ->prepare ("SELECT * FROM {$ table } WHERE post_id = %d AND paid = '1' ORDER BY `id` ASC " , $ post_id ));
847849 $ i = 0 ;
848850
849851 if (count ($ alldbdata ) > 0 ) {
@@ -927,7 +929,7 @@ public function list_table_page()
927929 <div id="icon-users" class="icon32"></div>
928930 <?php $ exampleListTable ->display (); ?>
929931 </div>
930- <?php
932+ <?php
931933 }
932934}
933935
@@ -970,8 +972,7 @@ public function prepare_items()
970972
971973 $ table = $ wpdb ->prefix . KKD_PFF_PAYSTACK_TABLE ;
972974 $ data = array ();
973- $ alldbdata = $ wpdb ->get_results ("SELECT * FROM $ table WHERE (post_id = ' " . $ post_id . "' AND paid = '1') " );
974-
975+ $ alldbdata = $ wpdb ->get_results ($ wpdb ->prepare ("SELECT * FROM {$ table } WHERE post_id = %d AND paid = '1' " , $ post_id ));
975976 foreach ($ alldbdata as $ key => $ dbdata ) {
976977 $ newkey = $ key + 1 ;
977978 if ($ dbdata ->txn_code_2 != "" ) {
@@ -1055,15 +1056,15 @@ private function table_data($data)
10551056 public function column_default ($ item , $ column_name )
10561057 {
10571058 switch ($ column_name ) {
1058- case 'id ' :
1059- case 'email ' :
1060- case 'amount ' :
1061- case 'txn_code ' :
1062- case 'metadata ' :
1063- case 'date ' :
1064- return $ item [$ column_name ];
1065- default :
1066- return print_r ($ item , true );
1059+ case 'id ' :
1060+ case 'email ' :
1061+ case 'amount ' :
1062+ case 'txn_code ' :
1063+ case 'metadata ' :
1064+ case 'date ' :
1065+ return $ item [$ column_name ];
1066+ default :
1067+ return print_r ($ item , true );
10671068 }
10681069 }
10691070
0 commit comments