GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PodloveSubscribeButton::enqueue_assets()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
eloc 12
c 4
b 0
f 0
nc 2
nop 1
dl 0
loc 22
rs 9.8666
1
<?php
0 ignored issues
show
introduced by
Class file names should be based on the class name with "class-" prepended. Expected class-podlovesubscribebutton.php, but found podlove.php.
Loading history...
2
/**
3
 * Plugin Name: Podlove Subscribe Button
4
 * Plugin URI:  https://wordpress.org/extend/plugins/podlove-subscribe-button/
5
 * Description: Brings the Podlove Subscribe Button to your WordPress installation.
6
 * Version:     1.3.11
7
 * Author:      Podlove
8
 * Author URI:  https://podlove.org
9
 * License:     MIT
10
 * License URI: license.txt
11
 * Text Domain: podlove-subscribe-button
12
 * Domain Path: /languages
13
 */
0 ignored issues
show
Coding Style Documentation introduced by
Missing @package tag in file comment
Loading history...
14
15
$correct_php_version = version_compare( phpversion(), "5.3", ">=" );
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 5.3 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
16
17
if ( ! $correct_php_version ) {
18
	printf( __( 'Podlove Subscribe Button Plugin requires %s or higher.<br>', 'podlove-subscribe-button' ), '<code>PHP 5.3</code>' );
0 ignored issues
show
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'.
Loading history...
introduced by
A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
Loading history...
19
	echo '<br />';
20
	printf( __( 'You are running %s', 'podlove-subscribe-button' ), '<code>PHP ' . phpversion() . '</code>' );
0 ignored issues
show
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'.
Loading history...
introduced by
A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'phpversion'.
Loading history...
21
	exit;
22
}
23
24
// Constants
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
25
require('constants.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
26
require('settings/buttons.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
27
// Models
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
28
require('model/base.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
29
require('model/button.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
30
require('model/network_button.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
31
// Table
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
32
require('settings/buttons_list_table.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
33
// Media Types
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
34
require('media_types.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
35
// Widget
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
36
require('widget.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
37
// Version control
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
38
require('version.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
39
// Helper functions
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
40
require('helper.php');
0 ignored issues
show
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
41
42
add_action( 'admin_menu', array( 'PodloveSubscribeButton', 'admin_menu') );
0 ignored issues
show
introduced by
Missing space before array closer.
Loading history...
43
if ( is_multisite() )
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
44
	add_action( 'network_admin_menu', array( 'PodloveSubscribeButton', 'admin_network_menu') );
0 ignored issues
show
introduced by
Missing space before array closer.
Loading history...
45
46
add_action( 'admin_init', array( 'PodloveSubscribeButton\Settings\Buttons', 'process_form' ) );
47
register_activation_hook( __FILE__, array( 'PodloveSubscribeButton', 'build_models' ) );
48
49
// Register Settings
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
50
add_action( 'admin_init', function () {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
51
	$settings = array( 'size', 'autowidth', 'style', 'format', 'color' );
52
53
	foreach ( $settings as $setting ) {
54
		if ( 'autowidth' == $setting ) {
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
55
			$args = array(
56
				'sanitize_callback' => array( 'PodloveSubscribeButton', 'sanitize_settings' ),
57
			);
58
			register_setting( 'podlove-subscribe-button', 'podlove_subscribe_button_default_' . $setting, $args );
59
		} else {
60
			register_setting( 'podlove-subscribe-button', 'podlove_subscribe_button_default_' . $setting );
61
		}
62
	}
63
} );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
64
65
add_shortcode( 'podlove-subscribe-button', array( 'PodloveSubscribeButton', 'shortcode' ) );
66
67
add_action( 'plugins_loaded', function () {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
68
	load_plugin_textdomain( 'podlove-subscribe-button', false, dirname(plugin_basename( __FILE__)) . '/languages/');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
69
} );
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
70
71
PodloveSubscribeButton::run();
72
73
74
class PodloveSubscribeButton {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for class PodloveSubscribeButton
Loading history...
75
76
	public static function run() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function run()
Loading history...
77
		add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
78
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
79
80
	public static function enqueue_assets( $hook ) {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::enqueue_assets" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function enqueue_assets()
Loading history...
81
82
		$pages = array( 'settings_page_podlove-subscribe-button', 'widgets.php' );
83
84
		if ( ! in_array( $hook, $pages )  ) {
0 ignored issues
show
introduced by
Not using strict comparison for in_array; supply true for third argument.
Loading history...
introduced by
Expected exactly one space before closing parenthesis; " " found.
Loading history...
85
			return;
86
		}
87
88
		// CSS Stylesheet
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
89
		wp_register_style( 'podlove-subscribe-button', plugin_dir_url( __FILE__ ) . 'style.css', false, '1.3.6' );
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string[] expected by parameter $deps of wp_register_style(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

89
		wp_register_style( 'podlove-subscribe-button', plugin_dir_url( __FILE__ ) . 'style.css', /** @scrutinizer ignore-type */ false, '1.3.6' );
Loading history...
90
		wp_enqueue_style( 'podlove-subscribe-button' );
91
92
		// Admin JS
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
93
		wp_enqueue_style( 'wp-color-picker' );
94
		wp_register_script( 'podlove-subscribe-button-admin-tools', plugin_dir_url( __FILE__ ) . 'js/admin.js', array( 'jquery', 'wp-color-picker' ), '1.3.6' );
0 ignored issues
show
introduced by
In footer ($in_footer) is not set explicitly wp_register_script; It is recommended to load scripts in the footer. Please set this value to true to load it in the footer, or explicitly false if it should be loaded in the header.
Loading history...
95
96
		$js_translations = array(
97
			'media_library' => __( 'Media Library', 'podlove-subscribe-button' ),
98
			'use_for'       => __( 'Use for Podcast Cover Art', 'podlove-subscribe-button' ),
99
		);
100
		wp_localize_script( 'podlove-subscribe-button-admin-tools', 'i18n', $js_translations );
101
		wp_enqueue_script( 'podlove-subscribe-button-admin-tools' );
102
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
103
104
	public static function admin_menu() {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::admin_menu" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function admin_menu()
Loading history...
105
		add_options_page(
106
				'Podlove Subscribe Button Options',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
107
				'Podlove Subscribe Button',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
108
				'manage_options',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
109
				'podlove-subscribe-button',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
110
				array( 'PodloveSubscribeButton\Settings\Buttons', 'page')
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
introduced by
Missing space before array closer.
Loading history...
111
			);
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 8 spaces, but found 12.
Loading history...
112
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
113
114
	public static function admin_network_menu() {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::admin_network_menu" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function admin_network_menu()
Loading history...
115
		add_submenu_page(
116
				'settings.php',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
117
				'Podlove Subscribe Button Options',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
118
				'Podlove Subscribe Button',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
119
				'manage_options',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
120
				'podlove-subscribe-button',
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
121
				array( 'PodloveSubscribeButton\Settings\Buttons', 'page')
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 12 spaces, but found 16.
Loading history...
introduced by
Missing space before array closer.
Loading history...
122
			);
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 8 spaces, but found 12.
Loading history...
123
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
124
125
	public static function build_models() {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::build_models" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function build_models()
Loading history...
126
		// Build Databases
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
127
		\PodloveSubscribeButton\Model\Button::build();
128
		if ( is_multisite() )
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
129
			\PodloveSubscribeButton\Model\NetworkButton::build();
130
131
		// Set Button "default" values
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
132
		$default_values = array(
133
				'size' => 'big',
0 ignored issues
show
introduced by
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
introduced by
Array double arrow not aligned correctly; expected 6 space(s) between "'size'" and double arrow, but found 1.
Loading history...
134
				'autowidth' => 'on',
0 ignored issues
show
introduced by
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
135
				'color' => '#599677',
0 ignored issues
show
introduced by
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
introduced by
Array double arrow not aligned correctly; expected 5 space(s) between "'color'" and double arrow, but found 1.
Loading history...
136
				'style' => 'filled',
0 ignored issues
show
introduced by
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
introduced by
Array double arrow not aligned correctly; expected 5 space(s) between "'style'" and double arrow, but found 1.
Loading history...
137
				'format' => 'rectangle'
0 ignored issues
show
introduced by
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
introduced by
Array double arrow not aligned correctly; expected 4 space(s) between "'format'" and double arrow, but found 1.
Loading history...
introduced by
Each array item in a multi-line array declaration must end in a comma
Loading history...
138
			);
0 ignored issues
show
introduced by
Array closer not aligned correctly; expected 8 space(s) but found 12
Loading history...
139
140
		foreach ($default_values as $option => $default_value) {
0 ignored issues
show
introduced by
No space after opening parenthesis is prohibited
Loading history...
introduced by
No space before closing parenthesis is prohibited
Loading history...
141
			if ( ! get_option('podlove_subscribe_button_default_' . $option ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
142
				update_option('podlove_subscribe_button_default_' . $option, $default_value);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
143
			}
144
		}
145
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
146
147
	public static function shortcode( $args ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function shortcode()
Loading history...
148
		if ( ! $args || ! isset($args['button']) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
149
			return __('You need to create a Button first and provide its ID.', 'podlove-subscribe-button');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
150
		} else {
151
			$buttonid = $args['button'];
152
		}
153
154
		// Fetch the (network)button by it's name
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
155
		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) )
0 ignored issues
show
introduced by
Variable assignment found within a condition. Did you mean to do a comparison?
Loading history...
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
Coding Style introduced by
Assignments must be the first block of code on a line
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
156
			return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] );
0 ignored issues
show
introduced by
A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
157
158
		// Get button styling and options
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
159
		$autowidth = self::interpret_width_attribute( self::get_array_value_with_fallback($args, 'width') );
0 ignored issues
show
Bug introduced by
It seems like self::get_array_value_wi...allback($args, 'width') can also be of type false; however, parameter $width_attribute of PodloveSubscribeButton::...rpret_width_attribute() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

159
		$autowidth = self::interpret_width_attribute( /** @scrutinizer ignore-type */ self::get_array_value_with_fallback($args, 'width') );
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
160
		$size = self::get_attribute( 'size', self::get_array_value_with_fallback($args, 'size') );
0 ignored issues
show
Bug introduced by
It seems like self::get_array_value_wi...fallback($args, 'size') can also be of type false; however, parameter $attribute_value of PodloveSubscribeButton::get_attribute() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

160
		$size = self::get_attribute( 'size', /** @scrutinizer ignore-type */ self::get_array_value_with_fallback($args, 'size') );
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
161
		$style = self::get_attribute( 'style', self::get_array_value_with_fallback($args, 'style') );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
162
		$format = self::get_attribute( 'format', self::get_array_value_with_fallback($args, 'format') );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
163
		$color = self::get_attribute( 'color', self::get_array_value_with_fallback($args, 'color') );
0 ignored issues
show
Unused Code introduced by
The assignment to $color is dead and can be removed.
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
164
165
		if ( isset($args['language']) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
166
			$language = $args['language'];
167
		} else {
168
			$language = 'en';
169
		}
170
171
		if ( isset($args['color']) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
172
			$color = $args['color'];
173
		} else {
174
			$color = get_option('podlove_subscribe_button_default_color', '#599677');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
175
		}
176
177
		if ( isset($args['hide']) && $args['hide'] == 'true' ) {
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
introduced by
Use Yoda Condition checks, you must.
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
178
			$hide = true;
179
		} else {
180
			$hide = false;
181
		}
182
183
		// Render button
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
184
		return $button->render($size, $autowidth, $style, $format, $color, $hide, $buttonid, $language);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
185
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
186
187
	public static function get_array_value_with_fallback($args, $key) {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::get_array_value_with_fallback" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function get_array_value_with_fallback()
Loading history...
introduced by
No space after opening parenthesis is prohibited
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
introduced by
No space before closing parenthesis is prohibited
Loading history...
188
		if ( isset($args[$key]) )
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
introduced by
Array keys must be surrounded by spaces unless they contain a string or an integer.
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
189
			return $args[$key];
0 ignored issues
show
introduced by
Array keys must be surrounded by spaces unless they contain a string or an integer.
Loading history...
190
191
		return false;
192
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
193
194
	/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
195
	 * @param  string $attribute
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
196
	 * @param  string $attribute_value
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
197
	 * @return string
198
	 */
199
	private static function get_attribute($attribute=null, $attribute_value=null) {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::get_attribute" is not in camel caps format
Loading history...
introduced by
No space after opening parenthesis is prohibited
Loading history...
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$attribute" and equals sign; expected 1 but found 0
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$attribute"; expected 1 but found 0
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$attribute_value" and equals sign; expected 1 but found 0
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$attribute_value"; expected 1 but found 0
Loading history...
introduced by
No space before closing parenthesis is prohibited
Loading history...
200
		if ( isset($attribute_value) && ctype_alnum($attribute_value) && key_exists( $attribute_value, \PodloveSubscribeButton\Model\Button::$$attribute ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
201
			return $attribute_value;
202
		} else {
203
			return get_option('podlove_subscribe_button_default_' . $attribute, \PodloveSubscribeButton\Model\Button::$properties[$attribute]);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
introduced by
Array keys must be surrounded by spaces unless they contain a string or an integer.
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
204
		}
205
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
206
207
	/**
208
	 * Interprets the provided width attribute and return either auto- or a specific width
209
	 * @param  string $width_attribute
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
210
	 * @return string
211
	 */
212
	private static function interpret_width_attribute( $width_attribute = null ) {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::interpret_width_attribute" is not in camel caps format
Loading history...
213
		if ( $width_attribute == 'auto' )
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
214
			return 'on';
215
		if ( $width_attribute && $width_attribute !== 'auto' )
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
216
			return 'off';
217
218
		return get_option('podlove_subscribe_button_default_autowidth', 'on');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
219
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
220
221
	public static function sanitize_settings( $input = null ) {
0 ignored issues
show
Coding Style introduced by
Method name "PodloveSubscribeButton::sanitize_settings" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function sanitize_settings()
Loading history...
222
		if ( null == $input ) {
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
223
			return 'off';
224
		} elseif ( 'on' == $input ) {
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
225
			return $input;
226
		}
227
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
228
}
229