Passed
Push — master ( b818a9...64cd18 )
by Christian
02:24
created

PodloveSubscribeButton::shortcode()   B

Complexity

Conditions 8
Paths 10

Size

Total Lines 38
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 24
nc 10
nop 1
dl 0
loc 38
rs 8.4444
c 1
b 0
f 0
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:  http://wordpress.org/extend/plugins/podlove-subscribe-button/
5
 * Description: Brings the Podlove Subscribe Button to your WordPress installation.
6
 * Version:     1.3.3
7
 * Author:      Podlove
8
 * Author URI:  http://podlove.org
9
 * License:     MIT
10
 * License URI: license.txt
11
 * Text Domain: podlove-subscribe-button
12
 */
0 ignored issues
show
Coding Style Documentation introduced by
Missing @package tag in file comment
Loading history...
13
14
$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...
15
16
if ( ! $correct_php_version ) {
17
	_e("Podlove Subscribe Button Plugin requires <strong>PHP 5.3</strong> or higher.<br>", 'podlove-subscribe-button');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style Comprehensibility introduced by
The string literal Podlove Subscribe Button.../strong> or higher.<br> 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...
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
18
	echo __("You are running PHP ", 'podlove-subscribe-button') . phpversion();
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style Comprehensibility introduced by
The string literal You are running PHP 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...
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
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'phpversion'.
Loading history...
19
	exit;
20
}
21
22
// Constants
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
23
require('constants.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
24
require('settings/buttons.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
25
// Models
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
26
require('model/base.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
27
require('model/button.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
28
require('model/network_button.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
29
// Table
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
30
require('settings/buttons_list_table.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
31
// Media Types
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
32
require('media_types.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
33
// Widget
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
34
require('widget.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
35
// Version control
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
36
require('version.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
37
// Helper functions
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
38
require('helper.php');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
"require" is a statement not a function; no parentheses are required
Loading history...
39
40
add_action( 'admin_menu', array( 'PodloveSubscribeButton', 'admin_menu') );
0 ignored issues
show
introduced by
Missing space before array closer.
Loading history...
41
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...
42
	add_action( 'network_admin_menu', array( 'PodloveSubscribeButton', 'admin_network_menu') );
0 ignored issues
show
introduced by
Missing space before array closer.
Loading history...
43
44
add_action( 'admin_init', array( 'PodloveSubscribeButton\Settings\Buttons', 'process_form' ) );
45
register_activation_hook( __FILE__, array( 'PodloveSubscribeButton', 'build_models' ) );
46
47
add_action( 'admin_enqueue_scripts', function () {
48
	wp_register_style( 'podlove-subscribe-button', plugin_dir_url(__FILE__).'style.css' );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
Concat operator must be surrounded by a single space
Loading history...
introduced by
Resource version not set in call to wp_register_style(). This means new versions of the style will not always be loaded due to browser caching.
Loading history...
49
	wp_enqueue_style( 'podlove-subscribe-button' );
50
51
	wp_enqueue_style('podlove-subscribe-button-spectrum', plugin_dir_url(__FILE__). 'js/spectrum/spectrum.css');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
Concat operator must be surrounded by a single space
Loading history...
introduced by
Resource version not set in call to wp_enqueue_style(). This means new versions of the style will not always be loaded due to browser caching.
Loading history...
52
	wp_enqueue_script('podlove-subscribe-button-spectrum', plugin_dir_url(__FILE__). 'js/spectrum/spectrum.js', array('jquery'));
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
Concat operator must be surrounded by a single space
Loading history...
introduced by
Missing space after array opener.
Loading history...
introduced by
Missing space before array closer.
Loading history...
introduced by
In footer ($in_footer) is not set explicitly wp_enqueue_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...
introduced by
Resource version not set in call to wp_enqueue_script(). This means new versions of the script will not always be loaded due to browser caching.
Loading history...
53
	wp_enqueue_script('podlove-subscribe-button-admin-tools', plugin_dir_url(__FILE__). 'js/admin.js', array('jquery'));
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
Concat operator must be surrounded by a single space
Loading history...
introduced by
Missing space after array opener.
Loading history...
introduced by
Missing space before array closer.
Loading history...
introduced by
In footer ($in_footer) is not set explicitly wp_enqueue_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...
introduced by
Resource version not set in call to wp_enqueue_script(). This means new versions of the script will not always be loaded due to browser caching.
Loading history...
54
} );
55
56
// Register Settings
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
57
add_action( 'admin_init', function () {
58
	$settings = array('size', 'autowidth', 'style', 'format', 'color');
0 ignored issues
show
introduced by
Missing space after array opener.
Loading history...
introduced by
Missing space before array closer.
Loading history...
59
60
	foreach ($settings as $setting) {
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...
61
		register_setting( 'podlove-subscribe-button', 'podlove_subscribe_button_default_' . $setting );
62
	}
63
} );
64
65
add_shortcode( 'podlove-subscribe-button', array( 'PodloveSubscribeButton', 'shortcode' ) );
66
67
add_action( 'plugins_loaded', function () {
68
	load_plugin_textdomain( 'podlove-subscribe-button' );
69
} );
70
71
72
class PodloveSubscribeButton {
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
73
74
	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 function doc comment
Loading history...
75
		add_options_page(
76
				'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...
77
				'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...
78
				'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...
79
				'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...
80
				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...
81
			);
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...
82
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
83
84
	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 function doc comment
Loading history...
85
		add_submenu_page(
86
				'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...
87
				'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...
88
				'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...
89
				'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...
90
				'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...
91
				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...
92
			);
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...
93
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
94
95
	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 function doc comment
Loading history...
96
		// Build Databases
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
97
		\PodloveSubscribeButton\Model\Button::build();
98
		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...
99
			\PodloveSubscribeButton\Model\NetworkButton::build();
100
101
		// 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...
102
		$default_values = array(
103
				'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...
104
				'autowidth' => 'on',
0 ignored issues
show
introduced by
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
105
				'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...
106
				'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...
107
				'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...
108
			);
0 ignored issues
show
introduced by
Array closer not aligned correctly; expected 8 space(s) but found 12
Loading history...
109
110
		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...
111
			if ( ! get_option('podlove_subscribe_button_default_' . $option ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
112
				update_option('podlove_subscribe_button_default_' . $option, $default_value);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
113
			}
114
		}
115
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
116
117
	public static function shortcode( $args ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing function doc comment
Loading history...
118
		if ( ! $args || ! isset($args['button']) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
119
			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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
120
		} else {
121
			$buttonid = $args['button'];
122
		}
123
124
		// 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...
125
		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($args['button']) )
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
Assignments must be the first block of code on a line
Loading history...
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
introduced by
Variable assignment found within a condition. Did you mean to do a comparison?
Loading history...
126
			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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
127
128
		// 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...
129
		$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

129
		$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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
130
		$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

130
		$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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
131
		$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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
132
		$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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
133
		$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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
134
135
		if ( isset($args['language']) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
136
			$language = $args['language'];
137
		} else {
138
			$language = 'en';
139
		}
140
141
		if ( isset($args['color']) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
142
			$color = $args['color'];
143
		} else {
144
			$color = get_option('podlove_subscribe_button_default_color', '#599677');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
145
		}
146
147
		if ( isset($args['hide']) && $args['hide'] == 'true' ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
introduced by
Use Yoda Condition checks, you must.
Loading history...
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
148
			$hide = TRUE;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected true, but found TRUE.
Loading history...
149
		} else {
150
			$hide = FALSE;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected false, but found FALSE.
Loading history...
151
		}
152
153
		// Render button
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
154
		return $button->render($size, $autowidth, $style, $format, $color, $hide, $buttonid, $language);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
155
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
156
157
	public static function get_array_value_with_fallback($args, $key) {
0 ignored issues
show
introduced by
No space after opening parenthesis is prohibited
Loading history...
Coding Style introduced by
Expected 1 spaces between opening bracket and argument "$args"; 0 found
Loading history...
introduced by
No space before closing parenthesis is prohibited
Loading history...
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 function doc comment
Loading history...
158
		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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
introduced by
Array keys must be surrounded by spaces unless they contain a string or an integer.
Loading history...
159
			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...
160
161
		return FALSE;
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected false, but found FALSE.
Loading history...
162
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
163
164
	/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
165
	 * @param  string $attribute
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
166
	 * @param  string $attribute_value
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
167
	 * @return string
168
	 */
169
	private static function get_attribute($attribute=NULL, $attribute_value=NULL) {
0 ignored issues
show
introduced by
No space after opening parenthesis is prohibited
Loading history...
Coding Style introduced by
Expected 1 spaces between opening bracket and argument "$attribute"; 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
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
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...
Coding Style introduced by
Method name "PodloveSubscribeButton::get_attribute" is not in camel caps format
Loading history...
170
		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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
171
			return $attribute_value;
172
		} else {
173
			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 bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
introduced by
Array keys must be surrounded by spaces unless they contain a string or an integer.
Loading history...
174
		}
175
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
176
177
	/**
178
	 * Interprets the provided width attribute and return either auto- or a specific width
179
	 * @param  string $width_attribute
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
180
	 * @return string
181
	 */
182
	private static function interpret_width_attribute( $width_attribute = NULL ) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
Coding Style introduced by
Method name "PodloveSubscribeButton::interpret_width_attribute" is not in camel caps format
Loading history...
183
		if ( $width_attribute == 'auto' )
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...
introduced by
Use Yoda Condition checks, you must.
Loading history...
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
184
			return 'on';
185
		if ( $width_attribute && $width_attribute !== 'auto' )
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...
introduced by
Use Yoda Condition checks, you must.
Loading history...
186
			return 'off';
187
188
		return get_option('podlove_subscribe_button_default_autowidth', 'on');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
189
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
190
}