Escape when echoed

In fact to be super pedantic, I think the correct code is actually: echo ‘<option value=”‘ . esc_attr( $folder ) . ‘”>’ . esc_html( $folder ) . ‘</option>’; Since the first variable is an attribute, and the second is encased in html, although I wold bet that the code you have would pass review, and … Read more

Adding Plugin-specific Fields with wp_insert_post()?

@sorich87’s answer is 99% there. The difference is that All-in-One SEO Pack follows certain best practices and uses a prefix of ‘_aioseop_’ on its meta keys. That makes the actual working code look more like this: $my_post = array( ‘post_title’ => ‘title’, ‘post_content’ => $post, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_date’ => date(‘Y-m-d H:i:s’, … Read more

Getting Post details when post is published

The function is wp_insert_post(), and as you can see there are some hooks you can use to modify data. wp_insert_post_data is a filter that gets all data right before it will be inserted into the database, so you modify it there and don’t need to do anything to get it saved. At the end of … Read more