@@ -33,7 +33,7 @@ class BSF_Analytics {
3333 public function __construct () {
3434
3535 define ( 'BSF_ANALYTICS_FILE ' , __FILE__ );
36- define ( 'BSF_ANALYTICS_VERSION ' , '1.0.0 ' );
36+ define ( 'BSF_ANALYTICS_VERSION ' , '1.0.1 ' );
3737 define ( 'BSF_ANALYTICS_PATH ' , dirname ( __FILE__ ) );
3838 define ( 'BSF_ANALYTICS_URI ' , $ this ->bsf_analytics_url () );
3939
@@ -186,6 +186,8 @@ public function option_notice() {
186186 $ notice_string .= __ ( 'This will be applicable for all sites from the network. ' , 'custom-typekit-fonts ' );
187187 }
188188
189+ $ language_dir = is_rtl () ? 'rtl ' : 'ltr ' ;
190+
189191 Astra_Notices::add_notice (
190192 array (
191193 'id ' => 'bsf-optin-notice ' ,
@@ -205,7 +207,7 @@ public function option_notice() {
205207 </div>
206208 </div> ' ,
207209 /* translators: %s usage doc link */
208- sprintf ( $ notice_string . '<a href="%2s " target="_blank" rel="noreferrer noopener">%3s </a> ' , $ this ->get_product_name (), esc_url ( $ this ->usage_doc_link ), __ ( ' Know More. ' , 'custom-typekit-fonts ' ) ),
210+ sprintf ( $ notice_string . '<span dir="%2s">< a href="%3s " target="_blank" rel="noreferrer noopener">%4s </a><span> ' , esc_html ( $ this ->get_product_name () ), $ language_dir , esc_url ( $ this ->usage_doc_link ), __ ( ' Know More. ' , 'custom-typekit-fonts ' ) ),
209211 add_query_arg (
210212 array (
211213 'bsf_analytics_optin ' => 'yes ' ,
@@ -240,11 +242,11 @@ public function handle_optin_optout() {
240242 return ;
241243 }
242244
243- if ( ! wp_verify_nonce ( sanitize_text_field ( $ _GET ['bsf_analytics_nonce ' ] ), 'bsf_analytics_optin ' ) ) {
245+ if ( ! wp_verify_nonce ( sanitize_text_field ( wp_unslash ( $ _GET ['bsf_analytics_nonce ' ] ) ), 'bsf_analytics_optin ' ) ) {
244246 return ;
245247 }
246248
247- $ optin_status = sanitize_text_field ( $ _GET ['bsf_analytics_optin ' ] );
249+ $ optin_status = isset ( $ _GET [ ' bsf_analytics_optin ' ] ) ? sanitize_text_field ( wp_unslash ( $ _GET ['bsf_analytics_optin ' ] ) ) : '' ;
248250
249251 if ( 'yes ' === $ optin_status ) {
250252 $ this ->optin ();
@@ -371,6 +373,7 @@ public function sanitize_option( $input ) {
371373 */
372374 public function render_settings_field_html () {
373375 ?>
376+ <fieldset>
374377 <label for="bsf-analytics-optin">
375378 <input id="bsf-analytics-optin" type="checkbox" value="1" name="bsf_analytics_optin" <?php checked ( get_site_option ( 'bsf_analytics_optin ' , 'no ' ), 'yes ' ); ?> >
376379 <?php
@@ -383,6 +386,9 @@ public function render_settings_field_html() {
383386 </label>
384387 <?php
385388 echo wp_kses_post ( sprintf ( '<a href="%1s" target="_blank" rel="noreferrer noopener">%2s</a> ' , esc_url ( $ this ->usage_doc_link ), __ ( 'Learn More. ' , 'custom-typekit-fonts ' ) ) );
389+ ?>
390+ </fieldset>
391+ <?php
386392 }
387393
388394 /**
@@ -406,14 +412,30 @@ private function get_product_name() {
406412 $ exploded_path = explode ( '/ ' , $ base , 2 );
407413 $ plugin_slug = $ exploded_path [0 ];
408414
415+ return $ this ->get_plugin_name ( $ plugin_slug );
416+ }
417+
418+ /**
419+ * Get plugin name by plugin slug.
420+ *
421+ * @param string $plugin_slug Plugin slug.
422+ * @return string $plugin_info['Name'] Plugin name.
423+ */
424+ private function get_plugin_name ( $ plugin_slug ) {
425+
426+ $ plugins = get_option ( 'active_plugins ' );
427+
409428 if ( ! function_exists ( 'get_plugin_data ' ) ) {
410429 require_once ABSPATH . 'wp-admin/includes/plugin.php ' ;
411430 }
412431
413- $ plugin_main_file = WP_PLUGIN_DIR . '/ ' . $ plugin_slug . '/ ' . $ plugin_slug . '.php ' ;
414- $ plugin_data = get_plugin_data ( wp_normalize_path ( $ plugin_main_file ) );
415-
416- return $ plugin_data ['Name ' ];
432+ foreach ( $ plugins as $ plugin_file ) {
433+ if ( 0 === strpos ( $ plugin_file , $ plugin_slug ) ) {
434+ $ plugin_path = WP_PLUGIN_DIR . '/ ' . $ plugin_file ;
435+ $ plugin_data = get_plugin_data ( $ plugin_path );
436+ return $ plugin_data ['Name ' ];
437+ }
438+ }
417439 }
418440
419441 /**
0 commit comments