dsifford/academic-bloggers-toolkit

View on GitHub
src/php/options.php

Summary

Maintainability
A
1 hr
Test Coverage

Method render_options_page has 26 lines of code (exceeds 25 allowed). Consider refactoring.
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.',
Severity: Minor
Found in src/php/options.php - About 1 hr to fix

    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

    <?php
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces between opening bracket and type hint "string"; 1 found
    Open

    function enqueue_scripts( string $hook ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces between argument "$hook" and closing bracket; 1 found
    Open

    function enqueue_scripts( string $hook ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( 'settings_page_abt-options' !== $hook ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( ! current_user_can( 'manage_options' ) ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'You do not have sufficient permissions to access this page.',
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        add_options_page(
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            __NAMESPACE__ . '\render_options_page'
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            isset( $_POST[ ABT_NONCE ], $_POST['citation_style'] ) &&
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        if ( 'settings_page_abt-options' !== $hook ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        if ( ! current_user_can( 'manage_options' ) ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

                esc_html__(
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'academic-bloggers-toolkit'
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            __( "Academic Blogger's Toolkit Options", 'academic-bloggers-toolkit' ),
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            'manage_options',
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            'abt-options',
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return;
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        $options = get_option( ABT_OPTIONS_KEY );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        if (
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            __( "Academic Blogger's Toolkit", 'academic-bloggers-toolkit' ),
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        wp_enqueue_style( 'abt-options-page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            wp_die(
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            'ABT',
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            ]
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        wp_enqueue_script( 'abt-options-page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        wp_enqueue_script( 'codepen' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

                )
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            update_option( ABT_OPTIONS_KEY, $options );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            [
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        require_once __DIR__ . '/views/options-page.php';
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            'abt-options-page',
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        $options = json_decode( wp_json_encode( $options ) );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

                'styles'  => get_citation_styles(),
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            // Ignoring because there's no need to sanitize this.
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        wp_localize_script(
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

                'options' => $options,
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Spaces must be used to indent lines; tabs are not allowed
    Open

        // Convert associative array to object because it's just easier to work with.
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            isset( $_POST[ ABT_NONCE ], $_POST['citation_style'] ) &&
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Opening brace should be on a new line
    Open

    function register_options_page() {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            __( "Academic Blogger's Toolkit Options", 'academic-bloggers-toolkit' ),
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

        wp_enqueue_script( 'abt-options-page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces after opening bracket; 1 found
    Open

        if ( 'settings_page_abt-options' !== $hook ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            __( "Academic Blogger's Toolkit Options", 'academic-bloggers-toolkit' ),
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        wp_enqueue_script( 'codepen' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'admin_menu', __NAMESPACE__ . '\register_options_page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Opening brace should be on a new line
    Open

    function render_options_page() {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

    defined( 'ABSPATH' ) || exit;
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Opening brace should be on a new line
    Open

    function enqueue_scripts( string $hook ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

        wp_enqueue_script( 'codepen' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        $options = get_option( ABT_OPTIONS_KEY );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'admin_menu', __NAMESPACE__ . '\register_options_page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces after opening bracket; 1 found
    Open

        if ( ! current_user_can( 'manage_options' ) ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

        if ( ! current_user_can( 'manage_options' ) ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces after opening bracket; newline found
    Open

        if (
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

        $options = get_option( ABT_OPTIONS_KEY );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            isset( $_POST[ ABT_NONCE ], $_POST['citation_style'] ) &&
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            __( "Academic Blogger's Toolkit", 'academic-bloggers-toolkit' ),
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        wp_enqueue_script( 'abt-options-page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        wp_enqueue_style( 'abt-options-page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( ! current_user_can( 'manage_options' ) ) {
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            $options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

        $options = json_decode( wp_json_encode( $options ) );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

        wp_enqueue_style( 'abt-options-page' );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

    defined( 'ABSPATH' ) || exit;
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            __( "Academic Blogger's Toolkit", 'academic-bloggers-toolkit' ),
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            update_option( ABT_OPTIONS_KEY, $options );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        $options = json_decode( wp_json_encode( $options ) );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

        $options = json_decode( wp_json_encode( $options ) );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            update_option( ABT_OPTIONS_KEY, $options );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

        $options = json_decode( wp_json_encode( $options ) );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            $options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            $options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Expected 0 spaces before closing bracket; 1 found
    Open

            wp_verify_nonce( sanitize_key( $_POST[ ABT_NONCE ] ), ABT_ACTIONS['SET_CITATION_STYLE'] )
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    Space after opening parenthesis of function call prohibited
    Open

            $options['citation_style'] = json_decode( wp_unslash( $_POST['citation_style'] ), true );
    Severity: Minor
    Found in src/php/options.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status