dsifford/academic-bloggers-toolkit

View on GitHub
src/academic-bloggers-toolkit.php

Summary

Maintainability
A
1 hr
Test Coverage

Method register_scripts has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function register_scripts() {
    //
    // Editor.
    //
    register_script( 'editor-stores' );
Severity: Minor
Found in src/academic-bloggers-toolkit.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 23 and the first side effect is on line 21.
    Open

    <?php

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

    function add_options_link( array $links ): array {

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

    function add_donate_link( array $links, string $file ): array {

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

    function add_donate_link( array $links, string $file ): array {

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( plugin_basename( __FILE__ ) === $file ) {

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

    function add_options_link( array $links ): array {

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( version_compare( ABT_VERSION, $options['VERSION'] ?? '0', '>' ) ) {

    Expected 0 spaces before closing bracket; 1 found
    Open

    if ( is_admin() ) {

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

        ]

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

            update_option( ABT_OPTIONS_KEY, $new_options );

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

            $links[] = sprintf(

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

                'VERSION'        => ABT_VERSION,

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

                    'value' => $options['citation_style']['value'] ?? 'american-medical-association',

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

        delete_option( ABT_OPTIONS_KEY );

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

                'citation_style' => [

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

        if ( version_compare( ABT_VERSION, $options['VERSION'] ?? '0', '>' ) ) {

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

                    'kind'  => $options['citation_style']['kind'] ?? 'predefined',

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

            ];

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

            'SET_CITATION_STYLE' => 'abt-form-set-citation-style',

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

        $options = get_option( ABT_OPTIONS_KEY );

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

        if ( plugin_basename( __FILE__ ) === $file ) {

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

        $url  = admin_url( 'options-general.php?page=abt-options' );

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

        'ABT_ACTIONS',

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

        load_plugin_textdomain( 'academic-bloggers-toolkit', false, basename( ABT_ROOT_PATH ) . '/languages' );

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

            $new_options = [

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

        }

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

                'https://donorbox.org/academic-bloggers-toolkit',

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

                'abt-editor-stores',

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

        //

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

        //

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

            '//assets.codepen.io/assets/embed/ei.js',

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

        require_once __DIR__ . '/php/editor.php';

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

            );

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

        }

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

                'abt-editor-stores',

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

            'editor-formats',

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

            'editor',

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

                'abt-editor-formats',

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

        wp_register_script(

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

        // Vendor.

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

        );

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

                ],

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

                __( 'Donate', 'academic-bloggers-toolkit' )

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

        return $links;

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

            [

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

        // Options Page.

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

            [],

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

            [

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

            ABT_ROOT_URI . '/vendor/citeproc.js',

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

        // Third party.

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

        <script type="text/javascript">

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

        [

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

        $text = __( 'Plugin Settings', 'academic-bloggers-toolkit' );

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

        register_script( 'editor-stores' );

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

        register_script(

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

            ]

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

            [

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

        register_script( 'options-page' );

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

            'citeproc',

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

            true

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

        //

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

            [],

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

            window._abt_nonce = '<?php echo esc_html( wp_create_nonce( 'abt-ajax' ) ); ?>'

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

        // Frontend.

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

        require_once __DIR__ . '/php/options.php';

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

                    'label' => $options['citation_style']['label'] ?? 'American Medical Association',

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

            'editor-blocks',

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

        //

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

        register_script( 'frontend' );

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

        wp_register_script(

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

        ?>

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

        return array_merge( $links, [ "<a href='$url'>$text</a>" ] );

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

        //

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

        );

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

        <?php

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

        require_once __DIR__ . '/php/frontend.php';

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

            ]

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

                'abt-editor-stores',

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

        register_script(

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

                'abt-editor-blocks',

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

            true

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

                '&hearts; <a href="%s">%s</a>',

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

        //

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

            filemtime( ABT_ROOT_PATH . '/vendor/citeproc.js' ),

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

            'codepen',

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

        </script>

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

        // Editor.

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

        //

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

        );

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

            ]

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

        register_script(

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

        //

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

        //

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

        //

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

        );

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

            ABT_VERSION,

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

        );

    Space after opening parenthesis of function call prohibited
    Open

    defined( 'ABSPATH' ) || exit;

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( version_compare( ABT_VERSION, $options['VERSION'] ?? '0', '>' ) ) {

    Space after opening parenthesis of function call prohibited
    Open

    define( 'ABT_ROOT_URI', plugins_url( '', __FILE__ ) );

    Expected 0 spaces before closing bracket; 1 found
    Open

        return array_merge( $links, [ "<a href='$url'>$text</a>" ] );

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\add_options_link' );

    Space after opening parenthesis of function call prohibited
    Open

    add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\add_options_link' );

    Space after opening parenthesis of function call prohibited
    Open

        if ( plugin_basename( __FILE__ ) === $file ) {

    Expected 0 spaces before closing bracket; 1 found
    Open

        load_plugin_textdomain( 'academic-bloggers-toolkit', false, basename( ABT_ROOT_PATH ) . '/languages' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'plugins_loaded', __NAMESPACE__ . '\plugin_textdomain' );

    Expected 0 spaces before closing bracket; 1 found
    Open

        $options = get_option( ABT_OPTIONS_KEY );

    Space after opening parenthesis of function call prohibited
    Open

        load_plugin_textdomain( 'academic-bloggers-toolkit', false, basename( ABT_ROOT_PATH ) . '/languages' );

    Expected 0 spaces before closing bracket; 1 found
    Open

        delete_option( ABT_OPTIONS_KEY );

    Space after opening parenthesis of function call prohibited
    Open

    register_uninstall_hook( __FILE__, __NAMESPACE__ . '\uninstall' );

    Opening brace should be on a new line
    Open

    function refactor_options() {

    Expected 0 spaces after opening bracket; 1 found
    Open

        if ( plugin_basename( __FILE__ ) === $file ) {

    Expected 0 spaces before closing bracket; 1 found
    Open

    defined( 'ABSPATH' ) || exit;

    Space after opening parenthesis of function call prohibited
    Open

        load_plugin_textdomain( 'academic-bloggers-toolkit', false, basename( ABT_ROOT_PATH ) . '/languages' );

    Space after opening parenthesis of function call prohibited
    Open

        delete_option( ABT_OPTIONS_KEY );

    Space after opening parenthesis of function call prohibited
    Open

    add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\add_options_link' );

    Space after opening parenthesis of function call prohibited
    Open

    define( 'ABT_VERSION', '{{VERSION}}' );

    Space after opening parenthesis of function call prohibited
    Open

        $options = get_option( ABT_OPTIONS_KEY );

    Space after opening parenthesis of function call prohibited
    Open

        return array_merge( $links, [ "<a href='$url'>$text</a>" ] );

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\add_options_link' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'admin_init', __NAMESPACE__ . '\refactor_options' );

    Space after opening parenthesis of function call prohibited
    Open

        $text = __( 'Plugin Settings', 'academic-bloggers-toolkit' );

    Space after opening parenthesis of function call prohibited
    Open

    define( 'ABT_ROOT_URI', plugins_url( '', __FILE__ ) );

    Expected 0 spaces before closing bracket; 1 found
    Open

    define( 'ABT_VERSION', '{{VERSION}}' );

    Space after opening parenthesis of function call prohibited
    Open

        if ( version_compare( ABT_VERSION, $options['VERSION'] ?? '0', '>' ) ) {

    Space after opening parenthesis of function call prohibited
    Open

            update_option( ABT_OPTIONS_KEY, $new_options );

    Opening brace should be on a new line
    Open

    function add_options_link( array $links ): array {

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'plugins_loaded', __NAMESPACE__ . '\plugin_textdomain' );

    Space after opening parenthesis of function call prohibited
    Open

        register_script( 'frontend' );

    Expected 0 spaces before closing bracket; 1 found
    Open

        register_script( 'editor-stores' );

    Space after opening parenthesis of function call prohibited
    Open

        register_script( 'options-page' );

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'admin_head-post.php', __NAMESPACE__ . '\ajax_nonce' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'admin_head-post.php', __NAMESPACE__ . '\ajax_nonce' );

    Space after opening parenthesis of function call prohibited
    Open

    define( 'ABT_NONCE', 'abt_nonce' );

    Expected 0 spaces before closing bracket; 1 found
    Open

            update_option( ABT_OPTIONS_KEY, $new_options );

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'admin_init', __NAMESPACE__ . '\refactor_options' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'admin_head-post-new.php', __NAMESPACE__ . '\ajax_nonce' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'admin_head-settings_page_abt-options', __NAMESPACE__ . '\ajax_nonce' );

    Expected 0 spaces after opening bracket; 1 found
    Open

        if ( version_compare( ABT_VERSION, $options['VERSION'] ?? '0', '>' ) ) {

    Expected 0 spaces before closing bracket; 1 found
    Open

        $url  = admin_url( 'options-general.php?page=abt-options' );

    Expected 0 spaces before closing bracket; 1 found
    Open

        if ( plugin_basename( __FILE__ ) === $file ) {

    Expected 0 spaces before closing bracket; 1 found
    Open

        register_script( 'frontend' );

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'wp_loaded', __NAMESPACE__ . '\register_scripts' );

    Opening brace should be on a new line
    Open

    function ajax_nonce() {

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'admin_head-post-new.php', __NAMESPACE__ . '\ajax_nonce' );

    Space after opening parenthesis of function call prohibited
    Open

                __( 'Donate', 'academic-bloggers-toolkit' )

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_action( 'wp_loaded', __NAMESPACE__ . '\register_scripts' );

    Space after opening parenthesis of function call prohibited
    Open

            filemtime( ABT_ROOT_PATH . '/vendor/citeproc.js' ),

    Expected 0 spaces before closing bracket; 1 found
    Open

    define( 'ABT_ROOT_URI', plugins_url( '', __FILE__ ) );

    Opening brace should be on a new line
    Open

    function uninstall() {

    Expected 0 spaces before closing bracket; 1 found
    Open

    add_filter( 'plugin_row_meta', __NAMESPACE__ . '\add_donate_link', 10, 2 );

    Space after opening parenthesis of function call prohibited
    Open

    add_action( 'admin_head-settings_page_abt-options', __NAMESPACE__ . '\ajax_nonce' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    define( 'ABT_NONCE', 'abt_nonce' );

    Space after opening parenthesis of function call prohibited
    Open

    define( 'ABT_OPTIONS_KEY', 'abt_options' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    define( 'ABT_OPTIONS_KEY', 'abt_options' );

    Space after opening parenthesis of function call prohibited
    Open

    define( 'ABT_ROOT_PATH', __DIR__ );

    Expected 0 spaces before closing bracket; 1 found
    Open

        load_plugin_textdomain( 'academic-bloggers-toolkit', false, basename( ABT_ROOT_PATH ) . '/languages' );

    Space after opening parenthesis of function call prohibited
    Open

        $url  = admin_url( 'options-general.php?page=abt-options' );

    Expected 0 spaces before closing bracket; 1 found
    Open

        $text = __( 'Plugin Settings', 'academic-bloggers-toolkit' );

    Space after opening parenthesis of function call prohibited
    Open

            window._abt_nonce = '<?php echo esc_html( wp_create_nonce( 'abt-ajax' ) ); ?>'

    Expected 0 spaces before closing bracket; 1 found
    Open

                __( 'Donate', 'academic-bloggers-toolkit' )

    Space after opening parenthesis of function call prohibited
    Open

        register_script( 'editor-stores' );

    Expected 0 spaces before closing bracket; 1 found
    Open

        register_script( 'options-page' );

    Expected 0 spaces before closing bracket; 1 found
    Open

    define( 'ABT_ROOT_PATH', __DIR__ );

    Expected 0 spaces before closing bracket; 1 found
    Open

    define( 'ABT_ROOT_URI', plugins_url( '', __FILE__ ) );

    Opening brace should be on a new line
    Open

    function plugin_textdomain() {

    Expected 0 spaces before closing bracket; 1 found
    Open

    register_uninstall_hook( __FILE__, __NAMESPACE__ . '\uninstall' );

    Opening brace should be on a new line
    Open

    function add_donate_link( array $links, string $file ): array {

    Space after opening parenthesis of function call prohibited
    Open

            window._abt_nonce = '<?php echo esc_html( wp_create_nonce( 'abt-ajax' ) ); ?>'

    Expected 0 spaces before closing bracket; 1 found
    Open

            window._abt_nonce = '<?php echo esc_html( wp_create_nonce( 'abt-ajax' ) ); ?>'

    Space after opening parenthesis of function call prohibited
    Open

    add_filter( 'plugin_row_meta', __NAMESPACE__ . '\add_donate_link', 10, 2 );

    Expected 0 spaces after opening bracket; 1 found
    Open

    if ( is_admin() ) {

    Opening brace should be on a new line
    Open

    function register_scripts() {

    Expected 0 spaces before closing bracket; 1 found
    Open

            filemtime( ABT_ROOT_PATH . '/vendor/citeproc.js' ),

    Expected 0 spaces before closing bracket; 1 found
    Open

            window._abt_nonce = '<?php echo esc_html( wp_create_nonce( 'abt-ajax' ) ); ?>'

    There are no issues that match your filters.

    Category
    Status