Are there any security risks when submitting data-attribute data through AJAX?

When dealing with submit forms, even if they are sent with AJAX, you must play by the Never trust user’s input rule. Every data-attribute can be changed, edited via Inspector. Your only trusted validation should be on the server side, as you did with: if ( isset($_POST[‘author_id’]) || is_numeric($_POST[‘author_id’]) ) Personally, I would inverse the … Read more

Print Dashboard submenu name and filename

If you want them in an unordered list: echo “<ul>\r\n”; foreach ( $submenu as $group => $item ) { foreach ( $submenu[$group] as $key => $value ) { echo “<li>” . $submenu[$group][$key][0] . ” > ” . $submenu[$group][$key][2] . “</li>\r\n”; } } echo “</ul>”; This results in: <ul> <li>Home > index.php</li> <li>Updates > update-core.php</li> <li>Library … Read more

Remove all removed pages from wordpress

You must use wp_delete_post() with second parameter set to true. The post will be completely deleted, not trashed. // Use $args to get the pages you created previously // See https://developer.wordpress.org/reference/functions/get_pages/ $pages = get_pages( $args ); if( $pages ) { foreach( $pages as $page ) { wp_delete_post( $page->ID, true ); } } After that, you … Read more

Displaying “One Time” Notification in Plugins

The idea is that you need to save_errors or update the option that has the errors/notices whenever you want. As soon as its output once by admin_notices it will be cleared. /** * Sample_Notice_Handling */ class Sample_Notice_Handling { public static $_notices = array(); /** * Constructor */ public function __construct() { add_action( ‘admin_notices’, array( $this, … Read more

Cannot change caption for a plugin

You just changed the default value for $top_text. Modifying a plugin directly like that is not a good idea, because the changes will be lost when updating. There’s quite a bit more code in that plugin, and going through it, I see that there is an options page where that value is set. It seems … Read more