0

I wrote a plugin which adds additional functionality to Advanced Custom fields and the tinyMCE editor. All in all simple stuff with a bunch of js and css primarily.

Issue is that WP not only looks for the file in:

'/wp-content/plugins/acf-columns/assets/js/input.js?ver=1.0.0'

where it's actually located, but also:

'/wp-content/themes/generatepress/resources/acf-field-column/js/input.js'

Not only does it not look for the js file in the 'assets' folder, but it also looks for it in 'acf-field-column' folder, not 'acf-field-columns' (notice the 's' in columns). I'm using a child theme of GeneratePress.

I'm only enqueuing the files in the plugin master file, and only once

Heres my enqueue

// Add styles and js init
function acf_admin_enqueue() {
global $post;

if($post->post_type != 'acf-field-group'):

    // enqueue jquery UI script
    wp_enqueue_script( 'jquery-ui', plugin_dir_url(__FILE__) . 'assets/js/jquery-ui.min.js', array('jquery'), '1.0.0', true );

    // enqueue plugin jQuery
    wp_enqueue_script( 'pagebuilder-js', plugin_dir_url(__FILE__) . 'assets/js/input.js', array('jquery'), '1.0.0', true );


    // enqueue stylesheet
    wp_enqueue_style( 'pagebuilder-styles', plugin_dir_url(__FILE__) . 'assets/css/input.css', array(), '1.0.0', false);
endif;
}

// hook in styles and js
add_action('acf/input/admin_head', 'acf_admin_enqueue');

I have no folder called 'resources' in my child theme, thats only in the generatepress parent theme. Any ideas on what is going on here?

  • not sure if it is related by your handler names are very generic (jquery-ui especially very aweful) I would guess you have a collision of handler names that cause confusion – Mark Kaplun Jun 2 '17 at 9:28
  • Just found the issue in one of the plugin files. It was just me not looking thoroughly enough. But thanks for the input. I should definitely change that handle. Thanks! – Emil Østervig Jun 2 '17 at 11:02
0

I'm a total dummy. Looked through the field file and found this:

function input_admin_enqueue_scripts()
{
    // Note: This function can be removed if not used


    // register acf scripts
    wp_register_script('acf-input-column', $this->settings['dir'] . 'js/input.js', array('acf-input'), $this->settings['version']);
    wp_register_style('acf-input-column', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version']);


    // scripts
    wp_enqueue_script(array(
        'acf-input-column',
    ));

    // styles
    wp_enqueue_style(array(
        'acf-input-column',
    ));

}

$settings->['dir'] was set to: get_template_directory_uri() . '/resources/acf-field-column/'

So that's where the 404 files got included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.