@@ -45,12 +45,31 @@ public static function fetchFeeSettings()
4545
4646 public function enqueue_scripts ()
4747 {
48+ global $ posts ;
49+ $ pattern = get_shortcode_regex ();
50+ preg_match ('/ ' .$ pattern .'/s ' , $ posts [0 ]->post_content , $ matches );
51+
4852 wp_enqueue_script ('blockUI ' , plugin_dir_url (__FILE__ ) . 'js/jquery.blockUI.min.js ' , array ('jquery ' ), $ this ->version , true , true );
4953 wp_enqueue_script ('jquery-ui-core ' );
50- wp_register_script ('Paystack ' , 'https://js.paystack.co/v1/inline.js ' , false , '1 ' );
51- wp_enqueue_script ('Paystack ' );
52- wp_enqueue_script ('paystack_frontend ' , plugin_dir_url (__FILE__ ) . 'js/paystack-forms-public.js ' , array ('jquery ' ), $ this ->version , true , true );
53- 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 );
54+
55+ if (is_array ($ matches )) {
56+ if ( count ($ matches ) > 0 ) {
57+ if ($ matches [2 ] == 'pff-paystack ' ) {
58+ wp_register_script ('Paystack ' , 'https://js.paystack.co/v1/inline.js ' , false , '1 ' );
59+ wp_enqueue_script ('Paystack ' );
60+ wp_enqueue_script ('paystack_frontend ' , plugin_dir_url (__FILE__ ) . 'js/paystack-forms-public.js ' , array ('jquery ' ), $ this ->version , true , true );
61+ 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 );
62+ }
63+ }
64+ }
65+
66+
67+ // wp_enqueue_script('blockUI', plugin_dir_url(__FILE__) . 'js/jquery.blockUI.min.js', array('jquery'), $this->version, true, true);
68+ // wp_enqueue_script('jquery-ui-core');
69+ // wp_register_script('Paystack', 'https://js.paystack.co/v1/inline.js', false, '1');
70+ // wp_enqueue_script('Paystack');
71+ // wp_enqueue_script('paystack_frontend', plugin_dir_url(__FILE__) . 'js/paystack-forms-public.js', array('jquery'), $this->version, true, true);
72+ // 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);
5473 }
5574}
5675
0 commit comments