• As the WordPress error messages says, “Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.”

    That mean these functions should not be called directly but like so:

    function enqueue_my_scripts_and_styles() {
      wp_enqueue_style('thickbox');
      wp_enqueue_script('jquery');
      wp_enqueue_script('thickbox');
      wp_register_script('postmessagejs', LACANDS_PLUGIN_URL .'jquery.ba-postmessage.min.js');
      wp_enqueue_script('postmessagejs');
      wp_register_script('lacandsjs', LACANDS_PLUGIN_URL.'la-click-and-share.js');
      wp_enqueue_script ('lacandsjs');
      wp_register_style ('lacandsnetworkpubcss', LACANDS_PLUGIN_URL.'la-click-and-share-networkpub.css');
    		wp_enqueue_style  ('lacandsnetworkpubcss');
    
       wp_enqueue_style('special-offers-style', get_template_directory_uri() . '/functions/css/special-offers.css');
    
    }
    
    add_action( 'wp_enqueue_scripts', 'enqueue_my_scripts_and_styles' );

    in la-click-and-share.php arount line 1033.

    http://wordpress.org/extend/plugins/1-click-retweetsharelike/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author vivekpuri

    (@vivekpuri)

    Thank you for the tip. We will look into it.

    Hello guys!

    As I see that the “Plugin Author” didn’t offered the solution for the problem described here i want to share my fix:

    Go to wp-content/plugins/1-click-retweetsharelike/la-click-and-share.php at the line approximately: 1022 and change the entire function lacands_main() with the following code:

    function thematic_enqueue_scripts() {
    	wp_enqueue_script('jquery');
    	wp_enqueue_script('thickbox');
    	wp_register_script('postmessagejs', LACANDS_PLUGIN_URL .'jquery.ba-postmessage.min.js');
    	wp_enqueue_script('postmessagejs');
    	wp_register_script('lacandsjs', LACANDS_PLUGIN_URL.'la-click-and-share.js');
    	wp_enqueue_script ('lacandsjs');
    }
    
    function thematic_enqueue_styles() {
    	wp_enqueue_style('thickbox');
    	wp_register_style('lacandsnetworkpubcss', LACANDS_PLUGIN_URL.'la-click-and-share-networkpub.css');
    	wp_enqueue_style('lacandsnetworkpubcss');
    }
    
    function lacands_main() {
    	lacands_init();
    	lacands_writeOptionsValuesToWPDatabase_twitter();
    	$dims = array('width' => 250, 'height' => 300);
    	$widget_ops = array('description' => LACANDS_FB_RECOMMENDATIONS_NAME);
    	register_activation_hook( __FILE__, 'lacands_activate' );
    	if ( is_admin() ) {
    		lacands_set_options();
    		lacandsnw_set_options();
    		add_action('wp_enqueue_styles', 'thematic_enqueue_styles');
    		add_action('wp_enqueue_scripts', 'thematic_enqueue_scripts');
    		add_action('admin_menu',  'lacands_wp_admin');
    		add_action('admin_menu',  'lacands_pages');
    		add_action('admin_notices', 'lacands_warning');
    		add_action('activate_{$plugin}', 'lacandsnw_pushpresscheck');
    		add_action('activated_plugin', 'lacandsnw_pushpresscheck');
    		wp_register_widget_control(LACANDS_FB_RECOMMENDATIONS_ID, LACANDS_FB_RECOMMENDATIONS_NAME, 'lacands_fb_recommendations_settings', $dims, $widget_ops);
    	}
    	add_filter ( 'the_content', 'lacands_wp_filter_post_content');
    	wp_register_sidebar_widget(LACANDS_FB_RECOMMENDATIONS_ID, LACANDS_FB_RECOMMENDATIONS_NAME, 'lacands_fb_recommendations', $widget_ops);
    	register_deactivation_hook( __FILE__, 'lacands_deactivate' );
    }

    This will fix both problems.

    P.S. Hope the Plugin Author will add this code to his plugin and I expect for his thanks :). Wish you the best!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: 1-click Retweet/Share/Like] wp_enqueue_style & wp_enqueue_script called incorrectly’ is closed to new replies.