WordPress.org

Support

[Resolved] Plugin broken

Viewing 2 replies - 1 through 2 (of 2 total)
  • In widget-data.php, I did this:

    Replace

    add_action( 'admin_enqueue_scripts', function($hook) use ($export_page, $import_page){
    			if( !in_array( $hook, array( $export_page, $import_page ) ) )
    				return;
    
    			wp_enqueue_style( 'widget_data', plugins_url( '/widget-data.css', __FILE__ ) );
    			wp_enqueue_script( 'widget_data', plugins_url( '/widget-data.js', __FILE__ ), array( 'jquery', 'wp-ajax-response' ) );
    			wp_localize_script( 'widget_data', 'widgets_url', get_admin_url( false, 'widgets.php' ) );
    		} );

    with this

    if(is_admin())
    		{
    			wp_enqueue_style( 'widget_data', plugins_url( '/widget-data.css', __FILE__ ) );
    			wp_enqueue_script( 'widget_data', plugins_url( '/widget-data.js', __FILE__ ), array( 'jquery', 'wp-ajax-response' ) );
    			wp_localize_script( 'widget_data', 'widgets_url', get_admin_url( false, 'widgets.php' ) );
    		}

    It worked for me. Not the best solution, I’m sure, but it worked.

    Plugin Author Kevin Langley

    @kevinlangleyjr

    This issue is due to the PHP version we require for the plugin, which is 5.3.0. Anything below that will error out. Usually if you ask your host to upgrade your PHP version to 5.3.0, they will do so without an issue and with ease and no interruption to your site. If they cannot or you do not want to upgrade, you can always go to the “Developers” tab on the plugin page (far right tab), and download version 1.0 that is compatible with older version of PHP.

    @drewmturner – your solution definitely works, in the plugin we only want to enqueue those stylesheets and javascript files on the specific admin page, and all you’re doing is allowing it on all pages. Like you said, its not the best, but it definitely works for sure with probably no harm done, its just not best practice for us to release the plugin enqueuing the assets on all admin pages.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Plugin broken’ is closed to new replies.
Skip to toolbar