Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // === ADMIN OPTIONS === //
- // add the options page under Settings
- function admin_page() {
- add_options_page('Exifography Options', 'Exifography Options', 'manage_options', 'exifography', array( &$this, 'options_page' ));
- }
- // render the admin page
- function options_page() {
- ?>
- <div>
- <h2><?php _e('Exifography Options', 'exifography'); ?></h2>
- <p><?php _e('For instructions and support please visit the <a target="_blank" href="http://www.kristarella.com/thesography">Thesography plugin page</a>.', 'thesography'); ?></p>
- <form action="options.php" method="post">
- <?php settings_fields($this->exif_options); ?>
- <?php do_settings_sections('plugin_options'); ?>
- <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
- </form>
- </div>
- <?php
- }
- // add the admin settings to the database and page
- function options_init(){
- register_setting( $this->exif_options, $this->exif_options, array(&$this,'options_validate') );
- add_settings_section('default_display', __('Default EXIF', 'exifography'), array(&$this,'defaults'), 'plugin_options');
- add_settings_section('auto_display', __('Auto insert into post', 'exifography'), array(&$this,'auto'), 'plugin_options');
- add_settings_section('custom_html', __('Custom HTML', 'exifography'), array(&$this,'html'), 'plugin_options');
- // exif fields settings inputs
- foreach ($this->fields as $key => $value) {
- add_settings_field('exif-field-'.$key, $value, array(&$this,'default_fields'), 'exifography', 'default_display', $key);
- }
- // auto insert settings fields
- add_settings_field('auto_insert', __('Automatically display exif','exifography'), array(&$this,'auto_field'), 'exifography', 'auto_display');
- // custom HTML settings fields
- foreach ($this->html_options as $key => $value) {
- add_settings_field($key, $value, array(&$this,'html_fields'), 'exifography', 'custom_html', $key);
- }
- wp_enqueue_style( 'exif_admin_style', WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) . 'styles/admin.css' );
- }
- // render options sections
- function defaults() {
- ?>
- <p><?php _e("Set these to create default options for every post. This is useful when <strong>most</strong> of your posts will be displaying EXIF for <strong>a single photo</strong>, and if you're not adding EXIF manually via shortcodes or custom functions.", 'exifography'); ?></p>
- <?php
- }
- function auto() {
- ?>
- <p><?php _e("Use this option to automatically insert the EXIF for the first image attached to your post.", 'exifography'); ?></p>
- <?php
- }
- function html() {
- ?>
- <p><?php _e('This is the HTML used to display your exif data. IDs and classes can be used for styling.', 'thesography'); ?></p>
- <?php
- }
- // render inputs
- function default_fields($key) {
- $options = $this->get_options();
- print_r($options);
- if(strpos($options['exif_fields'], $key) !== false)
- $checked = 'checked="checked"';
- echo '<input id="exif-field-'.$key.'" value="'.$key.'" type="checkbox" name="exif_fields[]" '.$checked.' />';
- }
- function auto_field() {
- $options = $this->get_options();
- if($options['auto_insert'])
- $checked = 'checked="checked"';
- echo '<input id="auto_insert" type="checkbox" name="auto_insert" '.$checked.' />';
- }
- function html_fields($key) {
- $options = $this->get_options();
- echo '<input type="text" id="'.$key.'" name="'.$key.'" value="'.stripslashes($options[$key]).'" class="regular-text code" />';
- }
- // validate options
- function options_validate($inputs) {
- return $inputs;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement