publish;
},
AWBSEO_Instant_Indexing::indexable_types()
)
);
// Handle auto-submit toggle save - always save when form is submitted so
// unchecking the checkbox (which sends no POST key) turns the feature OFF.
if ( isset( $_POST['awbseo_ii_save'] ) && check_admin_referer( 'awbseo_ii_settings' ) ) {
$auto_val = isset( $_POST['awbseo_ii_auto'] ) ? '1' : '0';
update_option( AWBSEO_Instant_Indexing::OPT_AUTO, $auto_val );
$auto = '1' === $auto_val;
echo '
__( 'Published Pages', 'adworksbid-seo' ), 'value' => number_format_i18n( $pub_count ), 'color' => $accent ],
[ 'label' => __( 'Submissions Logged', 'adworksbid-seo' ), 'value' => number_format_i18n( $total_log ), 'color' => '#5c5056' ],
[ 'label' => __( 'Successful', 'adworksbid-seo' ), 'value' => number_format_i18n( $success_log ), 'color' => $green ],
[ 'label' => __( 'Failed', 'adworksbid-seo' ), 'value' => number_format_i18n( $failed_log ), 'color' => $red ],
];
foreach ( $stats as $s ) : ?>
Why does the log show zero? CitedSEO logs a submission each time you publish or update a post or page (when auto-submit is turned on). Pages that already existed before you enabled this are not submitted automatically.', 'adworksbid-seo' ),
[ 'strong' => [] ]
);
?>
%d existing page, use the Bulk Submission section below.',
'To notify search engines about your %d existing pages , use the Bulk Submission section below.',
$pub_count,
'adworksbid-seo'
),
[ 'strong' => [] ]
),
number_format_i18n( $pub_count )
);
?>
%s published page across all public post types.',
'You have %s published pages across all public post types.',
$pub_count,
'adworksbid-seo'
),
[ 'strong' => [] ]
),
number_format_i18n( $pub_count )
);
?>
$entry ) :
$bg = $i % 2 === 0 ? '#fff' : '#faf6f4';
$is_ok = $entry['status'] === 'submitted';
$clr = $is_ok ? $green : $red;
$icon = $is_ok ? '✓' : '✗';
if ( $is_ok ) {
$label = __( 'Submitted', 'adworksbid-seo' );
} elseif ( $entry['status'] === 'error' ) {
$label = __( 'Error', 'adworksbid-seo' );
} else {
$label = __( 'Failed', 'adworksbid-seo' );
}
?>
' . esc_html__( 'Log cleared.', 'adworksbid-seo' ) . '' );
$awb_ii_page_js = 'var _awbiiNonce=' . $awb_ii_page_nonce . ';';
$awb_ii_page_js .= 'var _ajaxurl=' . $awb_ii_ajax_url . ';';
$awb_ii_page_js .= 'var _awbiiPubCount=' . $awb_ii_pub_count . ';';
$awb_ii_page_js .= 'var _awbiiLogClearedHtml=' . $awb_ii_no_log_msg . ';';
$awb_ii_page_js .= 'var _awbiiStr=' . wp_json_encode( [
'checking' => __( 'Checking…', 'adworksbid-seo' ),
'verified' => __( '✓ Verified - key file is accessible.', 'adworksbid-seo' ),
'key_mismatch' => __( '✗ Key mismatch - unexpected content.', 'adworksbid-seo' ),
/* translators: %s = HTTP status code (e.g. 404) */
'not_accessible' => __( '✗ Not accessible (HTTP %s). Try flushing permalinks.', 'adworksbid-seo' ),
'regen_confirm' => __( 'Regenerate the IndexNow key? The old key will stop working and the log will be cleared.', 'adworksbid-seo' ),
'regenerating' => __( 'Regenerating…', 'adworksbid-seo' ),
'regen_btn' => __( '↺ Regenerate Key', 'adworksbid-seo' ),
'key_regenerated' => __( 'Key regenerated - please verify.', 'adworksbid-seo' ),
'error_prefix' => __( 'Error:', 'adworksbid-seo' ),
/* translators: %d = number of published pages */
'submit_all_confirm' => __( 'Submit all %d published pages to IndexNow?', 'adworksbid-seo' ),
'submitting' => __( 'Submitting…', 'adworksbid-seo' ),
'submit_all_btn' => __( '⚡ Submit All Pages', 'adworksbid-seo' ),
/* translators: %d = number of URLs submitted */
'submitted_ok' => __( '✓ %d URLs submitted successfully.', 'adworksbid-seo' ),
/* translators: %d = number of batches that failed */
'batches_failed' => __( '(%d batches failed)', 'adworksbid-seo' ),
'submit_failed' => __( '✗ Submission failed.', 'adworksbid-seo' ),
'enter_url' => __( 'Please enter at least one URL.', 'adworksbid-seo' ),
'submit_urls_btn' => __( '⚡ Submit URLs', 'adworksbid-seo' ),
/* translators: %d = number of submitted URLs */
'urls_submitted_singular' => __( '✓ %d URL submitted.', 'adworksbid-seo' ),
'urls_submitted_plural' => __( '✓ %d URLs submitted.', 'adworksbid-seo' ),
'failed' => __( '✗ Failed.', 'adworksbid-seo' ),
'network_error' => __( '✗ Network error.', 'adworksbid-seo' ),
'clear_confirm' => __( 'Clear the entire submission log?', 'adworksbid-seo' ),
] ) . ';';
$awb_ii_page_js .= <<<'AWBIIVIEWJS'
function awbiiPost(action,data,cb){data.action=action;data.nonce=_awbiiNonce;fetch(_ajaxurl,{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:new URLSearchParams(data).toString()}).then(function(r){return r.json();}).then(cb).catch(function(){cb({success:false,data:_awbiiStr.network_error});});}
function awbiiVerifyKey(){var el=document.getElementById('ii-key-status');el.textContent=_awbiiStr.checking;el.style.color='#7c706c';fetch(document.getElementById('ii-key-file').href+'?nocache='+Date.now()).then(function(r){return r.ok?r.text():Promise.reject(r.status);}).then(function(t){var key=document.getElementById('ii-key-val').textContent.trim();if(t.trim()===key){el.textContent=_awbiiStr.verified;el.style.color='#04785b';}else{el.textContent=_awbiiStr.key_mismatch;el.style.color='#aa3535';}}).catch(function(s){el.textContent=_awbiiStr.not_accessible.replace('%s',s);el.style.color='#aa3535';});}
function awbiiRegenKey(btn){if(!confirm(_awbiiStr.regen_confirm))return;btn.disabled=true;btn.textContent=_awbiiStr.regenerating;awbiiPost('awbseo_indexnow_generate_key',{},function(res){btn.disabled=false;btn.textContent=_awbiiStr.regen_btn;if(res.success){document.getElementById('ii-key-val').textContent=res.data.key;document.getElementById('ii-key-file').textContent=res.data.file_url;document.getElementById('ii-key-file').href=res.data.file_url;document.getElementById('ii-key-status').textContent=_awbiiStr.key_regenerated;document.getElementById('ii-key-status').style.color='#7c706c';setTimeout(function(){location.reload();},1500);}else{alert(_awbiiStr.error_prefix+' '+(res.data||'unknown'));}});}
function awbiiSubmitAll(btn){if(!confirm(_awbiiStr.submit_all_confirm.replace('%d',_awbiiPubCount)))return;var msg=document.getElementById('ii-submit-all-msg');btn.disabled=true;btn.textContent=_awbiiStr.submitting;msg.textContent='';msg.style.color='#7c706c';awbiiPost('awbseo_indexnow_submit_all',{},function(res){btn.disabled=false;btn.textContent=_awbiiStr.submit_all_btn;if(res.success){msg.style.color='#04785b';msg.textContent=_awbiiStr.submitted_ok.replace('%d',res.data.submitted);if(res.data.errors&&res.data.errors.length){msg.style.color='#8a5a00';msg.textContent+=' '+_awbiiStr.batches_failed.replace('%d',res.data.errors.length);}}else{msg.style.color='#aa3535';msg.textContent=res.data||_awbiiStr.submit_failed;}});}
function awbiiSubmitCustom(btn){var ta=document.getElementById('ii-custom-urls');var msg=document.getElementById('ii-custom-msg');var lines=ta.value.split('\n').map(function(l){return l.trim();}).filter(Boolean);if(!lines.length){alert(_awbiiStr.enter_url);return;}btn.disabled=true;btn.textContent=_awbiiStr.submitting;msg.textContent='';var body='action=awbseo_indexnow_submit&nonce='+encodeURIComponent(_awbiiNonce);lines.forEach(function(u){body+='&urls[]='+encodeURIComponent(u);});fetch(_ajaxurl,{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json();}).then(function(res){btn.disabled=false;btn.textContent=_awbiiStr.submit_urls_btn;if(res.success){msg.style.color='#04785b';var tpl=res.data.submitted!==1?_awbiiStr.urls_submitted_plural:_awbiiStr.urls_submitted_singular;msg.textContent=tpl.replace('%d',res.data.submitted);ta.value='';}else{msg.style.color='#aa3535';msg.textContent=res.data||_awbiiStr.failed;}}).catch(function(){btn.disabled=false;btn.textContent=_awbiiStr.submit_urls_btn;msg.style.color='#aa3535';msg.textContent=_awbiiStr.network_error;});}
function awbiiClearLog(btn){if(!confirm(_awbiiStr.clear_confirm))return;btn.disabled=true;awbiiPost('awbseo_indexnow_clear_log',{},function(res){btn.disabled=false;if(res.success){var tbl=document.getElementById('ii-log-table');if(tbl)tbl.parentNode.innerHTML=_awbiiLogClearedHtml;btn.style.display='none';}});}
AWBIIVIEWJS;
wp_add_inline_script( 'awbseo-admin', $awb_ii_page_js );
?>