From e0be02c492d57ebe6fb8c0af421e0670676a8b20 Mon Sep 17 00:00:00 2001 From: bdolor Date: Thu, 20 Dec 2018 12:18:10 -0800 Subject: [PATCH] apply coding standards --- admin/views/admin-settings.php | 10 +- admin/views/api-search.php | 40 +++---- admin/views/download-textbooks.php | 7 +- autoloader.php | 37 +++--- composer.json | 2 +- composer.lock | 24 ++-- .../namespace.php} | 0 phpcs.ruleset.xml | 2 + pressbooks-textbook.php | 2 +- .../tinymce-spellcheck/includes/atd-l10n.php | 42 +++---- .../includes/config-options.php | 112 ++++++++++-------- .../includes/config-unignore.php | 4 +- .../tinymce-spellcheck/includes/proxy.php | 20 ++-- .../tinymce-spellcheck/tinymce-spellcheck.php | 26 ++-- themes-book/opentextbook/functions.php | 2 +- .../opentextbook/inc/tab-functions.php | 24 ++-- themes-book/opentextbook/tabs-content.php | 4 +- 17 files changed, 189 insertions(+), 169 deletions(-) rename inc/{pbt-settings.php => settings/namespace.php} (100%) diff --git a/admin/views/admin-settings.php b/admin/views/admin-settings.php index e6163ba..e461bf8 100644 --- a/admin/views/admin-settings.php +++ b/admin/views/admin-settings.php @@ -18,17 +18,15 @@ get_settings_errors(); // message about functionality being tied to theme - if ( false == \PBT\Textbook::isTextbookTheme() ) { + if ( false === \PBT\Textbook::isTextbookTheme() ) { echo "

To access many features of this plugin, first activate one of our themes, such as the Open Textbook theme.

"; } ?> - +
@@ -53,7 +51,7 @@ class="nav-tab ">Se break; } - if ( ! in_array( $active_tab, [ 'revise' ] ) ) { + if ( ! in_array( $active_tab, [ 'revise' ], true ) ) { submit_button(); } ?> diff --git a/admin/views/api-search.php b/admin/views/api-search.php index b265f87..a1f7344 100644 --- a/admin/views/api-search.php +++ b/admin/views/api-search.php @@ -20,11 +20,11 @@

$book ) { // set book title, author, license - $book_title = $book['title']; + $book_title = $book['title']; $book_license = $book['license']; - $book_author = $book['author']; - $book_domain = $book['domain']; + $book_author = $book['author']; + $book_domain = $book['domain']; // do chapters if ( isset( $book['chapters'] ) ) { @@ -109,8 +109,8 @@ function () { - > + ?> + > @@ -125,34 +125,32 @@ function () { - + ?> - > - - + ?> + > + - + - + ?> @@ -161,7 +159,7 @@ function () { submit_button( __( 'Start', 'pressbooks-textbook' ), 'primary', 'submit', false ); echo '   '; // Space submit_button( __( 'Cancel', 'pressbooks-textbook' ), 'delete', 'abort_button', false ); - ?> + ?>

@@ -169,7 +167,7 @@ function () {
diff --git a/admin/views/download-textbooks.php b/admin/views/download-textbooks.php index 4bb1c4b..d98fbb1 100644 --- a/admin/views/download-textbooks.php +++ b/admin/views/download-textbooks.php @@ -16,7 +16,6 @@

- displayBySubject(); + $equella_fetch = new \PBT\Modules\Catalogue\EquellaFetch(); + $filter = new \PBT\Modules\Catalogue\Filter( $equella_fetch ); + $textbooks = $filter->displayBySubject(); } catch ( Exception $exc ) { echo $exc->getMessage(); diff --git a/autoloader.php b/autoloader.php index 01a560f..8c50623 100644 --- a/autoloader.php +++ b/autoloader.php @@ -11,35 +11,36 @@ \spl_autoload_register( function ( $class ) { - // project-specific namespace prefix - $prefix = 'PBT'; + // project-specific namespace prefix + $prefix = 'PBT'; - // base directory for the namespace prefix - $base_dir = __DIR__ . '/inc'; + // base directory for the namespace prefix + $base_dir = __DIR__ . '/inc'; - // does the class use the namespace prefix? - $len = \strlen( $prefix ); + // does the class use the namespace prefix? + $len = \strlen( $prefix ); if ( \strncmp( $prefix, $class, $len ) !== 0 ) { - // no, move to the next registered autoloader - return; + // no, move to the next registered autoloader + return; } - // get the relative class name - $relative_class = \substr( $class, $len ); + // get the relative class name + $relative_class = \substr( $class, $len ); + $last_ns_pos = strripos( $relative_class, '\\' ); - if ( false !== ( $last_ns_pos = strripos( $relative_class, '\\' ) ) ) { - $namespace = substr( $relative_class, 0, $last_ns_pos ); - $class = substr( $relative_class, $last_ns_pos + 1 ); - $file = str_replace( '\\', DIRECTORY_SEPARATOR, $namespace ) . DIRECTORY_SEPARATOR; + if ( false !== $last_ns_pos ) { + $namespace = substr( $relative_class, 0, $last_ns_pos ); + $class = substr( $relative_class, $last_ns_pos + 1 ); + $file = str_replace( '\\', DIRECTORY_SEPARATOR, $namespace ) . DIRECTORY_SEPARATOR; } - $file .= 'class-' . str_replace( '_', '-', $class ) . '.php'; + $file .= 'class-' . str_replace( '_', '-', $class ) . '.php'; - $path = $base_dir . strtolower( $file ); + $path = $base_dir . strtolower( $file ); - // if the file exists, require it + // if the file exists, require it if ( \file_exists( $path ) ) { - require $path; + require $path; } } ); diff --git a/composer.json b/composer.json index f2dbaa7..c45f004 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "@standards" ], "standards": [ - "vendor/bin/phpcs --standard=phpcs.ruleset.xml *.php inc/" + "vendor/bin/phpcs --standard=phpcs.ruleset.xml ." ] } } diff --git a/composer.lock b/composer.lock index 0e085a7..3e85663 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "81d6621ec351f88a8252d8a831116096", + "content-hash": "997ff79e746f776bd0338e1f31b74bf9", "packages": [], "packages-dev": [ { @@ -1305,16 +1305,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.3.2", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e" + "reference": "379deb987e26c7cd103a7b387aea178baec96e48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e", - "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", + "reference": "379deb987e26c7cd103a7b387aea178baec96e48", "shasum": "" }, "require": { @@ -1352,7 +1352,7 @@ "phpcs", "standards" ], - "time": "2018-09-23T23:08:17+00:00" + "time": "2018-12-19T23:57:18+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1414,16 +1414,16 @@ }, { "name": "symfony/yaml", - "version": "v3.4.18", + "version": "v3.4.20", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "640b6c27fed4066d64b64d5903a86043f4a4de7f" + "reference": "291e13d808bec481eab83f301f7bff3e699ef603" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/640b6c27fed4066d64b64d5903a86043f4a4de7f", - "reference": "640b6c27fed4066d64b64d5903a86043f4a4de7f", + "url": "https://api.github.com/repos/symfony/yaml/zipball/291e13d808bec481eab83f301f7bff3e699ef603", + "reference": "291e13d808bec481eab83f301f7bff3e699ef603", "shasum": "" }, "require": { @@ -1469,7 +1469,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-10-02T16:33:53+00:00" + "time": "2018-11-11T19:48:54+00:00" }, { "name": "webmozart/assert", diff --git a/inc/pbt-settings.php b/inc/settings/namespace.php similarity index 100% rename from inc/pbt-settings.php rename to inc/settings/namespace.php diff --git a/phpcs.ruleset.xml b/phpcs.ruleset.xml index 8cf35ba..8226ed1 100644 --- a/phpcs.ruleset.xml +++ b/phpcs.ruleset.xml @@ -38,5 +38,7 @@ /vendor/* + /tests/* + /symbionts/* diff --git a/pressbooks-textbook.php b/pressbooks-textbook.php index fde9e1c..062e353 100644 --- a/pressbooks-textbook.php +++ b/pressbooks-textbook.php @@ -133,7 +133,7 @@ function pb_compatibility() { | | */ -require PBT_PLUGIN_DIR . 'inc/pbt-settings.php'; +require PBT_PLUGIN_DIR . 'inc/settings/namespace.php'; /* |-------------------------------------------------------------------------- diff --git a/symbionts/tinymce-spellcheck/includes/atd-l10n.php b/symbionts/tinymce-spellcheck/includes/atd-l10n.php index 5841bbf..3b5fe44 100644 --- a/symbionts/tinymce-spellcheck/includes/atd-l10n.php +++ b/symbionts/tinymce-spellcheck/includes/atd-l10n.php @@ -8,33 +8,35 @@ function TSpell_init_l10n_js() { } // load localized strings for AtD - wp_localize_script( 'TSpell_settings', 'TSpell_l10n_r0ar', array( - 'menu_title_spelling' => __( 'Spelling', 'tinymce-spellcheck' ), - 'menu_title_repeated_word' => __( 'Repeated Word', 'tinymce-spellcheck' ), + wp_localize_script( + 'TSpell_settings', 'TSpell_l10n_r0ar', [ + 'menu_title_spelling' => __( 'Spelling', 'tinymce-spellcheck' ), + 'menu_title_repeated_word' => __( 'Repeated Word', 'tinymce-spellcheck' ), - 'menu_title_no_suggestions' => __( 'No suggestions', 'tinymce-spellcheck' ), + 'menu_title_no_suggestions' => __( 'No suggestions', 'tinymce-spellcheck' ), - 'menu_option_explain' => __( 'Explain...', 'tinymce-spellcheck' ), - 'menu_option_ignore_once' => __( 'Ignore suggestion', 'tinymce-spellcheck' ), - 'menu_option_ignore_always' => __( 'Ignore always', 'tinymce-spellcheck' ), - 'menu_option_ignore_all' => __( 'Ignore all', 'tinymce-spellcheck' ), + 'menu_option_explain' => __( 'Explain...', 'tinymce-spellcheck' ), + 'menu_option_ignore_once' => __( 'Ignore suggestion', 'tinymce-spellcheck' ), + 'menu_option_ignore_always' => __( 'Ignore always', 'tinymce-spellcheck' ), + 'menu_option_ignore_all' => __( 'Ignore all', 'tinymce-spellcheck' ), - 'menu_option_edit_selection' => __( 'Edit Selection...', 'tinymce-spellcheck' ), + 'menu_option_edit_selection' => __( 'Edit Selection...', 'tinymce-spellcheck' ), - 'button_proofread' => __( 'proofread', 'tinymce-spellcheck' ), - 'button_edit_text' => __( 'edit text', 'tinymce-spellcheck' ), - 'button_proofread_tooltip' => __( 'Proofread Writing', 'tinymce-spellcheck' ), + 'button_proofread' => __( 'proofread', 'tinymce-spellcheck' ), + 'button_edit_text' => __( 'edit text', 'tinymce-spellcheck' ), + 'button_proofread_tooltip' => __( 'Proofread Writing', 'tinymce-spellcheck' ), - 'message_no_errors_found' => __( 'No writing errors were found.', 'tinymce-spellcheck' ), - 'message_server_error' => __( 'There was a problem communicating with the Proofreading service. Try again in one minute.', 'tinymce-spellcheck' ), - 'message_server_error_short' => __( 'There was an error communicating with the proofreading service.', 'tinymce-spellcheck' ), + 'message_no_errors_found' => __( 'No writing errors were found.', 'tinymce-spellcheck' ), + 'message_server_error' => __( 'There was a problem communicating with the Proofreading service. Try again in one minute.', 'tinymce-spellcheck' ), + 'message_server_error_short' => __( 'There was an error communicating with the proofreading service.', 'tinymce-spellcheck' ), - 'dialog_replace_selection' => __( 'Replace selection with:', 'tinymce-spellcheck' ), - 'dialog_confirm_post_publish' => __( "The proofreader has suggestions for this post. Are you sure you want to publish it?\n\nPress OK to publish your post, or Cancel to view the suggestions and edit your post.", 'tinymce-spellcheck' ), - 'dialog_confirm_post_update' => __( "The proofreader has suggestions for this post. Are you sure you want to update it?\n\nPress OK to update your post, or Cancel to view the suggestions and edit your post.", 'tinymce-spellcheck' ), - ) ); + 'dialog_replace_selection' => __( 'Replace selection with:', 'tinymce-spellcheck' ), + 'dialog_confirm_post_publish' => __( "The proofreader has suggestions for this post. Are you sure you want to publish it?\n\nPress OK to publish your post, or Cancel to view the suggestions and edit your post.", 'tinymce-spellcheck' ), + 'dialog_confirm_post_update' => __( "The proofreader has suggestions for this post. Are you sure you want to update it?\n\nPress OK to update your post, or Cancel to view the suggestions and edit your post.", 'tinymce-spellcheck' ), + ] + ); - wp_enqueue_script( 'TSpell_l10n', plugins_url( '/js/install_atd_l10n.js', dirname( __FILE__ ) ), array( 'TSpell_settings', 'jquery' ), TSPELL_VERSION ); + wp_enqueue_script( 'TSpell_l10n', plugins_url( '/js/install_atd_l10n.js', dirname( __FILE__ ) ), [ 'TSpell_settings', 'jquery' ], TSPELL_VERSION ); } add_action( 'admin_print_scripts', 'TSpell_init_l10n_js' ); diff --git a/symbionts/tinymce-spellcheck/includes/config-options.php b/symbionts/tinymce-spellcheck/includes/config-options.php index 469f184..2ddde57 100644 --- a/symbionts/tinymce-spellcheck/includes/config-options.php +++ b/symbionts/tinymce-spellcheck/includes/config-options.php @@ -8,10 +8,10 @@ */ function TSpell_print_option( $name, $value, $options ) { // Attribute-safe version of $name - $attr_name = sanitize_title($name); // Using sanitize_title since there's no comparable function for attributes -?> - > - + > + ID == 0 ) + if ( ! $user || $user->ID == 0 ) { return; + } TSpell_update_options( $user->ID, 'TSpell_options' ); TSpell_update_options( $user->ID, 'TSpell_check_when' ); @@ -36,66 +37,79 @@ function TSpell_display_options_form() { // grab our user and validate their existence $user = wp_get_current_user(); - if ( ! $user || $user->ID == 0 ) + if ( ! $user || $user->ID == 0 ) { return; + } $options_show_types = TSpell_get_options( $user->ID, 'TSpell_options' ); $options_check_when = TSpell_get_options( $user->ID, 'TSpell_check_when' ); $options_guess_lang = TSpell_get_options( $user->ID, 'TSpell_guess_lang' ); -?> + ?> - - + +

-

+ '; - TSpell_print_option( 'onupdate', __('a post or page is updated', 'tinymce-spellcheck'), $options_check_when ); - ?>

+ TSpell_print_option( 'onupdate', __( 'a post or page is updated', 'tinymce-spellcheck' ), $options_check_when ); + ?> +

-

+

-

+

-

+ '; - TSpell_print_option( 'Cliches', __('Clichés', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Cliches', __( 'Clichés', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Complex Expression', __('Complex Phrases', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Complex Expression', __( 'Complex Phrases', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Diacritical Marks', __('Diacritical Marks', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Diacritical Marks', __( 'Diacritical Marks', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Double Negative', __('Double Negatives', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Double Negative', __( 'Double Negatives', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Hidden Verbs', __('Hidden Verbs', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Hidden Verbs', __( 'Hidden Verbs', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Jargon Language', __('Jargon', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Jargon Language', __( 'Jargon', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Passive voice', __('Passive Voice', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Passive voice', __( 'Passive Voice', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Phrases to Avoid', __('Phrases to Avoid', 'tinymce-spellcheck'), $options_show_types ); + TSpell_print_option( 'Phrases to Avoid', __( 'Phrases to Avoid', 'tinymce-spellcheck' ), $options_show_types ); echo '
'; - TSpell_print_option( 'Redundant Expression', __('Redundant Phrases', 'tinymce-spellcheck'), $options_show_types ); - ?>

-

Learn more about these options.', 'tinymce-spellcheck' ), 'http://support.wordpress.com/proofreading/' ); -?>

+ TSpell_print_option( 'Redundant Expression', __( 'Redundant Phrases', 'tinymce-spellcheck' ), $options_show_types ); + ?> +

+

+ Learn more about these options.', 'tinymce-spellcheck' ), 'http://support.wordpress.com/proofreading/' ); + ?> +

- -

%2$s value is the default proofreading language.', '%1$s = http://codex.wordpress.org/Installing_WordPress_in_Your_Language, %2$s = WPLANG', 'tinymce-spellcheck' ), - 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language', - 'WPLANG' - ); ?>

- -

- - + %2$s value is the default proofreading language.', '%1$s = http://codex.wordpress.org/Installing_WordPress_in_Your_Language, %2$s = WPLANG', 'tinymce-spellcheck' ), + 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language', + 'WPLANG' + ); + ?> +

+ +

+ +

+ + ID, 'TSpell_ignored_phrases' ); -?> + ?>