options = get_option($this->tag); if (is_admin()) { add_action('admin_menu', array(&$this, 'menu')); add_action('admin_init', array(&$this, 'settings_init')); add_filter('plugin_row_meta', array(&$this, 'settings_meta'), 10, 2); } add_filter('contact_detail', array(&$this, 'build'), 1); add_shortcode('contact', array(&$this, 'shortcode')); } function menu() { add_options_page($this->name, $this->name, 8, $this->tag, array(&$this, 'settings_page')); } function settings_init() { register_setting($this->tag.'_options', $this->tag); } function settings_page() { include_once('settings.php'); } function settings_meta($links, $file) { $plugin = plugin_basename(__FILE__); if ($file == $plugin) { return array_merge( $links, array(sprintf( '%s', $this->tag, __('Edit Details') )) ); } return $links; } function build($args) { extract($args); $value = $this->value($type); if (strlen($value) == 0) { return; } $detail = $before.$value.$after; if ($echo) { echo $detail; } else { return $detail; } } function value($type=false) { if ($type != false && array_key_exists($type, $this->options)) { return ($type == 'address' ? nl2br($this->options[$type]) : $this->options[$type]); } return null; } function shortcode($atts) { extract(shortcode_atts(array( 'type' => false ), $atts)); return contact_detail($type, false, false, false); } } $contactDetails = new ContactDetails(); if (isset($contactDetails)) { function contact_detail($t=false,$b='',$a='',$e=true){ return apply_filters('contact_detail', array( 'type'=>$t, 'before'=>$b, 'after'=>$a, 'echo'=>$e )); } } }