Custom Field Template
[resolved] [SOLUTION] Conflict work-around for Ajax Event Calendar & Custom Field Template (2 posts)

  1. korythewebguy
    Posted 4 years ago #

    Recently I ran into a plugin conflict between "Custom Field Template" v2.02 and "Ajax Event Calendar" v1.02

    It seems that when the two are loaded together, Custom Field Template hijacks the date.js methods and causes Ajax Event Calendar to hang at the "Loading Event Form..." screen, making users unable to edit or remove existing events. Many users will see a "Object [object Window] has no method 'getFullYear' in date.js on line 129" error in their JavaScript consoles.

    Many threads have pointed to simply removing the date.js file from the /wp-content/plugins/custom-field-template folder - This resolves the conflict with Ajax Event Calendar, but leaves Custom Field Template unable to use the date-picker on any fields.

    The following alternative solution involves moving one line of code, and lets both plugins function without issue:

    PLEASE NOTE... the following solution will be overwritten when you upgrade "Custom Field Template" (unless CFT's author fixes the next release) so PLEASE REMEMBER to re-apply the solution after doing so.

    1. Connect to your site via FTP, SFTP, or any method by which you can edit .PHP files OR Login to the WordPress back-end, click 'Editor' beneath 'Plugins'
    2. If using FTP/SFTP/etc, navigate to your /wp-content/plugins/custom-field-template/ folder and open the custom-field-template.php file OR Using the WordPress plugin editor, select "Custom Field Template" as the plugin, then choose to edit the custom-field-template.php file.
    3. Find the following piece of code (around line 737): wp_enqueue_script( 'date', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/date.js', array('jquery') );
    4. Highlight & copy that one line of code, then delete it. (Or just cut it to your clipboard.)
    5. Now locate the line of code (about 4 lines below; line 741) which reads if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || (is_object($post) && $post->post_type=='page') ) : - Directly below this line, paste-in the line of code you copied/cut in Step 4.
    6. Save the custom-field-template.php file.
    7. Voila! You're done - Custom Field Template and Ajax Event Calendar will now work side-by-side without any problems.

    Just to clarify, when you're finished lines 735 through 744 of custom-field-template.php should look like this:

    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'jquery-form' );
    wp_enqueue_script( 'bgiframe', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.bgiframe.js', array('jquery') ) ;
    wp_enqueue_script( 'datePicker', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.datePicker.js', array('jquery') );
    wp_enqueue_script( 'textarearesizer', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.textarearesizer.js', array('jquery') );
    if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || (is_object($post) && $post->post_type=='page') ) :
    	wp_enqueue_script( 'date', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/date.js', array('jquery') );

    I am posting this solution here because (I'm reasonably sure) the conflict is unfortunately caused by Custom Field Template, not by Ajax Events Calendar - No less, I absolutely love both of these plug-ins and highly appreciate their respective authors! Hopefully Hiroaki Miyashita will considering fixing this in the next release.


  2. korythewebguy
    Posted 4 years ago #

    I thought I'd update this post and note that as of "Custom Field Template" version 2.04, the conflict with "Ajax Event Calendar" appears to have been resolved.

    As such, the code-hack described above is no longer necessary - My sincere thanks to Hiroaki Miyashita for this truly fantastic plugin, and for working to resolve the issue!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Field Template
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic