• I am trying to move this site to a new server. This page works just fine on the old server. On the new one, my theme seems to be ignoring includes in my theme files.

    Here is the old server page that works.
    https://www.davishomes.com/neighborhoods/davis-communities/

    The new one that doesn’t work.
    https://staging.davishomes.com/neighborhoods/davis-communities/

    <?
    function map_scripts() {
      wp_enqueue_script('google-maps', 'https://maps.googleapis.com/maps/api/js?key=MY_API_KEY', '', '');
      wp_enqueue_script( 'jquery_ui_map', '/wp-includes/js/jquery.ui.map/jquery.ui.map.full.min.js', array(), '1.0.0', true );  
    }
    add_action( 'wp_enqueue_scripts', 'map_scripts' );
    ?>

    The above code is one of my includes called “map_scripts.php.”

    And I am including it with:

    include("map_scripts.php");
    

    Any ideas?

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • The opening php tag is wrong <?php

    and get rid of the closing php tag it is not needed

    Thread Starter senojeel

    (@senojeel)

    Thanks! Any ideas why that would work on one server, but not another?

    I also have this one:

    <?
    function list_scripts() {
      wp_enqueue_style('font1', 'https://fonts.googleapis.com/css?family=Lato');
      wp_enqueue_style('font-awesome', 'https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css');
      wp_enqueue_style('normalize', get_stylesheet_directory_uri() . '/jplist/css/vendor/normalize.css');
      wp_enqueue_style('styles', get_stylesheet_directory_uri() . '/jplist/css/styles.min.css');
    	
      wp_enqueue_script('jquery', '/wp-includes/js/jquery/jquery.js');
      
      //mediaswitch
      wp_enqueue_style('mediacheck', get_stylesheet_directory_uri() . '/mediacheck/css/base.css');
      wp_enqueue_script('mediacheck', get_stylesheet_directory_uri() . '/mediacheck/js/mediaCheck-min.js');
      
      //jquery ui
      wp_enqueue_style('jquery-ui', get_stylesheet_directory_uri() . '/jplist/css/vendor/jquery-ui.min.css');
      wp_enqueue_script('jquery-ui', get_stylesheet_directory_uri() . '/jplist/js/vendor/jquery-ui.min.js');
      wp_enqueue_script('jquery-ui-touch-punch', get_stylesheet_directory_uri() . '/touchpunch/js/jquery.ui.touch-punch.min.js');
    
      //jplist core
      wp_enqueue_style('jplist', get_stylesheet_directory_uri() . '/jplist/css/jplist-core.min.css');
      wp_enqueue_script('jplist-core', get_stylesheet_directory_uri() . '/jplist/js/jplist-core.min.js');
      
      
      //jplist views
      wp_enqueue_style('jplist-views-control', get_stylesheet_directory_uri() . '/jplist/css/jplist-views-control.min.css');
      wp_enqueue_script('jplist-views-control', get_stylesheet_directory_uri() . '/jplist/js/jplist.views-control.min.js');
      
      //jplist pagination
      wp_enqueue_style('jplist-pagination-bundle', get_stylesheet_directory_uri() . '/jplist/css/jplist-pagination-bundle.min.css');
      wp_enqueue_script('jplist-pagination-bundle', get_stylesheet_directory_uri() . '/jplist/js/jplist.pagination-bundle.min.js');
      
      //jplist history
      wp_enqueue_style('jplist-history-bundle', get_stylesheet_directory_uri() . '/jplist/css/jplist-history-bundle.min.css');
      wp_enqueue_script('jplist-history-bundle', get_stylesheet_directory_uri() . '/jplist/js/jplist.history-bundle.min.js');
      
      //jplist toggle
      wp_enqueue_style('jplist-filter-toggle-bundle', get_stylesheet_directory_uri() . '/jplist/css/jplist-filter-toggle-bundle.min.css');
      wp_enqueue_script('jplist-filter-toggle-bundle', get_stylesheet_directory_uri() . '/jplist/js/jplist.filter-toggle-bundle.min.js');
      
      //jplist jqueryui
      wp_enqueue_style('jplist-jquery-ui-bundle', get_stylesheet_directory_uri() . '/jplist/css/jplist-jquery-ui-bundle.min.css');
      wp_enqueue_script('jplist-jquery-ui-bundle', get_stylesheet_directory_uri() . '/jplist/js/jplist.jquery-ui-bundle.min.js');
      
      //jplist dropdown
      wp_enqueue_script('jplist.filter-dropdown-bundle', get_stylesheet_directory_uri() . '/jplist/js/jplist.filter-dropdown-bundle.min.js');
      
      wp_enqueue_style('smart_table', get_stylesheet_directory_uri() . '/css/smart_table.css');
      wp_enqueue_script('smart_table', get_stylesheet_directory_uri() . '/js/smart_table.js');
    }
    add_action( 'wp_enqueue_scripts', 'list_scripts' );
    ?>'

    I am changing the opening tag and removing the closing tag. But I am getting a different error.

    • This reply was modified 6 years, 11 months ago by senojeel.

    as @jaycbrf pointed out, it is customary to not include a closing tag ?> but every PHP page should open with <?php. It worked on your old server because php was probably configured to accept “short tags”.

    https://php.net/manual/en/language.basic-syntax.phptags.php

    Thread Starter senojeel

    (@senojeel)

    Ahh, that makes sense.

    Any idea as to why I am getting the error “Uncaught Error: Syntax error, unrecognized expression: .” on my code above?

    hmmm, not 100% sure but that reference to the wp-includes folder is suspect. You can load jQuery simply with wp_enqueue_script('jquery');.

    Thread Starter senojeel

    (@senojeel)

    I changed the jquery call, but it didn’t change the results. From everything I have read so far, the dot (.) is correctly used.

      wp_enqueue_style('normalize', get_stylesheet_directory_uri() . '/jplist/css/vendor/normalize.css');
    

    yes, the dot is correctly used. I just was pointing out that it is not standard practice to make calls to wp-includes. jQuery is already registered by default.

    Have you enabled debugging?

    you can enable debugging by adding define( 'WP_DEBUG', true ); to your wp-config file. It would help to know exactly where the error occurs such as a line number.

    I didn’t even notice that – jQuery and jQuery UI are included with WP core. Enqueueing them again will cause JS errors.

    wp-includes>js>jquery
    and
    wp-includes>js>jquery>ui

    You are loading a plethora of duplicate scripts – take a look in the includes folder to see what WP already has…

    Thread Starter senojeel

    (@senojeel)

    I will do that jaycbrf. I inherited this site, so I am discovering things as I go through it. PHP shortcodes was the issue I was having. I will eventually changed them, but for now, I enabled them on the server.

    Thanks for everyone’s help!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Enqueue Scripts being ignored’ is closed to new replies.