DO NOT 'Network Activate', since Wordpress 3.0 failed to create database tables for each web site. Use 'Activate' for each web site instead. I hope you enjoy it. For feedback and reports, visit the plugin website. Author: Benjamin Sommer Version: 1.3.2 Author URI: http://www.benjaminsommer.com License: CC GNU GPL 2.0 license */ /*--------------------------------------------------------------------------------------------------------- ** LOAD CONFIGURATION **--------------------------------------------------------------------------------------------------------- */ include_once('core/config.php'); //---------------------------------------------------------------------------------- // COMMON DB-QUERIES //---------------------------------------------------------------------------------- include_once( 'core/dbqueries.php' ); //---------------------------------------------------------------------------------- // COMMON DB-QUERIES //---------------------------------------------------------------------------------- include_once( 'core/uri_hndl.php' ); //---------------------------------------------------------------------------------- // INSTALL, ACTIVATION, DEACTIVATION //---------------------------------------------------------------------------------- function netblog_install() { global $wpdb; if( !get_option( "netblog_version" ) ) add_option('netblog_version', constant('NETBLOG_VERSION') ); update_option('netblog_version', constant('NETBLOG_VERSION') ); require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); if( get_option("netblog_db_ext_ver") == '1.0' ) return netblog_upgd_db10(); $tbl = $wpdb->prefix . constant('NETBLOG_DB_NET'); if($wpdb->get_var("SHOW TABLES LIKE '$tbl'") != $tbl) { $sql = "CREATE TABLE " . $tbl . " ( id BIGINT(20) UNSIGNED NOT NULL, adj_id BIGINT(20) UNSIGNED NOT NULL, UNIQUE KEY netblogAdj (id,adj_id) );"; dbDelta($sql); add_option("netblog_db_net_ver", constant('NETBLOG_DB_NET_VER') ); } // MAX MEDIUMINT: 16777215 (unsigned) $tbl = $wpdb->prefix . constant('NETBLOG_DB_EXT'); if($wpdb->get_var("SHOW TABLES LIKE '$tbl'") != $tbl) { $sql = "CREATE TABLE " . $tbl . " ( uri_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, uri VARCHAR(512) NOT NULL, uri_title VARCHAR(127) NOT NULL, flag INT(10), refs MEDIUMINT NOT NULL DEFAULT 1, PRIMARY KEY (uri_id) );"; dbDelta($sql); add_option("netblog_db_ext_ver", constant('NETBLOG_DB_EXT_VER') ); } $tbl = $wpdb->prefix . constant('NETBLOG_DB_REL_EXTNODE'); if($wpdb->get_var("SHOW TABLES LIKE '$tbl'") != $tbl) { $sql = "CREATE TABLE " . $tbl . " ( id BIGINT(20) UNSIGNED NOT NULL, uri_id BIGINT(20) UNSIGNED NOT NULL, UNIQUE INDEX `netblog_rel_extnode` (id,uri_id) );"; dbDelta($sql); add_option("netblog_db_rel_extnode_ver", constant('NETBLOG_DB_REL_EXTNODE_VER') ); } } // FIRST VERSION - NOTHING TO UPGRADE function netblog_upgrade() { $ver = get_option("netblog_db_ext_ver"); if( $ver == false ) return netblog_install(); if( !get_option( "netblog_version" ) ) add_option('netblog_version', constant('NETBLOG_VERSION') ); update_option('netblog_version', constant('NETBLOG_VERSION') ); if( $ver == '1.0') return netblog_upgd_db10(); return false; } function netblog_upgd_db10() { global $wpdb; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); // CREATE TABLE REL EXT if( !get_option('netblog_db_rel_extnode_ver') || get_option('netblog_db_rel_extnode_ver') != constant('NETBLOG_DB_REL_EXTNODE_VER')) { $tbl = $wpdb->prefix . constant('NETBLOG_DB_REL_EXTNODE'); if($wpdb->get_var("SHOW TABLES LIKE '$tbl'") != $tbl) { $sql = "CREATE TABLE " . $tbl . " ( id BIGINT(20) UNSIGNED NOT NULL, uri_id BIGINT(20) UNSIGNED NOT NULL, UNIQUE INDEX `netblog_rel_extnode` (id,uri_id) );"; //$wpdb->query($sql); dbDelta($sql); if( !get_option('netblog_db_rel_extnode_ver') ) add_option("netblog_db_rel_extnode_ver", constant('NETBLOG_DB_REL_EXTNODE_VER') ); else update_option("netblog_db_rel_extnode_ver", constant('NETBLOG_DB_REL_EXTNODE_VER') ); } } if( !get_option('netblog_db_ext_ver') ) { $tbl = $wpdb->prefix . constant('NETBLOG_DB_EXT'); if($wpdb->get_var("SHOW TABLES LIKE '$tbl'") != $tbl) { $sql = "CREATE TABLE " . $tbl . " ( uri_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, uri VARCHAR(512) NOT NULL, uri_title VARCHAR(127) NOT NULL, flag INT(10), refs MEDIUMINT NOT NULL DEFAULT 1, PRIMARY KEY (uri_id) );"; dbDelta($sql); add_option("netblog_db_ext_ver", constant('NETBLOG_DB_EXT_VER') ); } return true; } // UPDATE TABLE EXT if( get_option('netblog_db_ext_ver') <= '1.0' ) { $ext = $wpdb->prefix . constant('NETBLOG_DB_EXT'); $sql = "SELECT * FROM `$ext`"; $res = $wpdb->get_results($sql, ARRAY_A); $wpdb->query("DROP TABLE `$ext`"); $sql = "CREATE TABLE `$ext` ( uri_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, uri VARCHAR(512) NOT NULL, uri_title VARCHAR(127) NOT NULL, flag INT(10), refs MEDIUMINT NOT NULL DEFAULT 1, PRIMARY KEY (uri_id) );"; //$wpdb->query($sql); dbDelta($sql); update_option("netblog_db_ext_ver", constant('NETBLOG_DB_EXT_VER') ); foreach( $res as $row ) { netblog_addAdjacent( $row['id'], $row['uri'], true, $row['uri_title'] ); } } return true; } function netblog_deactivate() { remove_action('admin_menu', 'netblog_plugin_menu'); } function netblog_uninstall() { global $wpdb; // REMOVE DATABASE TABLES $dbtbl = array(); $dbtbl[] = $wpdb->prefix . constant('NETBLOG_DB_NET'); $dbtbl[] = $wpdb->prefix . constant('NETBLOG_DB_EXT'); $dbtbl[] = $wpdb->prefix . constant('NETBLOG_DB_REL_EXTNODE'); foreach( $dbtbl as $tbl ) { if( $wpdb->get_var("SHOW TABLES LIKE '$tbl'") == $tbl ) $wpdb->query("DROP TABLE `$tbl`"); } // $wpdb->query("DROP TABLE IF EXISTS ".implode(',',$dbtbl) ); // ALTERNATIVE METHOD - SOMEWHAT FASTER // REMOVE OPTIONS delete_option("netblog_version" ); delete_option("netblog_db_net_ver" ); delete_option("netblog_db_ext_ver" ); delete_option("netblog_db_rel_extnode_ver" ); } register_activation_hook(__FILE__,'netblog_install'); register_deactivation_hook(__FILE__,'netblog_deactivate'); register_uninstall_hook(__FILE__, 'netblog_uninstall'); //---------------------------------------------------------------------------------- // TOP-LEVEL ADMIN-MENU //---------------------------------------------------------------------------------- add_action('admin_init', 'netblog_plugin_admin_init'); add_action('admin_init', 'netblog_plugin_script'); add_action('admin_init', 'netblog_plugin_styles'); //add_action('admin_menu', 'netblog_plugin_menu'); // AMIN MENU DISABLED FOR NOW! UNDER CONSTRUCTION!!!! add_action('deleted_post', 'netblog_removeNode'); add_action('admin_menu', 'netblog_plg'); function netblog_plugin_admin_init() { wp_register_style('Netblog-plugin-css', WP_PLUGIN_URL . '/netblog/styles/style-admin.css'); wp_register_script('Netblog-plugin-js', WP_PLUGIN_URL . '/netblog/js/admin.js'); wp_register_style('Netblog-plugin-css-autocomplete', WP_PLUGIN_URL . '/netblog/styles/autocomplete.css'); wp_register_script('Netblog-plugin-js-autocomplete', WP_PLUGIN_URL . '/netblog/js/autocomplete.js'); wp_register_style('Netblog-plugin-css-lister', WP_PLUGIN_URL . '/netblog/styles/lister.css'); wp_register_script('Netblog-plugin-js-lister', WP_PLUGIN_URL . '/netblog/js/lister.js'); wp_register_script('Netblog-plugin-js-md5', WP_PLUGIN_URL . '/netblog/js/md5.js'); wp_register_script('Netblog-plugin-js-fade', WP_PLUGIN_URL . '/netblog/js/fade_hideShow.js'); wp_register_script('Netblog-plugin-js-timeoutRefresh', WP_PLUGIN_URL . '/netblog/js/setTimeoutRefresh.js'); } function netblog_plg() { $page = add_posts_page('Netblog', 'Extern Links', 'publish_posts', 'netblog-main-mk', 'netblog_main'); } function netblog_plugin_menu() { $page = add_posts_page('Netblog Posts', 'Netblog', 'publish_posts', 'netblog-posts-mk', 'netblog_plugin_options'); //add_action('admin_print_styles-' . $page, 'netblog_plugin_styles'); //add_action('admin_print_scripts-' . $page, 'netblog_plugin_script'); } function netblog_plugin_styles() { wp_enqueue_style('Netblog-plugin-css'); wp_enqueue_style('Netblog-plugin-css-autocomplete'); wp_enqueue_style('Netblog-plugin-css-lister'); } function netblog_plugin_script() { wp_enqueue_script('Netblog-plugin-js'); wp_enqueue_script('Netblog-plugin-js-autocomplete'); wp_enqueue_script('Netblog-plugin-js-lister'); wp_enqueue_script('Netblog-plugin-js-md5'); wp_enqueue_script('Netblog-plugin-js-fade'); wp_enqueue_script('Netblog-plugin-js-timeoutRefresh'); } function netblog_plugin_options() { global $wpdb; if (!current_user_can('publish_posts')) { wp_die( __('You do not have sufficient permissions to access this page.') ); } } function netblog_getqs( $remove ) { $r; if( is_array( $remove) ) $r = $remove; else $r = array($remove); $s = '?'; $num = 0; if(isset($_GET)) foreach( $_GET as $k=>$v ) { if( in_array($k,$r) ) continue; if( $num++ == 0 ) $s .= "$k=$v"; else $s .= "&$k=$v"; } return $s; } function netblog_qsval( $key ) { if( isset($_GET) && isset($_GET[$key]) ) return $_GET[$key]; else return ''; } //---------------------------------------------------------------------------------- // HELPER FUNCTIONS //---------------------------------------------------------------------------------- function netblog_cstrip( $string, $maxSize, $appendOnExceed ) { if( $maxSize > 0 && strlen($string) > $maxSize ) $string = substr($string,0,$maxSize) . $appendOnExceed; return $string; } //---------------------------------------------------------------------------------- // NETBLOG-PAGE //---------------------------------------------------------------------------------- function netblog_main() { echo '

Netblog - Manage External Links


'; ?>
 
'; } //---------------------------------------------------------------------------------- // SETTINGS PAGE //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // METABOX FOR EDIT-POST //---------------------------------------------------------------------------------- add_action('admin_init', 'netblog_post_add_metabox'); function netblog_post_add_metabox() { if( function_exists('add_meta_box') ) { add_meta_box('netblog_post_interface', 'Further Reading', 'netblog_post_interface', 'post', 'advanced','high'); add_meta_box('netblog_post_interface', 'Further Reading', 'netblog_post_interface', 'page', 'advanced','high'); } else { //add_action('dbx_post_advanced', 'myplugin_old_custom_box' ); } netblog_plugin_styles(); } function netblog_post_interface() { global $post; $nodeID = $post->ID; // VERIFY echo ''; $hintKeywordsExt = ''; $t = explode(' ', constant('NETBLOG_WEBSEARCH_KEYWORDS') ); if( sizeof($t) > 1 ) $hintKeywordsExt .= 'either '; $hintKeywordsExt .= 'with '; for( $i=0; $i0 && $i0 && $i==sizeof($t)-1 ) $hintKeywordsExt .= ' or with '; $hintKeywordsExt .= "'$t[$i]'"; } // METABOX CONTENT ?>
Type a name to search for posts at this site. Preceed your query to the word wide web .