INN / umbrella-sfpublicpress

San Francisco Public Press
https://sfpublicpress.org/
GNU General Public License v2.0
1 stars 4 forks source link

JS thing to click the checkboxes, and related tag merge/conversion task functionality #95

Closed benlk closed 4 years ago

benlk commented 4 years ago

With the following variable preparation:

tags=``;
tags=`the pasted
list of tags
copied
as cells from the column`;

, the following code will check the boxes for those tags on this page:

console.log(tags.split('\n').length);
var count = 0;
tags.split('\n').forEach(function(tag) {
    for (const a of document.querySelectorAll("a.row-title")) {
        if ( 0 === a.textContent.localeCompare(tag)) {
        console.log([a.textContent, tag])
            a.closest('tr').querySelector('.check-column input[type=checkbox]').checked = true;
            count++;
       }
    }
});
console.log( 'tags needing merge on this page: ' + count );

This will result in log output if there are tags on this page that need to be merged.

Given that removing tags from the front of the stack messes with pagination of tags later in the stack, if you have multiple pages of tags even when the list of tags is set to show 999 tags, you should click to the last page and run this script there, then on the second-to-last, then on the third-to-last, and so on.

Full preparatory snippet

tags=``;
console.log(tags.split('\n').length);
var count = 0;
tags.split('\n').forEach(function(tag) {
    for (const a of document.querySelectorAll("a.row-title")) {
        if ( 0 === a.textContent.localeCompare(tag)) {
        console.log([a.textContent, tag])
            a.closest('tr').querySelector('.check-column input[type=checkbox]').checked = true;
            count++;
       }
    }
});
console.log( 'tags needing merge on this page: ' + count );

Process

  1. Copy the code from under the "Full Preparatory Snippet" above into a text editor.
  2. From the "SFPP Post Tags 3/24/20" sheet, from the "Ben's sorted version" tab:
    1. Scroll down to find a category under the "NEW CATEGORY (LL)" column that doesn't have a "done" entry in the "Completed" column.
    2. Copy all the tags in that column, and paste between the `` in the snippet in your text editor, making sure that each tag is on its own line.
    3. Note down the new category that you'll be setting things to.
    4. Change the entry in the "Completed" column for these terms to "In Progress"
  3. Open /wp-admin/edit-tags.php?taxonomy=post_tag
    1. Go to the last page of the tag listing.
  4. Open your browser dev tools
    1. Switch to the Console
    2. Paste the whole snippet in
    3. Hit "enter" to run the snippet
    4. You should see output like: "tags needing merge on this page: 3". If the only number given is 0, you do not need to merge any tags on this page.
    5. If the number is greater than 0, scroll to the bottom or top, from the "Bulk Actions" menu choose "Merge", and in the new text box add the name of the new category.
    6. Apply.
  5. Repeat step 3 for each of the pages of tag results, working your way from the last page of tags to the first. This order is important.
  6. When all the tags in this batch are merged into the new term, return to the spreadsheet and set the "Completed" column entry to "done" for these tags.
  7. When all the tags for the new category are merged:
    1. find the merged tag in the tag list (easiest to search)
    2. check the box for it
    3. from "Bulk Actions" select "Change taxonomy", and then choose "Categories". Click "apply".
    4. Go to the Categories list at /wp-admin/edit-tags.php?taxonomy=category and find the category by searching. There may be a duplicate category that needs to be merged with this one. If so, merge them.
benlk commented 4 years ago

Snippet has been updated to: