src/php/options.php
Method render_options_page
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function render_options_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die(
esc_html__(
'You do not have sufficient permissions to access this page.',
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 19 and the first side effect is on line 12. Open
Open
<?php
- Exclude checks
Expected 0 spaces between opening bracket and type hint "string"; 1 found Open
Open
function enqueue_scripts( string $hook ) {
- Exclude checks
Expected 0 spaces between argument "$hook" and closing bracket; 1 found Open
Open
function enqueue_scripts( string $hook ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( 'settings_page_abt-options' !== $hook ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( ! current_user_can( 'manage_options' ) ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'You do not have sufficient permissions to access this page.',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
add_options_page(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
__NAMESPACE__ . '\render_options_page'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
isset( $_POST[ ABT_NONCE ], $_POST['citation_style'] ) &&
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( 'settings_page_abt-options' !== $hook ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( ! current_user_can( 'manage_options' ) ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
esc_html__(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'academic-bloggers-toolkit'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
__( "Academic Blogger's Toolkit Options", 'academic-bloggers-toolkit' ),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'manage_options',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'abt-options',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$options = get_option( ABT_OPTIONS_KEY );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
__( "Academic Blogger's Toolkit", 'academic-bloggers-toolkit' ),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_enqueue_style( 'abt-options-page' );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_die(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'ABT',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_enqueue_script( 'abt-options-page' );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_enqueue_script( 'codepen' );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
update_option( ABT_OPTIONS_KEY, $options );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
[
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
require_once __DIR__ . '/views/options-page.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'abt-options-page',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$options = json_decode( wp_json_encode( $options ) );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'styles' => get_citation_styles(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
// Ignoring because there's no need to sanitize this.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_localize_script(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'options' => $options,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
// Convert associative array to object because it's just easier to work with.
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
isset( $_POST[ ABT_NONCE ], $_POST['citation_style'] ) &&
- Exclude checks
Opening brace should be on a new line Open
Open
function register_options_page() {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
__( "Academic Blogger's Toolkit Options", 'academic-bloggers-toolkit' ),
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
wp_enqueue_script( 'abt-options-page' );
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( 'settings_page_abt-options' !== $hook ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
__( "Academic Blogger's Toolkit Options", 'academic-bloggers-toolkit' ),
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
wp_enqueue_script( 'codepen' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
add_action( 'admin_menu', __NAMESPACE__ . '\register_options_page' );
- Exclude checks
Opening brace should be on a new line Open
Open
function render_options_page() {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
defined( 'ABSPATH' ) || exit;
- Exclude checks
Opening brace should be on a new line Open
Open
function enqueue_scripts( string $hook ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
wp_enqueue_script( 'codepen' );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$options = get_option( ABT_OPTIONS_KEY );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
add_action( 'admin_menu', __NAMESPACE__ . '\register_options_page' );
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( ! current_user_can( 'manage_options' ) ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if ( ! current_user_can( 'manage_options' ) ) {
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
Open
if (
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$options = get_option( ABT_OPTIONS_KEY );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
isset( $_POST[ ABT_NONCE ], $_POST['citation_style'] ) &&
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
__( "Academic Blogger's Toolkit", 'academic-bloggers-toolkit' ),
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
wp_enqueue_script( 'abt-options-page' );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
wp_enqueue_style( 'abt-options-page' );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( ! current_user_can( 'manage_options' ) ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$options = json_decode( wp_json_encode( $options ) );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
wp_enqueue_style( 'abt-options-page' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
defined( 'ABSPATH' ) || exit;
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
__( "Academic Blogger's Toolkit", 'academic-bloggers-toolkit' ),
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
update_option( ABT_OPTIONS_KEY, $options );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$options = json_decode( wp_json_encode( $options ) );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$options = json_decode( wp_json_encode( $options ) );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
update_option( ABT_OPTIONS_KEY, $options );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$options = json_decode( wp_json_encode( $options ) );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
- Exclude checks