Sync your WordPress posts to standard.site records on your PDS
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

native js

+259 -214
+50 -42
assets/js/meta-box.js
··· 1 - (function ($) { 1 + (function () { 2 2 "use strict"; 3 3 4 4 function toggleCustomField(selectId, fieldId) { 5 - var $select = $("#" + selectId); 6 - var $field = $("#" + fieldId); 5 + var select = document.getElementById(selectId); 6 + var field = document.getElementById(fieldId); 7 7 8 8 function update() { 9 - if ($select.val() === "custom") { 10 - $field.show(); 9 + if (select.value === "custom") { 10 + field.style.display = ""; 11 11 } else { 12 - $field.hide(); 12 + field.style.display = "none"; 13 13 } 14 14 } 15 15 16 - $select.on("change", update); 16 + select.addEventListener("change", update); 17 17 update(); 18 18 } 19 19 20 - $(document).ready(function () { 20 + document.addEventListener("DOMContentLoaded", function () { 21 21 toggleCustomField( 22 22 "wireservice_title_source", 23 23 "wireservice-custom-title-field" ··· 33 33 34 34 var frame; 35 35 36 - $("#wireservice-select-image").on("click", function (e) { 37 - e.preventDefault(); 36 + document 37 + .getElementById("wireservice-select-image") 38 + .addEventListener("click", function (e) { 39 + e.preventDefault(); 38 40 39 - if (frame) { 40 - frame.open(); 41 - return; 42 - } 41 + if (frame) { 42 + frame.open(); 43 + return; 44 + } 43 45 44 - frame = wp.media({ 45 - title: wireserviceMetaBox.selectImageTitle, 46 - button: { text: wireserviceMetaBox.useImageButton }, 47 - multiple: false, 48 - library: { type: "image" }, 49 - }); 46 + frame = wp.media({ 47 + title: wireserviceMetaBox.selectImageTitle, 48 + button: { text: wireserviceMetaBox.useImageButton }, 49 + multiple: false, 50 + library: { type: "image" }, 51 + }); 50 52 51 - frame.on("select", function () { 52 - var attachment = frame.state().get("selection").first().toJSON(); 53 - $("#wireservice_custom_image_id").val(attachment.id); 54 - var thumbUrl = 55 - attachment.sizes && attachment.sizes.thumbnail 56 - ? attachment.sizes.thumbnail.url 57 - : attachment.url; 58 - $("#wireservice-custom-image-preview").html( 59 - '<img src="' + 53 + frame.on("select", function () { 54 + var attachment = frame.state().get("selection").first().toJSON(); 55 + document.getElementById("wireservice_custom_image_id").value = 56 + attachment.id; 57 + var thumbUrl = 58 + attachment.sizes && attachment.sizes.thumbnail 59 + ? attachment.sizes.thumbnail.url 60 + : attachment.url; 61 + document.getElementById( 62 + "wireservice-custom-image-preview" 63 + ).innerHTML = 64 + '<img src="' + 60 65 thumbUrl + 61 - '" style="max-width:150px;height:auto;display:block;margin-bottom:8px;" />' 62 - ); 63 - $("#wireservice-remove-image").show(); 64 - }); 66 + '" style="max-width:150px;height:auto;display:block;margin-bottom:8px;" />'; 67 + document.getElementById("wireservice-remove-image").style.display = 68 + ""; 69 + }); 65 70 66 - frame.open(); 67 - }); 71 + frame.open(); 72 + }); 68 73 69 - $("#wireservice-remove-image").on("click", function (e) { 70 - e.preventDefault(); 71 - $("#wireservice_custom_image_id").val(""); 72 - $("#wireservice-custom-image-preview").html(""); 73 - $(this).hide(); 74 - }); 74 + document 75 + .getElementById("wireservice-remove-image") 76 + .addEventListener("click", function (e) { 77 + e.preventDefault(); 78 + document.getElementById("wireservice_custom_image_id").value = ""; 79 + document.getElementById("wireservice-custom-image-preview").innerHTML = 80 + ""; 81 + this.style.display = "none"; 82 + }); 75 83 }); 76 - })(jQuery); 84 + })();
+94 -78
assets/js/records.js
··· 1 - (function ($) { 1 + (function () { 2 2 "use strict"; 3 + 4 + function escapeHtml(str) { 5 + var div = document.createElement("div"); 6 + div.textContent = str || ""; 7 + return div.innerHTML; 8 + } 3 9 4 10 function formatDate(isoString) { 5 11 if (!isoString) return "\u2014"; ··· 13 19 }); 14 20 } 15 21 16 - function esc(str) { 17 - return $("<span>").text(str || "").html(); 18 - } 19 - 20 22 function fieldRow(label, value) { 21 - return "<tr><th>" + esc(label) + "</th><td>" + value + "</td></tr>"; 23 + return "<tr><th>" + escapeHtml(label) + "</th><td>" + value + "</td></tr>"; 22 24 } 23 25 24 26 function renderPublication(record) { 25 27 var val = record.value; 26 28 var html = '<table class="widefat wireservice-record-table">'; 27 29 html += "<tbody>"; 28 - html += fieldRow("AT-URI", "<code>" + esc(record.uri) + "</code>"); 29 - html += fieldRow("CID", "<code>" + esc(record.cid) + "</code>"); 30 - html += fieldRow("Name", esc(val.name)); 30 + html += fieldRow("AT-URI", "<code>" + escapeHtml(record.uri) + "</code>"); 31 + html += fieldRow("CID", "<code>" + escapeHtml(record.cid) + "</code>"); 32 + html += fieldRow("Name", escapeHtml(val.name)); 31 33 html += fieldRow( 32 34 "URL", 33 35 '<a href="' + 34 - esc(val.url) + 36 + escapeHtml(val.url) + 35 37 '" target="_blank">' + 36 - esc(val.url) + 38 + escapeHtml(val.url) + 37 39 "</a>" 38 40 ); 39 41 40 42 if (val.description) { 41 - html += fieldRow("Description", esc(val.description)); 43 + html += fieldRow("Description", escapeHtml(val.description)); 42 44 } 43 45 44 46 if (val.icon) { 45 47 html += fieldRow( 46 48 "Icon", 47 49 "<code>blob</code> (" + 48 - esc(val.icon.mimeType || "unknown type") + 50 + escapeHtml(val.icon.mimeType || "unknown type") + 49 51 ")" 50 52 ); 51 53 } ··· 83 85 var val = record.value; 84 86 var html = '<div class="wireservice-document-card">'; 85 87 html += '<div class="wireservice-document-card-header">'; 86 - html += "<h3>" + esc(val.title) + "</h3>"; 88 + html += "<h3>" + escapeHtml(val.title) + "</h3>"; 87 89 html += "</div>"; 88 90 html += '<div class="wireservice-document-card-body">'; 89 91 html += '<table class="widefat wireservice-record-table">'; 90 92 html += "<tbody>"; 91 - html += fieldRow("AT-URI", "<code>" + esc(record.uri) + "</code>"); 93 + html += fieldRow("AT-URI", "<code>" + escapeHtml(record.uri) + "</code>"); 92 94 93 95 if (val.path) { 94 - html += fieldRow("Path", esc(val.path)); 96 + html += fieldRow("Path", escapeHtml(val.path)); 95 97 } 96 98 97 99 html += fieldRow("Published", formatDate(val.publishedAt)); ··· 105 107 val.description.length > 200 106 108 ? val.description.substring(0, 200) + "..." 107 109 : val.description; 108 - html += fieldRow("Description", esc(desc)); 110 + html += fieldRow("Description", escapeHtml(desc)); 109 111 } 110 112 111 113 if (val.tags && val.tags.length > 0) { 112 114 var tags = val.tags 113 115 .map(function (t) { 114 - return esc(t); 116 + return escapeHtml(t); 115 117 }) 116 118 .join(", "); 117 119 html += fieldRow("Tags", tags); ··· 121 123 html += fieldRow( 122 124 "Cover Image", 123 125 "<code>blob</code> (" + 124 - esc(val.coverImage.mimeType || "unknown type") + 126 + escapeHtml(val.coverImage.mimeType || "unknown type") + 125 127 ")" 126 128 ); 127 129 } ··· 129 131 if (val.textContent) { 130 132 html += fieldRow( 131 133 "Text Content", 132 - esc(val.textContent.substring(0, 100)) + 134 + escapeHtml(val.textContent.substring(0, 100)) + 133 135 (val.textContent.length > 100 ? "..." : "") 134 136 ); 135 137 } ··· 139 141 return html; 140 142 } 141 143 144 + function ajaxPost(url, data) { 145 + var formData = new FormData(); 146 + for (var key in data) { 147 + formData.append(key, data[key]); 148 + } 149 + return fetch(url, { method: "POST", body: formData }).then(function (res) { 150 + return res.json(); 151 + }); 152 + } 153 + 142 154 function loadPublication() { 143 - var $loading = $("#wireservice-publication-loading"); 144 - var $error = $("#wireservice-publication-error"); 145 - var $data = $("#wireservice-publication-data"); 155 + var loading = document.getElementById("wireservice-publication-loading"); 156 + var error = document.getElementById("wireservice-publication-error"); 157 + var data = document.getElementById("wireservice-publication-data"); 146 158 147 - $.post(wireserviceRecords.ajaxUrl, { 159 + ajaxPost(wireserviceRecords.ajaxUrl, { 148 160 action: "wireservice_get_publication_record", 149 161 nonce: wireserviceRecords.nonce, 150 162 }) 151 - .done(function (response) { 152 - $loading.hide(); 163 + .then(function (response) { 164 + loading.style.display = "none"; 153 165 if (!response.success) { 154 - $error 155 - .html( 156 - "<p class='wireservice-error'>" + esc(response.data) + "</p>" 157 - ) 158 - .show(); 166 + error.innerHTML = 167 + "<p class='wireservice-error'>" + 168 + escapeHtml(response.data) + 169 + "</p>"; 170 + error.style.display = ""; 159 171 return; 160 172 } 161 - $data.html(renderPublication(response.data)).show(); 173 + data.innerHTML = renderPublication(response.data); 174 + data.style.display = ""; 162 175 }) 163 - .fail(function () { 164 - $loading.hide(); 165 - $error 166 - .html( 167 - "<p class='wireservice-error'>Failed to fetch publication record.</p>" 168 - ) 169 - .show(); 176 + .catch(function () { 177 + loading.style.display = "none"; 178 + error.innerHTML = 179 + "<p class='wireservice-error'>Failed to fetch publication record.</p>"; 180 + error.style.display = ""; 170 181 }); 171 182 } 172 183 ··· 174 185 var totalLoaded = 0; 175 186 176 187 function loadDocuments(cursor) { 177 - var $loading = $("#wireservice-documents-loading"); 178 - var $error = $("#wireservice-documents-error"); 179 - var $list = $("#wireservice-documents-list"); 180 - var $pagination = $("#wireservice-documents-pagination"); 181 - var $loadMore = $("#wireservice-documents-load-more"); 188 + var loading = document.getElementById("wireservice-documents-loading"); 189 + var error = document.getElementById("wireservice-documents-error"); 190 + var list = document.getElementById("wireservice-documents-list"); 191 + var pagination = document.getElementById( 192 + "wireservice-documents-pagination" 193 + ); 194 + var loadMore = document.getElementById("wireservice-documents-load-more"); 182 195 183 196 if (!cursor) { 184 - $loading.show(); 197 + loading.style.display = ""; 185 198 } 186 - $loadMore.prop("disabled", true); 199 + loadMore.disabled = true; 187 200 188 201 var postData = { 189 202 action: "wireservice_list_document_records", ··· 194 207 postData.cursor = cursor; 195 208 } 196 209 197 - $.post(wireserviceRecords.ajaxUrl, postData) 198 - .done(function (response) { 199 - $loading.hide(); 210 + ajaxPost(wireserviceRecords.ajaxUrl, postData) 211 + .then(function (response) { 212 + loading.style.display = "none"; 200 213 if (!response.success) { 201 - $error 202 - .html( 203 - "<p class='wireservice-error'>" + esc(response.data) + "</p>" 204 - ) 205 - .show(); 214 + error.innerHTML = 215 + "<p class='wireservice-error'>" + 216 + escapeHtml(response.data) + 217 + "</p>"; 218 + error.style.display = ""; 206 219 return; 207 220 } 208 221 ··· 211 224 totalLoaded += records.length; 212 225 213 226 if (records.length === 0 && totalLoaded === 0) { 214 - $list.html("<p>No document records found on this PDS.</p>").show(); 227 + list.innerHTML = "<p>No document records found on this PDS.</p>"; 228 + list.style.display = ""; 215 229 return; 216 230 } 217 231 ··· 220 234 html += renderDocumentCard(records[i]); 221 235 } 222 236 223 - $list.append(html).show(); 237 + list.insertAdjacentHTML("beforeend", html); 238 + list.style.display = ""; 224 239 225 - var $count = $("#wireservice-documents-count"); 226 - if ($count.length === 0) { 227 - $list.before( 240 + var count = document.getElementById("wireservice-documents-count"); 241 + if (!count) { 242 + list.insertAdjacentHTML( 243 + "beforebegin", 228 244 '<p id="wireservice-documents-count">' + 229 245 totalLoaded + 230 246 " records loaded</p>" 231 247 ); 232 248 } else { 233 - $count.text(totalLoaded + " records loaded"); 249 + count.textContent = totalLoaded + " records loaded"; 234 250 } 235 251 236 252 if (documentCursor) { 237 - $pagination.show(); 238 - $loadMore.prop("disabled", false); 253 + pagination.style.display = ""; 254 + loadMore.disabled = false; 239 255 } else { 240 - $pagination.hide(); 256 + pagination.style.display = "none"; 241 257 } 242 258 }) 243 - .fail(function () { 244 - $loading.hide(); 245 - $error 246 - .html( 247 - "<p class='wireservice-error'>Failed to fetch document records.</p>" 248 - ) 249 - .show(); 259 + .catch(function () { 260 + loading.style.display = "none"; 261 + error.innerHTML = 262 + "<p class='wireservice-error'>Failed to fetch document records.</p>"; 263 + error.style.display = ""; 250 264 }); 251 265 } 252 266 253 - $(document).ready(function () { 254 - if ($("#wireservice-records-publication").length === 0) { 267 + document.addEventListener("DOMContentLoaded", function () { 268 + if (!document.getElementById("wireservice-records-publication")) { 255 269 return; 256 270 } 257 271 258 272 loadPublication(); 259 273 loadDocuments(null); 260 274 261 - $("#wireservice-documents-load-more").on("click", function () { 262 - if (documentCursor) { 263 - loadDocuments(documentCursor); 264 - } 265 - }); 275 + document 276 + .getElementById("wireservice-documents-load-more") 277 + .addEventListener("click", function () { 278 + if (documentCursor) { 279 + loadDocuments(documentCursor); 280 + } 281 + }); 266 282 }); 267 - })(jQuery); 283 + })();
+112 -91
assets/js/settings.js
··· 1 - (function ($) { 1 + (function () { 2 2 "use strict"; 3 3 4 + function escapeHtml(str) { 5 + var div = document.createElement("div"); 6 + div.textContent = str || ""; 7 + return div.innerHTML; 8 + } 9 + 4 10 function toggleCustomField(selectId, fieldId, currentValueId) { 5 - var $select = $("#" + selectId); 6 - var $field = $("#" + fieldId); 7 - var $currentValue = $("#" + currentValueId); 8 - var $previewText = $currentValue.find(".wireservice-preview-text"); 11 + var select = document.getElementById(selectId); 12 + var field = document.getElementById(fieldId); 13 + var currentValue = document.getElementById(currentValueId); 14 + var previewText = currentValue 15 + ? currentValue.querySelector(".wireservice-preview-text") 16 + : null; 9 17 10 18 function update() { 11 - var selected = $select.find("option:selected"); 12 - var preview = selected.attr("data-value") || ""; 19 + var selected = select.options[select.selectedIndex]; 20 + var preview = selected.getAttribute("data-value") || ""; 13 21 14 - if ($select.val() === "custom") { 15 - $field.show(); 16 - $currentValue.hide(); 22 + if (select.value === "custom") { 23 + field.style.display = ""; 24 + if (currentValue) currentValue.style.display = "none"; 17 25 } else { 18 - $field.hide(); 19 - $currentValue.show(); 20 - if ($previewText.length) { 26 + field.style.display = "none"; 27 + if (currentValue) currentValue.style.display = ""; 28 + if (previewText) { 21 29 var truncated = 22 30 preview.length > 100 23 31 ? preview.substring(0, 100) + "..." 24 32 : preview; 25 - $previewText.text(truncated || "—"); 33 + previewText.textContent = truncated || "\u2014"; 26 34 } 27 35 } 28 36 } 29 37 30 - $select.on("change", update); 38 + select.addEventListener("change", update); 31 39 update(); 32 40 } 33 41 34 42 function initIconField() { 35 - var $select = $("#wireservice_pub_icon_source"); 36 - var $customField = $("#wireservice-pub-custom-icon-field"); 37 - var $preview = $("#wireservice-pub-icon-preview"); 38 - var $uploadBtn = $("#wireservice-pub-icon-upload"); 39 - var $removeBtn = $("#wireservice-pub-icon-remove"); 40 - var $hiddenInput = $("#wireservice_pub_custom_icon_id"); 41 - var $customPreview = $("#wireservice-pub-custom-icon-preview"); 43 + var select = document.getElementById("wireservice_pub_icon_source"); 44 + var customField = document.getElementById( 45 + "wireservice-pub-custom-icon-field" 46 + ); 47 + var preview = document.getElementById("wireservice-pub-icon-preview"); 48 + var uploadBtn = document.getElementById("wireservice-pub-icon-upload"); 49 + var removeBtn = document.getElementById("wireservice-pub-icon-remove"); 50 + var hiddenInput = document.getElementById("wireservice_pub_custom_icon_id"); 51 + var customPreview = document.getElementById( 52 + "wireservice-pub-custom-icon-preview" 53 + ); 42 54 var frame; 43 55 44 56 function updateVisibility() { 45 - var val = $select.val(); 57 + var val = select.value; 46 58 if (val === "custom") { 47 - $customField.show(); 48 - $preview.hide(); 59 + customField.style.display = ""; 60 + preview.style.display = "none"; 49 61 } else if (val === "none") { 50 - $customField.hide(); 51 - $preview.hide(); 62 + customField.style.display = "none"; 63 + preview.style.display = "none"; 52 64 } else { 53 - $customField.hide(); 54 - $preview.show(); 65 + customField.style.display = "none"; 66 + preview.style.display = ""; 55 67 } 56 68 } 57 69 58 - $select.on("change", updateVisibility); 70 + select.addEventListener("change", updateVisibility); 59 71 updateVisibility(); 60 72 61 - $uploadBtn.on("click", function (e) { 73 + uploadBtn.addEventListener("click", function (e) { 62 74 e.preventDefault(); 63 75 64 76 if (frame) { ··· 75 87 76 88 frame.on("select", function () { 77 89 var attachment = frame.state().get("selection").first().toJSON(); 78 - $hiddenInput.val(attachment.id); 90 + hiddenInput.value = attachment.id; 79 91 var thumbUrl = 80 92 attachment.sizes && attachment.sizes.thumbnail 81 93 ? attachment.sizes.thumbnail.url 82 94 : attachment.url; 83 - $customPreview.html( 95 + customPreview.innerHTML = 84 96 '<img src="' + 85 - thumbUrl + 86 - '" alt="" style="width: 64px; height: 64px; object-fit: cover; border-radius: 4px;">' 87 - ); 88 - $removeBtn.show(); 97 + thumbUrl + 98 + '" alt="" style="width: 64px; height: 64px; object-fit: cover; border-radius: 4px;">'; 99 + removeBtn.style.display = ""; 89 100 }); 90 101 91 102 frame.open(); 92 103 }); 93 104 94 - $removeBtn.on("click", function (e) { 105 + removeBtn.addEventListener("click", function (e) { 95 106 e.preventDefault(); 96 - $hiddenInput.val(""); 97 - $customPreview.html(""); 98 - $removeBtn.hide(); 107 + hiddenInput.value = ""; 108 + customPreview.innerHTML = ""; 109 + removeBtn.style.display = "none"; 110 + }); 111 + } 112 + 113 + function ajaxPost(url, data) { 114 + var formData = new FormData(); 115 + for (var key in data) { 116 + if (Array.isArray(data[key])) { 117 + for (var i = 0; i < data[key].length; i++) { 118 + formData.append(key + "[]", data[key][i]); 119 + } 120 + } else { 121 + formData.append(key, data[key]); 122 + } 123 + } 124 + return fetch(url, { method: "POST", body: formData }).then(function (res) { 125 + return res.json(); 99 126 }); 100 127 } 101 128 102 129 function initBackfill() { 103 - var $button = $("#wireservice-backfill-start"); 104 - var $progress = $("#wireservice-backfill-progress"); 105 - var $fill = $progress.find(".wireservice-progress-bar-fill"); 106 - var $status = $("#wireservice-backfill-status"); 107 - var $results = $("#wireservice-backfill-results"); 130 + var button = document.getElementById("wireservice-backfill-start"); 131 + var progress = document.getElementById("wireservice-backfill-progress"); 132 + var fill = progress 133 + ? progress.querySelector(".wireservice-progress-bar-fill") 134 + : null; 135 + var status = document.getElementById("wireservice-backfill-status"); 136 + var results = document.getElementById("wireservice-backfill-results"); 108 137 var batchSize = 5; 109 138 110 - if (!$button.length) { 139 + if (!button) { 111 140 return; 112 141 } 113 142 114 - $button.on("click", function () { 115 - $button.prop("disabled", true); 116 - $progress.show(); 117 - $results.hide().empty(); 118 - $fill.css("width", "0%"); 119 - $status.text("Counting posts..."); 143 + button.addEventListener("click", function () { 144 + button.disabled = true; 145 + progress.style.display = ""; 146 + results.style.display = "none"; 147 + results.innerHTML = ""; 148 + fill.style.width = "0%"; 149 + status.textContent = "Counting posts..."; 120 150 121 - $.post(wireserviceBackfill.ajaxUrl, { 151 + ajaxPost(wireserviceBackfill.ajaxUrl, { 122 152 action: "wireservice_backfill_count", 123 153 nonce: wireserviceBackfill.nonce, 124 154 }) 125 - .done(function (response) { 155 + .then(function (response) { 126 156 if (!response.success) { 127 - $status.text("Failed to count posts."); 128 - $button.prop("disabled", false); 157 + status.textContent = "Failed to count posts."; 158 + button.disabled = false; 129 159 return; 130 160 } 131 161 ··· 133 163 var total = postIds.length; 134 164 135 165 if (total === 0) { 136 - $status.text("All posts are already synced."); 137 - $progress.hide(); 138 - $button.prop("disabled", false); 166 + status.textContent = "All posts are already synced."; 167 + progress.style.display = "none"; 168 + button.disabled = false; 139 169 return; 140 170 } 141 171 ··· 143 173 var succeeded = 0; 144 174 var errors = []; 145 175 146 - // Chunk post IDs into batches. 147 176 var batches = []; 148 177 for (var i = 0; i < postIds.length; i += batchSize) { 149 178 batches.push(postIds.slice(i, i + batchSize)); ··· 151 180 152 181 function processBatch(index) { 153 182 if (index >= batches.length) { 154 - // Done. 155 - var pct = "100%"; 156 - $fill.css("width", pct); 183 + fill.style.width = "100%"; 157 184 158 185 var summary = succeeded + " of " + total + " posts synced."; 159 - $status.text(summary); 186 + status.textContent = summary; 160 187 161 188 if (errors.length > 0) { 162 189 var html = ··· 166 193 for (var e = 0; e < errors.length; e++) { 167 194 html += 168 195 "<li><strong>" + 169 - $("<span>").text(errors[e].title).html() + 196 + escapeHtml(errors[e].title) + 170 197 "</strong>: " + 171 - $("<span>").text(errors[e].error).html() + 198 + escapeHtml(errors[e].error) + 172 199 "</li>"; 173 200 } 174 201 html += "</ul></details>"; 175 - $results.html(html).show(); 202 + results.innerHTML = html; 203 + results.style.display = ""; 176 204 } 177 205 178 - $button.prop("disabled", false); 206 + button.disabled = false; 179 207 return; 180 208 } 181 209 182 - $status.text( 183 - "Syncing posts... (" + processed + " of " + total + ")" 184 - ); 210 + status.textContent = 211 + "Syncing posts... (" + processed + " of " + total + ")"; 185 212 186 - $.post(wireserviceBackfill.ajaxUrl, { 213 + ajaxPost(wireserviceBackfill.ajaxUrl, { 187 214 action: "wireservice_backfill_batch", 188 215 nonce: wireserviceBackfill.nonce, 189 216 post_ids: batches[index], 190 217 }) 191 - .done(function (response) { 218 + .then(function (response) { 192 219 if (response.success && response.data.results) { 193 220 for (var r = 0; r < response.data.results.length; r++) { 194 221 var result = response.data.results[r]; ··· 200 227 } 201 228 } 202 229 } else { 203 - // Count the entire batch as failed. 204 230 processed += batches[index].length; 205 231 for (var f = 0; f < batches[index].length; f++) { 206 232 errors.push({ ··· 210 236 } 211 237 } 212 238 213 - var pct = Math.round((processed / total) * 100) + "%"; 214 - $fill.css("width", pct); 215 - 239 + fill.style.width = 240 + Math.round((processed / total) * 100) + "%"; 216 241 processBatch(index + 1); 217 242 }) 218 - .fail(function () { 243 + .catch(function () { 219 244 processed += batches[index].length; 220 245 for (var f = 0; f < batches[index].length; f++) { 221 246 errors.push({ ··· 224 249 }); 225 250 } 226 251 227 - var pct = Math.round((processed / total) * 100) + "%"; 228 - $fill.css("width", pct); 229 - 252 + fill.style.width = 253 + Math.round((processed / total) * 100) + "%"; 230 254 processBatch(index + 1); 231 255 }); 232 256 } 233 257 234 258 processBatch(0); 235 259 }) 236 - .fail(function () { 237 - $status.text("Failed to start backfill."); 238 - $button.prop("disabled", false); 260 + .catch(function () { 261 + status.textContent = "Failed to start backfill."; 262 + button.disabled = false; 239 263 }); 240 264 }); 241 265 } 242 266 243 - $(document).ready(function () { 267 + document.addEventListener("DOMContentLoaded", function () { 244 268 toggleCustomField( 245 269 "wireservice_pub_name_source", 246 270 "wireservice-pub-custom-name-field", ··· 252 276 "wireservice-pub-desc-current-value" 253 277 ); 254 278 255 - // Initialize icon source toggle and media picker. 256 279 initIconField(); 257 280 258 - // Initialize color pickers. 259 - $(".wireservice-color-picker").wpColorPicker(); 281 + jQuery(".wireservice-color-picker").wpColorPicker(); 260 282 261 - // Initialize backfill. 262 283 initBackfill(); 263 284 }); 264 - })(jQuery); 285 + })();
+2 -2
includes/Admin.php
··· 82 82 wp_enqueue_script( 83 83 "wireservice-settings", 84 84 WIRESERVICE_PLUGIN_URL . "assets/js/settings.js", 85 - ["jquery", "wp-color-picker"], 85 + ["wp-color-picker"], 86 86 WIRESERVICE_VERSION, 87 87 true, 88 88 ); ··· 98 98 wp_enqueue_script( 99 99 "wireservice-records", 100 100 WIRESERVICE_PLUGIN_URL . "assets/js/records.js", 101 - ["jquery"], 101 + [], 102 102 WIRESERVICE_VERSION, 103 103 true, 104 104 );
+1 -1
includes/Setup.php
··· 281 281 wp_enqueue_script( 282 282 "wireservice-meta-box", 283 283 WIRESERVICE_PLUGIN_URL . "assets/js/meta-box.js", 284 - ["jquery"], 284 + [], 285 285 WIRESERVICE_VERSION, 286 286 true, 287 287 );