Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/71 input names #112

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/push-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Deploy to WordPress.org
on:
push:
branches:
- trunk
tags-ignore:
- 'v*-alpha*'
- 'v*-beta*'
- 'v*-rc*'
- '-alpha*'
- '-beta*'
- '-rc*'
jobs:
tag:
name: New tag
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Add build zip to GitHub releases.
# Version: 1.0.0
# Version: 1.1.0

name: Release

Expand Down Expand Up @@ -49,20 +49,24 @@ jobs:
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: "Sets up Composer Caching."
uses: "actions/cache@v2"
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-composer-build-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-composer-build-

- name: "Logs debug information."
run: |
php --version
composer --version

- name: "Install Composer dependencies with development dependencies."
run: |
composer install --no-interaction --prefer-dist --no-scripts

- name: "Setup NodeJS."
uses: actions/setup-node@v2
with:
Expand All @@ -72,30 +76,36 @@ jobs:
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"

- name: "Sets up NPM Caching."
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-npm-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-npm-build-

- name: "Install NPM dependencies."
run: npm install

- name: "Get release version."
run: |
echo "release_tag=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
echo "release_name=$(node -p -e "require('./package.json').name")" >> $GITHUB_ENV

- name: "Logs debug information."
run: |
node --version
npm --version
echo ${{ env.release_tag }}

- name: "Build release."
run: |
npm run release

- name: "Add package to GitHub releases."
uses: softprops/action-gh-release@v1
with:
files: ./deploy/${{ env.release_tag }}/radio-buttons-for-taxonomies.zip
files: ./deploy/${{ env.release_name }}-${{ env.release_tag }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module.exports = function(grunt) {
all: ['js/*.js', '!js/*.min.js']
},

// # Build and release

// Remove the build directory files
clean: {
main: ['build/**']
Expand Down Expand Up @@ -81,6 +83,22 @@ module.exports = function(grunt) {
}
},

// Make a zipfile.
compress: {
main: {
options: {
mode: 'zip',
archive: 'deploy/<%= pkg.name %>-<%= pkg.version %>.zip'
},
expand: true,
cwd: 'build/',
src: ['**/*'],
dest: '/<%= pkg.name %>'
}
},

// # Docs

// Generate git readme from readme.txt
wp_readme_to_markdown: {
convert: {
Expand Down Expand Up @@ -147,6 +165,15 @@ module.exports = function(grunt) {

});

grunt.registerTask(
'zip',
[
'clean',
'copy',
'compress'
]
);

// makepot and addtextdomain tasks
grunt.loadNpmTasks('grunt-wp-i18n');

Expand All @@ -159,4 +186,6 @@ module.exports = function(grunt) {

grunt.registerTask('build', ['replace', 'newer:uglify', 'makepot', 'wp_readme_to_markdown']);

grunt.registerTask( 'release', [ 'build', 'zip', 'clean' ] );

};
10 changes: 8 additions & 2 deletions inc/class-walker-category-radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ public function start_el( &$output, $category, $depth = 0, $args = array(), $id
$this->printed_nonce = true;
}

/* RB4T mod: Replace default $name variable */
$name = 'radio_tax_input['.$taxonomy.']';
/* RB4T mod: Replace default $name variable - Core naming conventions. */
if ( 'category' === $taxonomy ) {
$name = 'post_category';
} elseif ( 'post_tag' === $taxonomy ) {
$name = 'post_tag';
} else {
$name = 'tax_input[' . $taxonomy . ']';
}
/* end */

$args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
Expand Down
25 changes: 17 additions & 8 deletions inc/class-wordpress-radio-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,10 @@ public function add_non_hierarchical_term() {
$cat_id = $cat_id['term_id'];
}

$data = sprintf( '<li id="%1$s-%2$s"><label class="selectit"><input id="in-%1$s-%2$s" type="radio" name="radio_tax_input[%1$s][]" value="%2$s" checked="checked"> %3$s</label></li>',
$data = sprintf( '<li id="%1$s-%2$s"><label class="selectit"><input id="in-%1$s-%2$s" type="radio" name="%3$s[]" value="%2$s" checked="checked"> %4$s</label></li>',
esc_attr( $taxonomy->name ),
intval( $cat_id ),
esc_attr( $taxonomy->name === 'post_tag' ? 'post_tag' : 'tax_input[ ' . $taxonomy->name . ']' ),
esc_html( $cat_name )
);

Expand Down Expand Up @@ -451,19 +452,27 @@ function save_single_term( $post_id ) {
return $post_id;
}

// If posts are being bulk edited, and no term is selected, do nothing.
if ( ! empty( $_GET[ 'bulk_edit' ] ) && empty ( $_REQUEST[ 'radio_tax_input' ][ "{$this->taxonomy}" ] ) ) {
return $post_id;
}

// Verify nonce.
if ( ! isset( $_REQUEST["_radio_nonce-{$this->taxonomy}"]) || ! wp_verify_nonce( $_REQUEST["_radio_nonce-{$this->taxonomy}"], "radio_nonce-{$this->taxonomy}" ) ) {
return $post_id;
}

if ( $this->taxonomy === 'category' ) {
$radio_tax_key = $_REQUEST['post_category' ];
} elseif ( $this->taxonomy === 'post_tag' ) {
$radio_tax_key = $_REQUEST['post_tag' ];
} else {
$radio_tax_key = $_REQUEST['tax_input']["{$this->taxonomy}"];
}

// If posts are being bulk edited, and no term is selected, do nothing.
if ( ! empty( $_GET[ 'bulk_edit' ] ) && empty ( $radio_tax_key ) ) {
return $post_id;
}

// OK, we must be authenticated by now: we need to make sure we're only saving 1 term.
if ( ! empty ( $_REQUEST["radio_tax_input"]["{$this->taxonomy}"] ) ) {
$terms = (array) $_REQUEST["radio_tax_input"]["{$this->taxonomy}"];
if ( ! empty ( $radio_tax_key ) ) {
$terms = (array) $radio_tax_key;
$single_term = intval( array_shift( $terms ) );
} else {
// If not saving any terms, set to default.
Expand Down
2 changes: 1 addition & 1 deletion js/dist/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '102c5bd05c574e9ce598');
<?php return array('dependencies' => array('lodash', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '459d2ed30f98546246ae');
Loading