Skip to content

Commit

Permalink
apply coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
bdolor committed Dec 20, 2018
1 parent d7f11f9 commit e0be02c
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 169 deletions.
10 changes: 4 additions & 6 deletions admin/views/admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<div class='updated'><p>To access many features of this plugin, first <a href='themes.php'>activate one of our themes</a>, such as the Open Textbook theme.</p></div>";
}
?>
<?php $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'remix'; ?>
<?php $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'remix'; //@codingStandardsIgnoreLine ?>

<div id="icon-options-general" class="icon32"></div>
<h2 class="nav-tab-wrapper">
<a href="?page=pressbooks-textbook-settings&tab=remix"
class="nav-tab <?php echo $active_tab == 'remix' ? 'nav-tab-active' : ''; ?>">Search
and Import</a>
<a href="?page=pressbooks-textbook-settings&tab=remix" class="nav-tab <?php echo $active_tab === 'remix' ? 'nav-tab-active' : ''; ?>">Search and Import</a>
</h2>
<!-- Create the form that will be used to modify display options -->
<form method="post" action="options.php" name="pbt_settings">
Expand All @@ -53,7 +51,7 @@ class="nav-tab <?php echo $active_tab == 'remix' ? 'nav-tab-active' : ''; ?>">Se
break;

}
if ( ! in_array( $active_tab, [ 'revise' ] ) ) {
if ( ! in_array( $active_tab, [ 'revise' ], true ) ) {
submit_button();
}
?>
Expand Down
40 changes: 19 additions & 21 deletions admin/views/api-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>

<?php
$pbt_import_url = wp_nonce_url( get_bloginfo( 'url' ) . '/wp-admin/options-general.php?page=api_search_import&import=1', 'pbt-import' );
$pbt_revoke_url = wp_nonce_url( get_bloginfo( 'url' ) . '/wp-admin/options-general.php?page=api_search_import&revoke=1', 'pbt-revoke-import' );
$pbt_import_url = wp_nonce_url( get_bloginfo( 'url' ) . '/wp-admin/options-general.php?page=api_search_import&import=1', 'pbt-import' );
$pbt_revoke_url = wp_nonce_url( get_bloginfo( 'url' ) . '/wp-admin/options-general.php?page=api_search_import&revoke=1', 'pbt-revoke-import' );
$pbt_current_import = get_option( 'pbt_current_import' );
$not_found = get_option( 'pbt_terms_not_found' );
$remix = get_option( 'pbt_remix_settings' );
$not_found = get_option( 'pbt_terms_not_found' );
$remix = get_option( 'pbt_remix_settings' );

// IMPORT show only if there is an import in progress
if ( is_array( $pbt_current_import ) ) {
Expand Down Expand Up @@ -87,10 +87,10 @@ function () {

foreach ( $pbt_current_import as $book_id => $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'] ) ) {
Expand All @@ -109,8 +109,8 @@ function () {
<?php
if ( $i % 2 ) {
echo 'class="alt"';}
?>
>
?>
>

<td><input type='checkbox' id='selective_import_<?php echo $i; ?>' name='chapters[<?php echo $key; ?>][import]' value='1'></td>
<input type='hidden' name='chapters[<?php echo $key; ?>][book]' value='<?php echo $book_id; ?>'>
Expand All @@ -125,34 +125,32 @@ function () {
<td><input type='radio' name='chapters[<?php echo $key; ?>][type]' value='chapter' checked='checked'></td>
<td><input type='radio' name='chapters[<?php echo $key; ?>][type]' value='back-matter'></td>
</tr>
<?php
++ $i;
<?php
++ $i;
}
// do books
} else {
?>
?>
<tr
<?php
if ( $i % 2 ) {
echo 'class="alt"';}
?>
>

<td><input type="radio" id="selective_import_<?php echo $i; ?>" name="book" value="<?php echo $book_id ; ?>" /></td>
?>
>
<td><input type="radio" id="selective_import_<?php echo $i; ?>" name="book" value="<?php echo $book_id; ?>" /></td>
<input type='hidden' name='domain' value='<?php echo $book_domain; ?>'>
<td><label>-----</label></td>
<td><label for="selective_import_<?php echo $i ; ?>"><?php echo $book_title . ', by ' . $book_author ; ?></label>
<td><label for="selective_import_<?php echo $i; ?>"><?php echo $book_title . ', by ' . $book_author; ?></label>
<td><label><?php echo $book_license; ?></label></td>
<td><label>-----</label></td>
<td><label>-----</label></td>
<td><label>-----</label></td>
</tr>

<?php
$i++;
}
}
?>
?>
</tbody>
</table>

Expand All @@ -161,15 +159,15 @@ function () {
submit_button( __( 'Start', 'pressbooks-textbook' ), 'primary', 'submit', false );
echo ' &nbsp; '; // Space
submit_button( __( 'Cancel', 'pressbooks-textbook' ), 'delete', 'abort_button', false );
?>
?>
</p>

</form>

<?php
} else {

if ( false != $not_found ) {
if ( false !== $not_found ) {
?>

<div class="error">
Expand Down
7 changes: 3 additions & 4 deletions admin/views/download-textbooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<div class="wrap">
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>

<?php
require( PBT_PLUGIN_DIR . 'inc/modules/catalogue/class-equellafetch.php' );
require( PBT_PLUGIN_DIR . 'inc/modules/catalogue/class-filter.php' );
Expand All @@ -31,9 +30,9 @@
echo $textbooks;
} else {
try {
$equellaFetch = new \PBT\Modules\Catalogue\EquellaFetch();
$filter = new \PBT\Modules\Catalogue\Filter( $equellaFetch );
$textbooks = $filter->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();
Expand Down
37 changes: 19 additions & 18 deletions autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
);
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@standards"
],
"standards": [
"vendor/bin/phpcs --standard=phpcs.ruleset.xml *.php inc/"
"vendor/bin/phpcs --standard=phpcs.ruleset.xml ."
]
}
}
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 2 additions & 0 deletions phpcs.ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@
</rule>

<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/tests/*</exclude-pattern>
<exclude-pattern>/symbionts/*</exclude-pattern>

</ruleset>
2 changes: 1 addition & 1 deletion pressbooks-textbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function pb_compatibility() {
|
|
*/
require PBT_PLUGIN_DIR . 'inc/pbt-settings.php';
require PBT_PLUGIN_DIR . 'inc/settings/namespace.php';

/*
|--------------------------------------------------------------------------
Expand Down
42 changes: 22 additions & 20 deletions symbionts/tinymce-spellcheck/includes/atd-l10n.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Loading

0 comments on commit e0be02c

Please sign in to comment.