Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class WPQR {
- /**
- * Enqueue Public Scripts
- * @return void
- */
- public function enqueue() {
- if ( is_singular( array( 'post', 'page' ) ) ) {
- global $post;
- // If current page/post has our shortcode wpqr, proceed.
- if ( has_shortcode( $post->post_content, 'wpqr' ) ) {
- require 'inc/react-wp/react-wp-scripts.php';
- \WPQR\enqueue_assets( plugin_dir_path( __FILE__ ) .'inc/react-wp', array(
- 'handle' => 'wpqr',
- // Production URL.
- 'base_url' => plugin_dir_url( __FILE__ ) . 'inc/react-wp/',
- ) );
- wp_localize_script( 'wpqr', 'wpqr', array(
- 'nonce' => wp_create_nonce( 'wp_rest' ),
- 'rest_url' => get_rest_url(),
- ) );
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment