Hello @paydelete
Thank you for the support topic, As I tested your plugin for AMP compatibility I did find some issues, the issues occur on non-AMP pages too.
1) Notice:
Notice: is_singular was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in wp-includes/functions.php on line 5663
It can be fixed by removing a line of code from deadelte.php also it’s not needed.
apply_filters('the_content', 'deaddelete_deleteButton');
2) Warning:
Warning: DOMDocument::loadHTML(): Tag figure invalid in Entity, line: 14 in wp-content/plugins/deaddelete/deaddelete.php on line 93
it’s worth adding a isset()
or ! empty()
check
you can also customize success and error messages by adding additional tags conditionally using amp_is_request function
eg:
$tagarray = array( 'form' => array('name' => array(),'method' => array(),'id' => array()), 'input' => array('type' => array(),'name' => array(),'value' => array()));
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
$tagarray['div'] = array(
'submit-success' => array(),
'submit-error' => array(),
);
$tagarray['template'] = array(
'type' => array(),
);
$buttonHtml = wp_kses('<form name="post" method="post" id="post"><input type="submit" name="removepost" value="Remove Dead Link" /><div submit-success><template type="amp-mustache">Links Removed successfully, Pleaase refresh!</template></div><div submit-error><template type="amp-mustache">Links Removal failed!</template></div></form>',$tagarray);
} else {
$buttonHtml = wp_kses('<form name="post" method="post" id="post"><input type="submit" name="removepost" value="Remove Dead Link" /></form>',$tagarray);
}
I am not sure how the plugin should work/function but it will be good practice to restrict non-admin users from deleting posts or it can be exploited to remove other posts.
eg: adding something like is recommended.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}