How to do it...

  1. Navigate to the ch2-private-item-text folder of the WordPress plugin directory of your development installation.
  2. Open the ch2-private-item-text.php file in a text editor.
  3. Add the following lines of code to implement an activation callback to initialize plugin options when it is installed or upgraded:
register_activation_hook( __FILE__, 'ch2pit_get_options' ); function ch2pit_get_options() {    $options = get_option( 'ch2pit_options', array() );    $stylesheet_location = plugin_dir_path( __FILE__ ) .                                'stylesheet.css';    $new_options['stylesheet'] =         file_get_contents( $stylesheet_location );     $merged_options = wp_parse_args( $options, $new_options );    $compare_options = array_diff_key( $new_options, $options ); if ( empty( $options ...

Get WordPress Plugin Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.