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.
Completed
Push — master ( dc0f35...efd704 )
by Christian
15s
created

Buttons::redirect()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 4
nop 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
introduced by
Filenames should be all lowercase with hyphens as word separators. Expected buttons.php, but found Buttons.php.
Loading history...
introduced by
Class file names should be based on the class name with "class-" prepended. Expected class-buttons.php, but found Buttons.php.
Loading history...
2
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
3
 * @author    Podlove <[email protected]>
4
 * @copyright Copyright (c) 2014-2018, Podlove
5
 * @license   https://github.com/podlove/podlove-subscribe-button-wp-plugin/blob/master/LICENSE MIT
6
 * @package   Podlove\PodloveSubscribeButton
7
 */
8
9
namespace PodloveSubscribeButton\Settings;
10
11
use PodloveSubscribeButton\Helpers;
12
13
class Buttons {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for class Buttons
Loading history...
14
15
	public static function page() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function page()
Loading history...
16
17
		$action = null !== filter_input( INPUT_GET, 'action' ) ? filter_input( INPUT_GET, 'action' ) : null;
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...
18
		$is_network = is_network_admin();
19
20
		if ( $action == 'confirm_delete' && null !== filter_input( INPUT_GET, 'button' ) ) {
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
introduced by
Use Yoda Condition checks, you must.
Loading history...
21
			$button = ( $is_network === true ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id( (int) filter_input( INPUT_GET, 'button' ) ) : \PodloveSubscribeButton\Model\Button::find_by_id( (int) filter_input( INPUT_GET, 'button' ) ) );
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
22
			?>
23
			<div class="updated">
24
				<p>
25
					<strong>
26
						<?php printf( __( 'You selected to delete the button "%s". Please confirm this action.', 'podlove-subscribe-button' ), $button->title ) ?>
0 ignored issues
show
Coding Style introduced by
Inline PHP statement must end with a semicolon
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
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 '$button'.
Loading history...
27
					</strong>
28
				</p>
29
				<p>
30
					<?php echo self::get_action_link( $button, __( 'Delete button permanently', 'podlove-subscribe-button' ), 'delete', 'button' ) ?>
0 ignored issues
show
Coding Style introduced by
Inline PHP statement must end with a semicolon
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'self'.
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...
31
					<?php echo self::get_action_link( $button, __( "Don't change anything", 'podlove-subscribe-button' ), 'keep', 'button-primary' ) ?>
0 ignored issues
show
Coding Style introduced by
Inline PHP statement must end with a semicolon
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'self'.
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...
32
				</p>
33
			</div>
34
			<?php
35
		}
36
		?>
37
		<div class="wrap">
38
			<h1><?php echo __( 'Podlove Subscribe Button', 'podlove-subscribe-button' ); ?> <a href="?page=<?php echo filter_input( INPUT_GET, 'page' ); ?>&amp;action=new&amp;network=<?php echo $is_network; ?>" class="add-new-h2"><?php _e( 'Add New', 'podlove-subscribe-button' ); ?></a></h1>
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
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$is_network'.
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...
39
            <div id="poststuff">
40
                <div id="post-body" class="columns-2">
41
                    <div id="post-body-content">
42
	                    <?php
43
	                    switch ( $action ) {
44
		                    case 'new':   self::new_template(); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
45
		                    case 'edit':  self::edit_template(); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
46
		                    case 'index': self::view_template(); break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
47
		                    default:      self::view_template(); break;
0 ignored issues
show
Coding Style introduced by
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
48
	                    }
49
	                    ?>
50
                    </div>
51
                    <div id="postbox-container-1" class="postbox-container">
52
                        <?php self::sidebar(); ?>
53
                    </div>
54
                </div>
55
            </div>
56
		</div><!-- .wrap -->
57
		<?php
58
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
59
60
	/**
61
	 * Render the sidebar HTML
62
	 */
63
	public static function sidebar() { ?>
0 ignored issues
show
Coding Style introduced by
Closing PHP tag must be on a line by itself
Loading history...
64
        <div id="submitdiv" class="postbox">
65
            <h2 class="ui-sortable-handle"><span>Podlove Subscribe Button <code><?php echo \PodloveSubscribeButton::$version; ?></code></span></h2>
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 'PodloveSubscribeButton'.
Loading history...
66
            <div class="inside">
67
                <div id="minor-publishing" style="padding:0 10px;">
68
                    <p><?php _e( 'This plugin allows easy inclusion of the Podlove Subscribe Button. Put it in your sidebar with a simple widget or include the button in pages and/or posts with a simple shortcode.', 'podlove-subscribe-button' ); ?></p>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
69
                    <p><?php _e( 'Start by adding a button for each of your podcasts here. You can then add the button to your sidebar by adding the <a href="widgets.php">Podlove Subscribe Button widget</a>.', 'podlove-subscribe-button' ); ?></p>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
70
                    <p><?php _e( 'If you want to display the button inside a page or article, you can also use the <code>[podlove-subscribe-button]</code> shortcode anywhere.', 'podlove-subscribe-button' ); ?></p>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
71
                </div>
72
                <div id="major-publishing-actions">
73
                    <ul>
74
                        <li>
75
                            <a href="https://subscribe-button.podlove.org/" target="_blank">Podlove Subscribe Button</a>
76
                        </li>
77
                        <li>
78
                            <a href="https://podlove.org" target="_blank">Podlove Initiative</a>
79
                        </li>
80
                        <li>
81
                            <a href="https://community.podlove.org/" target="_blank">Podlove Community</a>
82
                        </li>
83
                        <li>
84
                            <a href="https://docs.podlove.org" target="_blank">Documentation &amp; Guides</a>
85
                        </li>
86
                        <li>
87
                            <a href="https://podlove.org/donations/" target="_blank">Donate</a>
88
                        </li>
89
                    </ul>
90
                </div>
91
            </div>
92
        </div>
93
        <?php
94
95
    }
96
97
	/**
98
	 * Process form: save/update a format
99
	 */
100
	public static function save() {
101
		if ( null == filter_input( INPUT_GET, '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...
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
102
			return;
103
104
		$post = filter_input_array( INPUT_POST );
105
106
		$button = ( filter_input( INPUT_GET, 'network' ) === '1' ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id( filter_input( INPUT_GET, 'button' ) ) : \PodloveSubscribeButton\Model\Button::find_by_id( filter_input( INPUT_GET, 'button' ) ) );
107
		$button->update_attributes( $post[ 'podlove_button' ] );
0 ignored issues
show
Bug introduced by
The method update_attributes() does not exist on null. ( Ignorable by Annotation )

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

107
		$button->/** @scrutinizer ignore-call */ 
108
           update_attributes( $post[ 'podlove_button' ] );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
introduced by
Array keys must NOT be surrounded by spaces if they only contain a string or an integer.
Loading history...
108
109
		if ( isset( $post[ 'submit_and_stay' ] ) ) {
0 ignored issues
show
introduced by
Array keys must NOT be surrounded by spaces if they only contain a string or an integer.
Loading history...
110
			self::redirect( 'edit', $button->id, array( 'network' => filter_input( INPUT_GET, 'network' ) ), ( filter_input( INPUT_GET, 'network' ) === '1' ? true : false ) );
111
		} else {
112
			self::redirect( 'index', $button->id, array(), ( filter_input( INPUT_GET, 'network' ) === '1' ? true : false ) );
113
		}
114
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
115
	/**
116
	 * Process form: create a format
117
	 */
118
	public static function create() {
119
		global $wpdb;
120
121
		$post = filter_input_array( INPUT_POST );
122
123
		$button = ( filter_input( INPUT_GET, 'network' ) === '1' ? new \PodloveSubscribeButton\Model\NetworkButton : new \PodloveSubscribeButton\Model\Button );
0 ignored issues
show
introduced by
Parenthesis should always be used when instantiating a new object.
Loading history...
124
		$button->update_attributes( $post[ 'podlove_button' ] );
0 ignored issues
show
introduced by
Array keys must NOT be surrounded by spaces if they only contain a string or an integer.
Loading history...
125
126
		if ( isset( $post[ 'submit_and_stay' ] ) ) {
0 ignored issues
show
introduced by
Array keys must NOT be surrounded by spaces if they only contain a string or an integer.
Loading history...
127
			self::redirect( 'edit', $button->id, array( 'network' => filter_input( INPUT_GET, 'network' ) ), ( filter_input( INPUT_GET, 'network' ) === '1' ? true : false ) );
128
		} else {
129
			self::redirect( 'index', $button->id, array(), ( filter_input( INPUT_GET, 'network' ) === '1' ? true : false ) );
130
		}
131
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
132
133
	/**
134
	 * Process form: delete a format
135
	 */
136
	public static function delete() {
137
		if ( null == filter_input( INPUT_GET, '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...
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
138
			return;
139
140
		$button = ( filter_input( INPUT_GET, 'network' ) === '1' ? \PodloveSubscribeButton\Model\NetworkButton::find_by_id( filter_input( INPUT_GET, 'button' ) ) : \PodloveSubscribeButton\Model\Button::find_by_id( filter_input( INPUT_GET, 'button' ) ) );
141
		$button->delete();
142
143
		self::redirect( 'index', null, array(), ( filter_input( INPUT_GET, 'network' ) === '1' ? true : false ) );
144
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
145
146
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$action" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$button_id" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$params" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$network" missing
Loading history...
147
	 * Helper method: redirect to a certain page.
148
	 */
149
	public static function redirect( $action, $button_id = null, $params = array(), $network = false ) {
150
		$page    = ( $network ? '/network/settings' : 'options-general' ) . '.php?page=' . filter_input( INPUT_GET, 'page' );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 4 spaces

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...
151
		$show    = ( $button_id ) ? '&button=' . $button_id : '';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 4 spaces

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...
152
		$action  = '&action=' . $action;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces

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...
153
154
		array_walk( $params, function( &$value, $key ) { $value = "&$key=$value"; } );
0 ignored issues
show
Coding Style introduced by
Opening brace must be the last content on the line
Loading history...
Coding Style introduced by
Closing brace of nested function must be on a new line
Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
155
156
		wp_redirect( admin_url( $page . $show . $action . implode( '', $params ) ) );
0 ignored issues
show
introduced by
wp_redirect() found. Using wp_safe_redirect(), along with the allowed_redirect_hosts filter if needed, can help avoid any chances of malicious redirects within code. It is also important to remember to call exit() after a redirect so that no other unwanted code is executed.
Loading history...
157
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
158
159
	public static function process_form() {
0 ignored issues
show
Coding Style introduced by
Method name "Buttons::process_form" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function process_form()
Loading history...
160
		if ( null === filter_input( INPUT_GET, '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...
161
			return;
162
163
		$action = ( null !== filter_input( INPUT_GET, 'action' ) ? filter_input( INPUT_GET, 'action' ) : null );
164
165
		if ( $action === 'save' ) {
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
166
			self::save();
167
		} elseif ( $action === 'create' ) {
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
168
			self::create();
169
		} elseif ( $action === 'delete' ) {
0 ignored issues
show
introduced by
Use Yoda Condition checks, you must.
Loading history...
170
			self::delete();
171
		}
172
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
173
174
	public static function new_template() {
0 ignored issues
show
Coding Style introduced by
Method name "Buttons::new_template" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function new_template()
Loading history...
175
		if ( filter_input( INPUT_GET, 'network' ) == '1' ) {
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
176
			$button = new \PodloveSubscribeButton\Model\NetworkButton;
0 ignored issues
show
introduced by
Parenthesis should always be used when instantiating a new object.
Loading history...
177
		} else {
178
			$button = new \PodloveSubscribeButton\Model\Button;
0 ignored issues
show
introduced by
Parenthesis should always be used when instantiating a new object.
Loading history...
179
		}
180
181
		echo '<h2>' . __( 'New Subscribe button', 'podlove-subscribe-button' ) . '</h2>' .
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...
182
				__( 'Please fill in your Podcast metadata to create a Podlove Subscription button', 'podlove-subscribe-button' );
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...
183
		self::form_template( $button, 'create' );
184
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
185
186
	public static function edit_template() {
0 ignored issues
show
Coding Style introduced by
Method name "Buttons::edit_template" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function edit_template()
Loading history...
187
		if ( filter_input( INPUT_GET, 'network' ) == '1' ) {
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
188
			$button = \PodloveSubscribeButton\Model\NetworkButton::find_by_id( filter_input( INPUT_GET, 'button' ) );
189
		} else {
190
			$button = \PodloveSubscribeButton\Model\Button::find_by_id( filter_input( INPUT_GET, 'button' ) );
191
		}
192
193
		echo '<h2>' . sprintf( __( 'Edit Subscribe button: %s', 'podlove-subscribe-button' ), $button->title ) . '</h2>';
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 '$button'.
Loading history...
194
		self::form_template( $button, 'save' );
195
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
196
197
	public static function view_template() {
0 ignored issues
show
Coding Style introduced by
Method name "Buttons::view_template" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function view_template()
Loading history...
198
199
		$is_network = is_network_admin();
200
		$table = new \PodloveSubscribeButton\Button_List_Table;
0 ignored issues
show
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...
introduced by
Parenthesis should always be used when instantiating a new object.
Loading history...
201
		$table->prepare_items();
202
		$table->display();
203
204
		if ( $is_network ) {
205
		    // https://vedovini.net/2015/10/using-the-wordpress-settings-api-with-network-admin-pages/
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
206
			?>
207
            <form method="post" action="edit.php?action=podlove_psb_update_network_options">
208
				<?php
209
				settings_fields( 'podlove-psb' );
210
				do_settings_sections( 'podlove-psb' );
211
				submit_button();
212
				?>
213
            </form>
214
			<?php
215
		} else {
216
			?>
217
            <form method="post" action="options.php">
218
				<?php
219
				settings_fields( 'podlove-psb' );
220
				do_settings_sections( 'podlove-psb' );
221
				submit_button();
222
				?>
223
            </form>
224
		<?php }
0 ignored issues
show
Coding Style introduced by
Opening PHP tag must be on a line by itself
Loading history...
225
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
226
227
	private static function form_template( $button, $action ) {
0 ignored issues
show
Coding Style introduced by
Method name "Buttons::form_template" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function form_template()
Loading history...
228
		// Enqueue Scripts for Media Manager
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
229
		wp_enqueue_media();
230
		// Adjust if is_network
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
231
		$is_network = is_network_admin();
232
		?>
233
		<form method="post" action="<?php echo ( $is_network === true ? '/wp-admin/network/settings' : 'options-general' ) ?>.php?page=podlove-subscribe-button&button=<?php echo $button->id; ?>&action=<?php echo $action; ?>&network=<?php echo $is_network; ?>">
0 ignored issues
show
Coding Style introduced by
Inline PHP statement must end with a semicolon
Loading history...
introduced by
Use Yoda Condition checks, you must.
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$button'.
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$action'.
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$is_network'.
Loading history...
234
			<input type="hidden" value="<?php echo $button->id; ?>" name="podlove_button[id]" />
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 '$button'.
Loading history...
235
			<table class="form-table" border="0" cellspacing="0">
236
					<tbody>
237
					<tr>
238
						<th scope="row">
239
							<label for="podlove_button_name"><?php _e( 'Button ID', 'podlove-subscribe-button' ); ?></label>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
240
						</th>
241
						<td>
242
							<input type="text" class="regular-text" id="podlove_button_name" name="podlove_button[name]" value="<?php echo $button->name; ?>" />
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 '$button'.
Loading history...
243
                            <p class="description"><?php _e( 'The ID will be used as in internal identifier for shortcodes.', 'podlove-subscribe-button' ); ?></p>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
244
                        </td>
245
					</tr>
246
					<tr>
247
						<th scope="row">
248
							<label for="podlove_button_title"><?php _e( 'Podcast Title', 'podlove-subscribe-button' ); ?></label>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
249
						</th>
250
						<td>
251
							<input type="text" class="regular-text" id="podlove_button_title" name="podlove_button[title]" value="<?php echo $button->title; ?>" />
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 '$button'.
Loading history...
252
						</td>
253
					</tr>
254
					<tr>
255
						<th scope="row">
256
							<label for="podlove_button_subtitle"><?php _e( 'Podcast Subtitle', 'podlove-subscribe-button' ); ?></label>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
257
						</th>
258
						<td>
259
							<input type="text" class="regular-text" id="podlove_button_subtitle" name="podlove_button[subtitle]" value="<?php echo $button->subtitle; ?>" />
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 '$button'.
Loading history...
260
						</td>
261
					</tr>
262
					<tr>
263
						<th scope="row">
264
							<label for="podlove_button_description"><?php _e( 'Podcast Description', 'podlove-subscribe-button' ); ?></label>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
265
						</th>
266
						<td>
267
							<textarea class="autogrow" cols="40" rows="3" id="podlove_button_description" name="podlove_button[description]"><?php echo $button->description; ?></textarea>
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 '$button'.
Loading history...
268
						</td>
269
					</tr>
270
					<tr>
271
						<th scope="row">
272
							<label for="podlove-button-cover"><?php _e( 'Podcast Image URL', 'podlove-subscribe-button' ); ?></label>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
273
						</th>
274
						<td>
275
							<input type="text" class="regular-text" id="podlove-button-cover" name="podlove_button[cover]" value="<?php echo $button->cover; ?>" />
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 '$button'.
Loading history...
276
							<a id="Podlove_cover_image_select" class="button" href="#">Select</a>
277
							<br /><img src="<?php echo $button->cover; ?>" alt="" style="width: 200px" />
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 '$button'.
Loading history...
278
							<script type="text/javascript">
279
								(function($) {
280
									$("#podlove-button-cover").on( 'change', function() {
281
										url = $(this).val();
282
										$(this).parent().find("img").attr("src", url);
283
									} );
284
								})(jQuery);
285
							</script>
286
						</td>
287
					</tr>
288
					<tr>
289
						<th scope="row">
290
							<label for="feeds_table"><?php _e( 'Podcast Feeds', 'podlove-subscribe-button' ); ?></label>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
291
						</th>
292
						<td>
293
							<table id="feeds_table" class="podlove_alternating widefat striped">
294
								<thead>
295
									<tr>
296
										<th scope="col" id="url" class="manage-column column-primary"><?php _e( 'URL', 'podlove-subscribe-button' ); ?></th>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
297
										<th scope="col" id="itunes_id" class="manage-column"><?php _e( 'iTunes feed ID', 'podlove-subscribe-button' ); ?></th>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
298
										<th scope="col" id="format" class="manage-column"><?php _e( 'Media format', 'podlove-subscribe-button' ); ?></th>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
299
										<th scope="col" id="action" class="manage-column"><?php _e( 'Actions', 'podlove-subscribe-button' ); ?></th>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
300
									</tr>
301
								</thead>
302
								<tbody id="feeds_table_body">
303
								</tbody>
304
							</table>
305
							<input type="button" class="button add_feed" value="+" />
306
							<p><span class="description"><?php _e( 'Provide all Feeds with their corresponding Media File Type. The Subscribe Button will then automatically provide the most suitable feed to the subscriber with respect to their Podcast Client.', 'podlove-subscribe-button' ); ?></span></p>
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
307
						</td>
308
					</tr>
309
					</tbody>
310
				</table>
311
				<input name="submit" id="submit" class="button button-primary" value="<?php _e( 'Save Changes', 'podlove-subscribe-button' ); ?>" type="submit" />
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
312
				<input type="submit" name="submit_and_stay" id="submit_and_stay" class="button" value="<?php _e( 'Save Changes and Continue Editing', 'podlove-subscribe-button' ); ?>"  />
0 ignored issues
show
introduced by
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
313
314
				<script type="text/template" id="feed_line_template">
315
					<tr>
316
						<td>
317
							<input type="text" class="regular-text" name="podlove_button[feeds][{{id}}][url]" value="{{url}}" />
318
						</td>
319
						<td>
320
						<input type="text" class="regular-text" name="podlove_button[feeds][{{id}}][itunesfeedid]" value="{{itunesfeedid}}" />
321
						</td>
322
						<td>
323
							<select class="regular-text podlove-media-format" name="podlove_button[feeds][{{id}}][format]">
324
								<?php
325
									foreach ( \PodloveSubscribeButton\Defaults::media_types() as $id => $audio ) {
326
										echo "<option value='" . $id . "'>" . $audio[ 'title' ] . "</option>\n";
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 '$id'.
Loading history...
introduced by
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$audio'.
Loading history...
introduced by
Array keys must NOT be surrounded by spaces if they only contain a string or an integer.
Loading history...
327
									}
328
								?>
329
							</select>
330
						</td>
331
						<td><span class="dashicons dashicons-trash clickable podlove-icon-remove"></span></td>
332
					</tr>
333
				</script>
334
				<script type="text/javascript">
335
					var feeds = <?php echo json_encode( $button->feeds ); ?>;
0 ignored issues
show
introduced by
json_encode() is discouraged. Use wp_json_encode() instead.
Loading history...
336
				</script>
337
		</form>
338
		<?php
339
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
340
341
	public static function get_action_link( $button, $title, $action = 'edit', $type = 'link' ) {
0 ignored issues
show
Coding Style introduced by
Method name "Buttons::get_action_link" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function get_action_link()
Loading history...
342
		return sprintf(
343
			'<a href="?page=%s&action=%s&button=%s&network=' . is_network_admin() . '"%s>' . $title . '</a>',
344
			filter_input( INPUT_GET, 'page' ),
345
			$action,
346
			$button->id,
347
			$type == 'button' ? ' class="button"' : ''
0 ignored issues
show
introduced by
Found: ==. Use strict comparisons (=== or !==).
Loading history...
introduced by
Use Yoda Condition checks, you must.
Loading history...
348
		);
349
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
350
351
	public static function podlove_psb_update_network_options() {
0 ignored issues
show
Coding Style introduced by
Method name "Buttons::podlove_psb_update_network_options" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function podlove_psb_update_network_options()
Loading history...
352
353
		//Verify Post Referring Page
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// Verify Post Referring Page" but found "//Verify Post Referring Page"
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
354
		check_admin_referer( 'podlove-psb-options' );
355
		update_site_option( 'podlove_psb_defaults', $_POST['podlove_psb_defaults'] );
0 ignored issues
show
introduced by
Detected usage of a non-validated input variable: $_POST
Loading history...
introduced by
Missing wp_unslash() before sanitization.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
356
357
		//Redirect to Network Settings Page
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// Redirect to Network Settings Page" but found "//Redirect to Network Settings Page"
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
358
		wp_redirect( add_query_arg( array( 'page' => 'podlove-subscribe-button', 'updated' => 'true' ), network_admin_url( 'settings.php' ) ) );
0 ignored issues
show
introduced by
wp_redirect() found. Using wp_safe_redirect(), along with the allowed_redirect_hosts filter if needed, can help avoid any chances of malicious redirects within code. It is also important to remember to call exit() after a redirect so that no other unwanted code is executed.
Loading history...
introduced by
When a multi-item array uses associative keys, each value should start on a new line.
Loading history...
359
360
		exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
361
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
362
363
} // END class
364