autoContentLinksControlPanel($file); } /** * Old style PHP4 constructor * @param string $file * @access public * @since 1.0 * @return void */ function autoContentLinksControlPanel($file) { // Add Settings link to plugin page add_filter("plugin_action_links_".$file, array($this, 'actlinks')); // Any settings to initialize add_action('admin_init', array($this, 'adminInit')); // Load menu page add_action('admin_menu', array($this, 'addAdminPage')); // Load admin CSS style sheet add_action('admin_head', array($this, 'registerHead')); } /** * Add a setting link to the plugin settings page * @param array $links * @access public * @since 1.0 * @return void */ function actlinks($links) { // Add a link to this plugins settings page $settings_link = 'Settings'; array_unshift($links, $settings_link); return $links; } /** * Initialize admin * @access public * @since 1.0 * @return void */ function adminInit() { register_setting('autoContentLinksOptions', 'auto_content_links'); } /** * Add an admin page to the general settings panel * @access public * @since 1.0 * @return void */ function addAdminPage() { add_options_page('Auto Content Links Options', 'Auto Content Links', 'administrator', 'auto-content-links', array($this, 'admin')); } /** * Admin page * @access public * @since 1.0 * @return void */ function admin() { echo '
'; echo '
'; echo '
'; echo '

Auto Content Links Settings

'; echo '

By: Rich Gubby

'; echo '

A word of warning: Don\'t enter words and URLs that loop on each other - it only gets the plugin in a mess and ultimately makes your blog post look rubbish!

'; echo ''; settings_fields('autoContentLinksOptions'); $this->options = get_option('auto_content_links'); $update = false; if(isset($_REQUEST['new_option_name']) AND $_REQUEST['new_option_name'] != '') { if(!isset($this->options['keys'])) $this->options['keys'] = array(); if(!array_key_exists($_REQUEST['new_option_name'], $this->options['keys'])) { $this->options['links'][] = array( 'name' => strip_tags(stripslashes($_REQUEST['new_option_name'])), 'url' => strip_tags(stripslashes($_REQUEST['new_option_url'])), 'instances' => strip_tags(stripslashes($_REQUEST['new_option_instances'])), 'match_whole_word' => strip_tags(stripslashes($_REQUEST['new_option_match_whole_word'])) ); $this->options['keys'][$_REQUEST['new_option_name']] = true; $update = true; } } foreach($_REQUEST as $key => $val) { // Check if we're trying to delete a key if(strpos($key, 'deleteoption_') === 0) { $delete = $this->options['links'][str_replace('deleteoption_', '', $key)]; unset($this->options['links'][str_replace('deleteoption_', '', $key)]); unset($this->options['keys'][$delete['name']]); $update = true; } // Check if we're updating a value if(strpos($key, 'link_') === 0) { // Update value $updateKey = substr($key, 5, 1); $update = $this->options['links'][$updateKey]; if($key == 'link_'.substr($key,5,1).'_name') $this->options['links'][$updateKey]['name'] = strip_tags(stripslashes($val)); if($key == 'link_'.substr($key,5,1).'_url') $this->options['links'][$updateKey]['url'] = strip_tags(stripslashes($val)); if($key == 'link_'.substr($key,5,1).'_instances') $this->options['links'][$updateKey]['instances'] = strip_tags(stripslashes($val)); if($key == 'link_'.substr($key,5,1).'_match_whole_word') $this->options['links'][$updateKey]['match_whole_word'] = strip_tags(stripslashes($val)); $update = true; } } if($update == true) { update_option('auto_content_links', $this->options); echo "

Settings saved

"; } echo '

'.__('Add New Auto Link').'

'; echo ''; echo ''; echo ''; echo ''; if(isset($this->options['links']) AND !empty($this->options['links'])) { echo '

Enter the word in your content you want to replace

Enter the URL that your new word replacement will go to

Replace the first "x" number of words in your content

Only match whole words - no words in words

'.__('Existing Auto Links').'

'; foreach($this->options['links'] as $key => $link) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } echo '


'; echo '

 

Donate

If you like this plugin, keep it Ad free and in a constant state of development by donating to the cause!

Follow me

I\'m on Twitter - make sure you follow me!

Other plugins you might like...

Wapple Architect Mobile Plugin

Wapple Architect Mobile Plugin

The Wapple Architect Mobile Plugin for WordPress mobilizes your blog so your visitors can read your posts whilst they are on their mobile phone!

Head over to http://wordpress.org/extend/plugins/wapple-architect/ and install it now or jump straight to the Plugin Install Page

WordPress Mobile Admin

WordPress Mobile Admin

WordPress Mobile Admin allows you to create posts from your mobile, upload photots, moderate comments and perform basic post/page management.

Download it from http://wordpress.org/extend/plugins/wordpress-mobile-admin/ or jump straight to the Plugin Install Page

'; } /** * Add styles to admin header * @access public * @since 1.0 * @return void */ function registerHead() { $url = WP_PLUGIN_URL.'/'.basename(dirname(__FILE__)).'/auto-content-links.css'; echo "\n"; } }