Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action('wp_ajax_some_ajax_generate_preview', 'some_ajax_generate_preview');
- function some_ajax_generate_preview() {
- $shortcode = $_REQUEST['shortcode'];
- $clean_shortcode = some_ajax_clean_shortcode($_REQUEST['shortcode']);
- $type = $_REQUEST['type'];
- $post_types = get_option('some_ajax_types');
- $response = function ($status, $message) {
- return json_encode(['status' => $status,
- 'message' => $message]);
- }
- if(!current_user_can('administrator')) {
- echo $response(false, _('Some message!', 'text-domain'));
- die();
- }
- if(!in_array($type, $post_types)) {
- echo $response(false, _('Some message!', 'text-domain'));
- die();
- }
- if(!shortcode_exists($clean_shortcode)) {
- echo $response(false, _('Some message!', 'text-domain'));
- die();
- }
- echo $response(true, _('Some message!', 'text-domain'));
- die();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement