<?php
    // prevent direct file access
	if( !defined( 'ABSPATH' ) ) exit;
    
    add_filter('admin_enqueue_scripts', 'pixe_seo_content_filter');
    function pixe_seo_content_filter($hook){
        if( $hook == 'post.php' ){
            if( class_exists('RankMath') ){
                $builder_content =  pixe_get_post_content(get_the_ID());

                wp_enqueue_script('pixe-rankmath-support', PIXE_URL . '/admin/js/rankmath-support.js', array('wp-hooks', 'rank-math-analyzer'), PIXE_VERSION, true);
                wp_localize_script('pixe-rankmath-support', 'pixeSeo', array(
                    'content' => $builder_content
                ));
            }else if( defined('WPSEO_VERSION') ){
                $builder_content =  pixe_get_post_content(get_the_ID());

                wp_enqueue_script('pixe-yoast-support', PIXE_URL . '/admin/js/yoast-support.js', array('jquery', 'wp-hooks'), PIXE_VERSION, true);
                wp_localize_script('pixe-yoast-support', 'pixeSeo', array(
                    'content' => $builder_content
                ));
            }
        }
    }
