Wordpress plugin to show a message saying that the site uses cookies

cookieconsent-options.php 4.2KB

    <?php $base_name = plugin_basename( 'eu-cookie-consent/cookieconsent-options.php' ); $base_page = 'admin.php?page='.$base_name; $id = (isset($_GET['id'] ) ? intval($_GET['id'] ) : 0); $mode = (isset($_GET['mode'] ) ? trim($_GET['mode'] ) : '' ); $text = ''; $themes = array( 'dark-bottom', 'dark-floating', // 'dark-inline', 'dark-top', 'light-bottom', 'light-floating', // 'light-inline', 'light-top', ); ### Form Processing if(!empty($_POST['Submit'] )) { check_admin_referer( 'cookieconsent_options' ); $cookie_options = array( 'message' => eu_cookieconsent_options_parse( 'message' ), 'dismiss' => eu_cookieconsent_options_parse( 'dismiss' ), 'learnMore' => eu_cookieconsent_options_parse( 'learnMore' ), 'link' => eu_cookieconsent_options_parse( 'link' ), 'theme' => eu_cookieconsent_options_parse( 'theme' ), 'expiryDays' => eu_cookieconsent_options_parse( 'expiryDays'), ); $update_queries = array(); $update_text = array(); $update_queries[] = update_option( 'eu_cookieconsent_options', $cookie_options ); $update_text[] = __('Cookie Consent Options','eu-cookie-consent'); $i = 0; foreach( $update_queries as $query) { if ( $query ) { $text .= '<p style="color: green;">' . $update_text[$i] . ' ' . __('Updated','eu-cookie-consent') . '</p>'; } } if ( empty( $text ) ) { $text = '<p style="color: red;">' . __('Cookie Consent Options not updated','eu-cookie-consent').'</p>'; } } $cookie_options = get_option('eu_cookieconsent_options'); ?> <?php if( !empty($text) ) { echo '<div id="message" class="updated fade"><p>'. $text .'</p></div>'; } ?> <form method="post" action="<?php echo admin_url( 'admin.php?page=' . plugin_basename( __FILE__ ) ); ?>"> <?php wp_nonce_field( 'cookieconsent_options' ); ?> <div class="wrap"> <h2><?php _e( 'Cookie Consent Options', 'eu-cookie-consent' ); ?></h2> <table class="form-table"> <tr> <td valign="top" width="30%"><strong><?php _e('Theme:', 'eu-cookie-consent'); ?></strong></td> <td valign="top"> <?php $selected_theme = $cookie_options['theme']; foreach ($themes as $theme) { ?> <div class="eucc-theme-select"> <img src="<?php echo plugins_url("eu-cookie-consent/silktide/theme-previews/$theme.png"); ?>" align="enter" /><br/> <input type="radio" name="theme" value="<?php echo $theme?>" <?php if ($theme === $selected_theme) { echo "checked"; } ?> /> </div><?php if ($theme === 'dark-top') { echo '<div class="clear"></div>'; } ?> <?php } ?> </td> </tr> <tr> <td valign="top" width="30%"><strong><?php _e( 'Message:' , 'eu-cookie-consent'); ?></strong></td> <td valign="top"> <input name='message' value='<?php echo htmlspecialchars(stripslashes($cookie_options['message'])); ?>' class="biginput" /> </td> </tr> <tr> <td valign="top" width="30%"><strong><?php _e( 'Accept Button text:' , 'eu-cookie-consent'); ?></strong></td> <td valign="top"> <input name='dismiss' value='<?php echo htmlspecialchars(stripslashes($cookie_options['dismiss'])); ?>' /> </td> </tr> <tr> <td valign="top" width="30%"><strong><?php _e( 'Read More button text:' , 'eu-cookie-consent'); ?></strong></td> <td valign="top"> <input name='learnMore' value='<?php echo htmlspecialchars(stripslashes($cookie_options['learnMore'])); ?>' /> </td> </tr> <tr> <td valign="top" width="30%"><strong><?php _e( 'Cookie Policy Page:' , 'eu-cookie-consent'); ?></strong></td> <td valign="top"> <input name='link' value='<?php echo htmlspecialchars(stripslashes($cookie_options['link'])); ?>' class="biginput" /> </td> </tr> <tr> <td valign="top" width="30%"><strong><?php _e( 'Expire Days:' , 'eu-cookie-consent'); ?></strong></td> <td valign="top"> <input name='expiryDays' value='<?php echo htmlspecialchars(stripslashes($cookie_options['expiryDays'])); ?>' /> </td> </tr> </table> <p class="submit"> <input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Changes', 'eu-cookie-consent' ); ?>" /> </p> </div> </form>