Guest User

Untitled

a guest
Apr 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. class WPQR {
  4. /**
  5. * Enqueue Public Scripts
  6. * @return void
  7. */
  8. public function enqueue() {
  9. if ( is_singular( array( 'post', 'page' ) ) ) {
  10. global $post;
  11. // If current page/post has our shortcode wpqr, proceed.
  12. if ( has_shortcode( $post->post_content, 'wpqr' ) ) {
  13. require 'inc/react-wp/react-wp-scripts.php';
  14.  
  15. \WPQR\enqueue_assets( plugin_dir_path( __FILE__ ) .'inc/react-wp', array(
  16. 'handle' => 'wpqr',
  17. // Production URL.
  18. 'base_url' => plugin_dir_url( __FILE__ ) . 'inc/react-wp/',
  19. ) );
  20.  
  21. wp_localize_script( 'wpqr', 'wpqr', array(
  22. 'nonce' => wp_create_nonce( 'wp_rest' ),
  23. 'rest_url' => get_rest_url(),
  24. ) );
  25. }
  26. }
  27. }
  28. }
Add Comment
Please, Sign In to add comment