Skip to content

Commit

Permalink
Minor docs & code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Jun 28, 2022
1 parent 6cf962b commit d623c7a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 30 deletions.
12 changes: 5 additions & 7 deletions src/Admin/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct() {
/**
* Add rating links to the admin dashboard.
*
* @param string $footer_text The existing footer text.
* @param string $footerText The existing footer text.
*
* @since 1.0.0
*
Expand All @@ -41,17 +41,15 @@ public function __construct() {
public function add_admin_footer_text( $footerText ) {
$current_screen = get_current_screen();

if ( true == stristr( $current_screen->base, 'plausible-analytics' ) ) {
$ratingText = sprintf(
if ( true === stristr( $current_screen->base, 'plausible-analytics' ) ) {
return sprintf(
/* translators: %s: Link to 5 star rating */
__( 'If you like <strong>Plausible Analytics</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'plausible-analytics' ),
'<a href="https://wordpress.org/support/view/plugin-reviews/plausible-analytics?filter=5#postform" target="_blank" class="plausible-analytics-rating-link" style="text-decoration:none;" data-rated="' . esc_attr__( 'Thanks :)', 'plausible-analytics' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
);

return $ratingText;
} else {
return $footerText;
}

return $footerText;
}

/**
Expand Down
10 changes: 0 additions & 10 deletions src/Admin/Settings/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ class API {
*/
public $fields = [];

/**
* Constructor.
*
* @since 1.3.0
* @access public
*
* @return void
*/
public function __construct() {}

/**
* Render Fields.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Settings/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public function statistics_page() {
esc_html( 'under Embed Analytics to view Plausible Analytics dashboard within your WordPress site.', 'plausible-analytics' )
);
?>
</p>
</div>
<?php
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Includes/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public function register_assets() {
/**
* Create admin bar nodes.
*
* @since 1.3.0
* @access public
* @param \WP_Admin_Bar $admin_bar Admin bar object.
*
* @return void
* @since 1.3.0
* @access public
*/

public function admin_bar_node( $admin_bar ) {
// Add main admin bar node.
$args = [
Expand Down
2 changes: 1 addition & 1 deletion src/Includes/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct() {
* @since 1.0.0
* @access public
*
* @return mixed
* @return string
*/
public function add_plausible_attributes( $tag, $handle ) {
// Bailout, if not `Plausible Analytics` script.
Expand Down
14 changes: 6 additions & 8 deletions src/Includes/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class Helpers {
*/
public static function get_domain() {
$site_url = site_url();
$domain = preg_replace( '/^http(s?)\:\/\/(www\.)?/i', '', $site_url );

return $domain;
return preg_replace( '/^http(s?)\:\/\/(www\.)?/i', '', $site_url );
}

/**
Expand All @@ -47,7 +46,7 @@ public static function get_analytics_url() {
$is_outbound_link = apply_filters( 'plausible_analytics_enable_outbound_links', true );
$file_name = $is_outbound_link ? 'plausible.outbound-links' : 'plausible';

// Triggered when self hosted analytics is enabled.
// Triggered when self-hosted analytics is enabled.
if (
! empty( $settings['is_self_hosted_analytics'] ) &&
'true' === $settings['is_self_hosted_analytics']
Expand Down Expand Up @@ -182,7 +181,7 @@ public static function get_quick_actions() {
* @since 1.3.0
* @access public
*
* @return mixed
* @return string
*/
public static function render_quick_actions() {
ob_start();
Expand Down Expand Up @@ -230,9 +229,9 @@ public static function render_quick_actions() {
public static function clean( $var ) {
if ( is_array( $var ) ) {
return array_map( [ __CLASS__, __METHOD__ ], $var );
} else {
return is_scalar( $var ) ? sanitize_text_field( wp_unslash( $var ) ) : $var;
}

return is_scalar( $var ) ? sanitize_text_field( wp_unslash( $var ) ) : $var;
}

/**
Expand All @@ -247,8 +246,7 @@ public static function get_user_role() {
global $current_user;

$user_roles = $current_user->roles;
$user_role = array_shift( $user_roles );

return $user_role;
return array_shift( $user_roles );
}
}

0 comments on commit d623c7a

Please sign in to comment.