There is a website on wordpress and a video player plugin built on the basis of the Magnific Popup library when displayed on the page as a shortcode [sp_html5video] - everything works fine shortcode code:
<?php function sp_html5video_shortcode( $atts, $content = null ) { .. // Popup Configuration $popup_conf = compact('popup_fix'); ?> <div class="wp-html5vp-video-row video-row video-row-clearfix" id="wp-html5vp-<?php echo $unique; ?>"> ... <div class="wp-html5vp-popup-conf"><?php echo json_encode( $popup_conf ); ?></div><!-- end of-popup-conf --> </div> } jQuery(document).ready(function($) { $( '.wp-html5vp-video-row' ).each(function( index ) { var popup_id = $(this).attr('id'); var popup_conf = $.parseJSON( $(this).find('.wp-html5vp-popup-conf').text()); if( typeof(popup_id) != 'undefined' ) { jQuery('#'+popup_id+ ' .popup-youtube').magnificPopup({ type: 'iframe', mainClass: 'mfp-fade wp-html5vp-mfp-zoom-in wp-html5vp-popup-main-wrp', removalDelay: 160, preloader: false, fixedContentPos: popup_conf.popup_fix == 'true' ? true : 0, }); jQuery('#'+popup_id+ ' .popup-modal').magnificPopup({ mainClass: 'mfp-fade wp-html5vp-popup-main-wrp', removalDelay: 160, preloader: false, fixedContentPos: popup_conf.popup_fix == 'true' ? true : 0, }); } }); }); I need on a separate page to bring out the functionality of the shortcode with which I want to perform additional actions. To do this, I transfer the contents of the shortcode function to a php file, but the modal window does not work. It writes an error:
Uncaught SyntaxError: Unexpected token A in JSON at position 0
For such a conclusion
console.log($(this).find('.wp-html5vp-popup-conf').text()); instead of (as it should be by analogy with the shortcode) {"popup_fix": "false"} writes Array What is my mistake and how to fix it?