daily pastebin goal
59%
SHARE
TWEET

Untitled

SasheVuchkov Jan 24th, 2019 (edited) 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. add_action('wp_ajax_some_ajax_generate_preview', 'some_ajax_generate_preview');
  4. function some_ajax_generate_preview() {
  5.  
  6. $shortcode = $_REQUEST['shortcode'];
  7. $clean_shortcode = some_ajax_clean_shortcode($_REQUEST['shortcode']);
  8. $type = $_REQUEST['type'];
  9. $post_types = get_option('some_ajax_types');
  10.  
  11.  
  12. $error = null;
  13.  
  14. if(!current_user_can('administrator')) $error = _('Some message!', 'text-domain');
  15. if(!$error && !in_array($type, $post_types)) $error = _('Some message!', 'text-domain');
  16. if(!$error && !shortcode_exists($clean_shortcode)) $error = _('Some message!', 'text-domain');
  17.  
  18. $message = $error ??  _('Some message!', 'text-domain');
  19.  
  20. echo json_encode(['status' => (bool) $error,
  21.                   'message' => $message]);  
  22.    
  23.  
  24. die();
  25.  
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top