Skip to content

Commit e5e7e9d

Browse files
committed
Pulled latest analytics code
1 parent ae7909c commit e5e7e9d

File tree

3 files changed

+42
-20
lines changed

3 files changed

+42
-20
lines changed

admin/bsf-analytics/class-bsf-analytics-stats.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function get_default_stats() {
6868
'graupi_version' => defined( 'BSF_UPDATER_VERSION' ) ? BSF_UPDATER_VERSION : false,
6969
'domain_name' => get_site_url(),
7070
'php_os' => PHP_OS,
71-
'server_software' => $_SERVER['SERVER_SOFTWARE'],
71+
'server_software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? filter_var( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ), FILTER_SANITIZE_STRING ) : '',
7272
'mysql_version' => $this->get_mysql_version(),
7373
'php_version' => $this->get_php_version(),
7474
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
@@ -181,7 +181,7 @@ public function format_plugin( $plugin ) {
181181
private function get_curl_ssl_version() {
182182
$curl = array();
183183
if ( function_exists( 'curl_version' ) ) {
184-
$curl = curl_version();
184+
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
185185
}
186186

187187
return isset( $curl['ssl_version'] ) ? $curl['ssl_version'] : false;
@@ -196,7 +196,7 @@ private function get_curl_ssl_version() {
196196
private function get_curl_version() {
197197
$curl = array();
198198
if ( function_exists( 'curl_version' ) ) {
199-
$curl = curl_version();
199+
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
200200
}
201201

202202
return isset( $curl['version'] ) ? $curl['version'] : false;

admin/bsf-analytics/class-bsf-analytics.php

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/**

languages/custom-typekit-fonts.pot

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ msgstr ""
55
"Project-Id-Version: Custom Adobe Fonts (Typekit) 1.0.17\n"
66
"Report-Msgid-Bugs-To: "
77
"https://wordpress.org/support/plugin/custom-typekit-fonts\n"
8-
"POT-Creation-Date: 2020-06-09 13:09:34+00:00\n"
8+
"POT-Creation-Date: 2020-06-15 05:45:18+00:00\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=utf-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
@@ -36,36 +36,36 @@ msgstr ""
3636
msgid "This will be applicable for all sites from the network."
3737
msgstr ""
3838

39-
#: admin/bsf-analytics/class-bsf-analytics.php:208
39+
#: admin/bsf-analytics/class-bsf-analytics.php:210
4040
#. translators: %s usage doc link
4141
msgid " Know More."
4242
msgstr ""
4343

44-
#: admin/bsf-analytics/class-bsf-analytics.php:215
44+
#: admin/bsf-analytics/class-bsf-analytics.php:217
4545
msgid "Yes! Allow it"
4646
msgstr ""
4747

48-
#: admin/bsf-analytics/class-bsf-analytics.php:223
48+
#: admin/bsf-analytics/class-bsf-analytics.php:225
4949
msgid "No Thanks"
5050
msgstr ""
5151

52-
#: admin/bsf-analytics/class-bsf-analytics.php:292
52+
#: admin/bsf-analytics/class-bsf-analytics.php:294
5353
msgid "Every two days"
5454
msgstr ""
5555

56-
#: admin/bsf-analytics/class-bsf-analytics.php:346
56+
#: admin/bsf-analytics/class-bsf-analytics.php:348
5757
msgid "Usage Tracking"
5858
msgstr ""
5959

60-
#: admin/bsf-analytics/class-bsf-analytics.php:377
60+
#: admin/bsf-analytics/class-bsf-analytics.php:380
6161
msgid "Allow Brainstorm Force products to track non-sensitive usage tracking data."
6262
msgstr ""
6363

64-
#: admin/bsf-analytics/class-bsf-analytics.php:380
64+
#: admin/bsf-analytics/class-bsf-analytics.php:383
6565
msgid " This will be applicable for all sites from the network."
6666
msgstr ""
6767

68-
#: admin/bsf-analytics/class-bsf-analytics.php:385
68+
#: admin/bsf-analytics/class-bsf-analytics.php:388
6969
msgid "Learn More."
7070
msgstr ""
7171

0 commit comments

Comments
 (0)