HEX
Server: LiteSpeed
System: Linux cde2.duelhost.dk 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: dtptviut (1121)
PHP: 8.0.30
Disabled: exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/dtptviut/public_html/wp-content/plugins/comparisonfeed-wp/compare-feed-wp-scripts.php
<?php /**
 * Proper way to enqueue scripts and styles
 */
function compare_scripts() {
  // Only register scripts and styles so we can load them on-demand later.
  wp_register_style( 'compare-feed', plugins_url( '/css/compare-feed.min.css' , __FILE__ ) , array() , CURRENT_VERSION );
  if (locate_template( 'compare-list-modified.css' )) {
    wp_register_style( 'compare-list-modified', get_template_directory_uri() . '/compare-list-modified.css' );
  }

  if (!wp_script_is('jquery')) {
    // do nothing
  } else {
    // insert jQuery
    wp_deregister_script('jquery');
    wp_register_script('jquery', plugins_url( '/js/jquery.js' , __FILE__ ), false, '1.12.4', false);
  }
  wp_register_script(
    'jsrender',
    plugins_url( '/js/jsrender.js' , __FILE__ ),
    array( 'jquery' ),
    CURRENT_VERSION,
    false
  );
  wp_register_script(
    'star-rating',
    plugins_url( '/js/star-rating.min.js' , __FILE__ ),
    array( 'jquery' ),
    CURRENT_VERSION,
    false
  );
  wp_register_script(
    'jquery-spinner',
    plugins_url( '/js/jquery.spinner.min.js' , __FILE__ ),
    array( 'jquery' ),
    CURRENT_VERSION,
    false
  );
  wp_register_script(
    'bootstrap-slider',
    plugins_url( '/js/bootstrap-slider.js' , __FILE__ ),
    array( 'jquery' ),
    CURRENT_VERSION,
    false
  );
  wp_register_script(
    'bootstrap-tooltips',
    plugins_url( '/js/dist/bootstrap-tooltips.min.js' , __FILE__ ),
    array( 'jquery' ),
    CURRENT_VERSION,
    false
  );
  // Use local jquery.compareFeed.js when on localhost to ease development.
  if (strpos($_SERVER['HTTP_HOST'], 'localhost') !== false) {
    wp_register_script(
      'compare-feed',
      plugins_url( '/js/dist/jquery.compareFeed.min.js', __FILE__ ),
      array( 'jquery' ),
      CURRENT_VERSION,
      false
    );
  } else {
    wp_register_script(
      'compare-feed',
      '//feedcontentcloud.com/v2/public/publisher/comparisonfeed/jquery',
      array( 'jquery' ),
      CURRENT_VERSION,
      false
    );
  }
  wp_register_script(
    'iframe-resizer',
    '//feedcontentcloud.com/comparisonfeed/resources/js/iframeResizer.min.js',
    false,
    CURRENT_VERSION,
    true
  );

  $post = get_post();
  $shortcode = (!empty($post)) ? has_shortcode($post->post_content, 'adservice-comparison-feed') : false;
  $builder = isset($_GET['fl_builder']); // Parameter used by Beaver Builder for their page editor.

  // If our shortcode is in the post and Beaver Builder is in use
  // then load our scripts right away.
  if ($shortcode && $builder) {
      wp_enqueue_style( 'compare-feed' );
      if (locate_template( 'compare-list-modified.css' )) {
          wp_enqueue_style( 'compare-list-modified' );
      }
      wp_enqueue_script( 'jquery' );
      wp_enqueue_script( 'jsrender' );
      wp_enqueue_script( 'star-rating' );
      wp_enqueue_script( 'jquery-spinner' );
      wp_enqueue_script( 'bootstrap-slider' );
      wp_enqueue_script( 'bootstrap-tooltips' );
      wp_enqueue_script( 'compare-feed' );
  }
}
add_action( 'wp_enqueue_scripts', 'compare_scripts' );

function compare_admin_scripts($hook) {
  wp_register_style( 'compare-admin', plugins_url('/css/compare-admin.min.css', __FILE__ ),  array(), CURRENT_VERSION );
  wp_enqueue_style( 'compare-admin' );

  if ( 'post.php' == $hook || 'page.php' == $hook || 'post-new.php' == $hook ) {
    wp_enqueue_style( 'fontawesome-min', plugins_url('/css/font-awesome.min.css', __FILE__) );
    wp_enqueue_script('jquery-ui-sortable');
    wp_enqueue_script('jquery-ui-slider');

    wp_enqueue_script(
      'jsrender',
      plugins_url( '/js/jsrender.js' , __FILE__ ),
      array( 'jquery' ),
      CURRENT_VERSION
    );
    // Use local jquery.compareFeed.js when on localhost to ease development.
    if (strpos($_SERVER['HTTP_HOST'], 'localhost') !== false) {
      wp_enqueue_script(
        'compare-feed',
        plugins_url( '/js/dist/jquery.compareFeed.min.js', __FILE__ ),
        array( 'jquery' ),
        CURRENT_VERSION
      );
    } else {
      wp_enqueue_script(
        'compare-feed',
        '//feedcontentcloud.com/v2/public/publisher/comparisonfeed/jquery',
        array( 'jquery' ),
        CURRENT_VERSION
      );
    }
    wp_enqueue_script(
      'star-rating',
      plugins_url( '/js/star-rating.min.js' , __FILE__ ),
      array( 'jquery' ),
      CURRENT_VERSION
    );

    wp_enqueue_script( 
      'compare-admin-js',
      plugins_url('/js/dist/compare-admin.min.js', __FILE__ ),
      array('jquery'),
      CURRENT_VERSION,
      true
    );
  }
}
add_action( 'admin_enqueue_scripts', 'compare_admin_scripts' );
?>