• Resolved Hrohh

    (@hrohh)


    you have some trouble with register js + css..

    this code is fix

    function __construct() {
    	foreach ( array('post.php','post-new.php') as $hook ) {
    		add_action( "admin_head-$hook", array( $this, 'nep_emoji_localize_tinymce_javascript' ));
    		add_action( 'admin_init', array( $this, 'nep_emoji_scripts' ));
    	}
    }
    function nep_emoji_scripts(){
    	// Register CSS and JS files
    	wp_register_style( 'nep_native-emoji',  plugins_url('/css/style.css',__FILE__), false, '1.0', 'all' );
    	wp_register_script( 'nep_native-emoji', plugins_url('/js/script.js',__FILE__), false, '1.0', true );
    
    	wp_enqueue_style( 'nep_native-emoji' );
    	wp_enqueue_script( 'nep_native-emoji' );
    
    }

    but its not perfet, better it would be

    $screen = get_current_screen();
    if ( 'edit' === $screen->base || 'post-new' === $screen->base){

    https://wordpress.org/plugins/native-emoji/

Viewing 2 replies - 1 through 2 (of 2 total)
  • adlnpk

    (@adlnpk)

    On WordPress 4.4.2 your plugin throw the following type of notices:

    Notice: wp_enqueue_style was called incorrectly.
    Notice: wp_register_script was called incorrectly.

    The enqueueing or registering of the following files are not correct:
    register: nep_native-emoji style
    register: nep_native-emoji script
    enqueue: nep_native-emoji style
    enqueue: jquery script
    enqueue: nep_native-emoji script

    This code should wrap in a function which hooked for the init hook, so instead of:

    // Register CSS and JS files
    wp_register_style( 'nep_native-emoji',  plugins_url('/css/style.css',__FILE__), false, '1.0', 'all' );
    wp_register_script( 'nep_native-emoji', plugins_url('/js/script.js',__FILE__), false, '1.0', true );

    Use:

    // Register CSS and JS files
    function nep_register_script_styles(){
        wp_register_style( 'nep_native-emoji',  plugins_url('/css/style.css',__FILE__), false, '1.0', 'all' );
        wp_register_script( 'nep_native-emoji', plugins_url('/js/script.js',__FILE__), false, '1.0', true );
    }
    add_action('init', 'nep_register_script_styles');

    And similar in the enqueueing, do not enqueue directly in the costructor, instead that use the following hook:
    add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );

    Plugin Author Danny Brandenburg

    (@davabuu)

    Thanks for your suggestions, as these files are enqueued to the admin i’ll use the hook
    add_action( 'admin_enqueue_scripts', 'function_name' );
    it will be included in the next version

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘erros in log’ is closed to new replies.