w3guy / persist-admin-notices-dismissal

Simple plugin that persists dismissal of admin notices across pages in WordPress dashboard.
http://w3guy.com/wordpress-admin-notices-dismissible/
90 stars 22 forks source link

not workng #12

Closed foxpcteam closed 7 years ago

foxpcteam commented 8 years ago

Hi, after i have create plugin and have add this line to the plugin i get this error: Parse error: syntax error, unexpected 'add_action' (T_STRING)

require  __DIR__ . '/vendor/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php'
add_action( 'admin_init', array( 'PAnD', 'init' ) );

function sample_admin_notice__success1() {
if ( ! is_admin_notice_active( 'notice-one-forever' ) ) {
        return;
    }

    ?>
    <div data-dismissible="notice-one-forever" class="updated notice notice-success is-dismissible">
        <p><?php _e( 'Done 1!', 'sample-text-domain' ); ?></p>
    </div>
    <?php
}
add_action( 'admin_notices', 'sample_admin_notice__success1' );

if i change from "require DIR" to: include_once( plugin_dir_path( __FILE__ ) . '/vendor/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php' );

i get this error:

Fatal error: Uncaught Error: Call to undefined function is_admin_notice_active() in

afragen commented 8 years ago

In your first example you are missing the ending ; from the require line.

Please take a closer look at the README example, you have also forgotten to reference the class in your conditional.