Skip to content

Commit

Permalink
Merge pull request #18 from threadi/feature/addGitHubAction
Browse files Browse the repository at this point in the history
Feature/add GitHub action
  • Loading branch information
threadi authored Dec 22, 2024
2 parents 8119eb7 + dadec84 commit 7e5548d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
composer update
- name: Run WordPress Coding Standard fixes
run: vendor/bin/phpcbf --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/*,*/gettext-helper.php,*/classes/multilingual-plugins/easy-language/pagebuilder/divi/build/,*/classes/multilingual-plugins/easy-language/blocks/*/build/,*translatepress* --standard=ruleset.xml .
run: vendor/bin/phpcbf --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .

- name: Run WordPress Coding Standard checks
run: vendor/bin/phpcs --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/*,*/gettext-helper.php,*/classes/multilingual-plugins/easy-language/pagebuilder/divi/build/,*/classes/multilingual-plugins/easy-language/blocks/*/build/,*translatepress* --standard=ruleset.xml .
run: vendor/bin/phpcs --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .

- name: Set version number 1
uses: richardrigutins/replace-in-files@v2
Expand All @@ -47,8 +47,8 @@ jobs:
rm -fr build
rm -fr releases
rm -fr languages
rm -fr changelog.md
rm -fr svn
rm changelog.md
rm readme.md
cd ..
zip -r -q ${{ github.event.repository.name }}_${{ github.ref_name }}.zip ${{ github.event.repository.name }}/* -x "*/.git/*" "*/.github/*" "*/blocks/*/src/*" "*/doc/*" "*/phpcs.xml" "*/composer.json" "*/composer.lock" "*/package.json" "*/package-lock.json" "*/.gitignore" "*/vendor/*" "*/node_modules/*" "/.editorconfig"
Expand Down
30 changes: 15 additions & 15 deletions auto-category-for-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ function auto_category_save_post( int $post_id, WP_Post $post, bool $update ): v
* @return array
*/
function auto_category_add_term_action( array $actions, WP_Term $tag ): array {
// bail if it is not the category taxonomy.
// bail if it is not the category taxonomy.
if ( 'category' !== $tag->taxonomy ) {
return $actions;
}

// get taxonomy as object.
$tax = get_taxonomy('category');
if (current_user_can($tax->cap->manage_terms)) {
$text = __('Set as default', 'auto-category-for-posts');
$value = '';
if (absint(get_option(AUTOCATEGORY_OPTIONNAME)) === $tag->term_id) {
$text = __('Default category', 'auto-category-for-posts');
$value = ' class="default_category"';
}
$actions['auto_category'] = '<a href="#"' . $value . ' data-termid="' . $tag->term_id . '" data-nonce="' . wp_create_nonce('auto_category_change_state') . '">' . esc_html( $text ) . '</a>';
}
return $actions;
}

// get taxonomy as object.
$tax = get_taxonomy( 'category' );
if ( current_user_can( $tax->cap->manage_terms ) ) {
$text = __( 'Set as default', 'auto-category-for-posts' );
$value = '';
if ( absint( get_option( AUTOCATEGORY_OPTIONNAME ) ) === $tag->term_id ) {
$text = __( 'Default category', 'auto-category-for-posts' );
$value = ' class="default_category"';
}
$actions['auto_category'] = '<a href="#"' . $value . ' data-termid="' . $tag->term_id . '" data-nonce="' . wp_create_nonce( 'auto_category_change_state' ) . '">' . esc_html( $text ) . '</a>';
}
return $actions;
}
add_filter( 'tag_row_actions', 'auto_category_add_term_action', 10, 2 );
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ OR use ant in build/-directory: `ant json-translations`

### Run

`vendor/bin/phpcs --standard=WordPress file`
`vendor/bin/phpcs --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .`

### Repair

`vendor/bin/phpcbf --standard=WordPress file`
`vendor/bin/phpcbf --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .`
20 changes: 20 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="AutoCategoryForPosts" namespace="AutoCategoryForPosts\AutoCategoryForPosts" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">

<description>Auto Category For Posts Coding Standards</description>

<rule ref="WordPress-Docs"/>
<rule ref="WordPress-Extra"/>
<rule ref="WordPress">
<!-- Excluded in favour to match PSR-4-namings of classes. -->
<exclude name="WordPress.Files.FileName"/>
<!-- Exclude slow query -->
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query"/>
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_key"/>
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_tax_query"/>
<!-- Exclude override of globals -->
<exclude name="WordPress.WP.GlobalVariablesOverride"/>
<!-- Exclude direkt db query warnings -->
<exclude name="WordPress.DB.DirectDatabaseQuery"/>
</rule>
</ruleset>

0 comments on commit 7e5548d

Please sign in to comment.