Plugin automatic-ai-posts (v2.0.0) - Pipeline completo: coleta de feeds RSS/Atom, filtro por IA, reescrita, categoria, imagem de capa e agendamento - Página de configuração com teste real do provedor de IA - Editor: botão para refazer imagem de capa e metadados, textos em PT-BR - Ajuda com botão Pix (copia-e-cola + QR) e sem nota de avaliação - Cache-busting por mtime nos assets do admin Tema gustavoo-portfolio - Marca do cabeçalho reduzida a "Gustavo" - Suporte a título próprio da marca Setup (docker/wp-init.sh, compose.yaml) - Plugins de terceiros (Post Views Counter, Rank Math, Site Kit) instalados do WordPress.org em vez de versionados - Falha explícita ao final se algum plugin obrigatório não instalar - WPCLI_UID/WPCLI_GID configuráveis Seeder do tema - Links permanentes "Dia e nome" e avatar "Iniciais" aplicados apenas em instalação nova, com regravação do .htaccess
58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
/**
|
|
* Post edit screen: "Search a new image" button.
|
|
*
|
|
* The AI query plus the image download can take a few seconds, so the button
|
|
* reports progress and updates the cover preview when it finishes.
|
|
*/
|
|
(function ($) {
|
|
'use strict';
|
|
|
|
$(document).on('click', '#aap-refresh-image-btn', function (e) {
|
|
e.preventDefault();
|
|
|
|
var $btn = $(this);
|
|
var $feedback = $('#aap-refresh-image-feedback');
|
|
var i18n = (window.aapEditor && aapEditor.i18n) || {};
|
|
|
|
if ($btn.data('busy')) return;
|
|
$btn.data('busy', true).prop('disabled', true);
|
|
|
|
$feedback.removeClass('is-error is-success').addClass('is-working').text(i18n.working || '...');
|
|
|
|
$.post(aapEditor.ajaxurl, {
|
|
action: 'aap_refresh_image',
|
|
nonce: $btn.data('nonce'),
|
|
post_id: $btn.data('post')
|
|
})
|
|
.done(function (res) {
|
|
if (res && res.success && res.data && res.data.updated) {
|
|
$feedback.removeClass('is-working').addClass('is-success').text(i18n.success || 'OK');
|
|
applyThumbnail(res.data);
|
|
} else if (res && res.success) {
|
|
$feedback.removeClass('is-working').addClass('is-error').text(i18n.no_image || 'No image found.');
|
|
} else {
|
|
$feedback.removeClass('is-working').addClass('is-error').text(i18n.error || 'Error.');
|
|
}
|
|
})
|
|
.fail(function () {
|
|
$feedback.removeClass('is-working').addClass('is-error').text(i18n.error || 'Error.');
|
|
})
|
|
.always(function () {
|
|
$btn.data('busy', false).prop('disabled', false);
|
|
});
|
|
});
|
|
|
|
/**
|
|
* Swap the preview inside the core "Featured image" box without reloading.
|
|
*/
|
|
function applyThumbnail(data) {
|
|
if (!data.thumbnail) return;
|
|
|
|
var $img = $('#postimagediv #postimagediv-thumbnail img, #postimagediv .inside img').first();
|
|
|
|
if ($img.length) {
|
|
$img.attr('src', data.thumbnail);
|
|
}
|
|
}
|
|
}(jQuery));
|