cicons = $wpdb->prefix.'ci_post_ref'; //Define a term that points to the uploads folder define('CICONS', ABSPATH."/wp-content/uploads/cicons"); /** ** Function: Adding "Content Icons" Meta box **/ add_action('admin_menu', 'cicons_add_meta_box'); function cicons_add_meta_box() { add_meta_box('ciconsdiv', __('Content Icons', 'cicons'), 'cicons_metabox_admin', 'post', 'side'); } /** ** Function: Content Icons Activate & Install **/ //First, we add the action, which tells WordPress to set the activation hook for a plugin //this particular call requires to parameters: the file location and name and the function name //add_action('activate_content-icons/content-icons.php', 'conticons_init'); add_action('init', 'cicons_init'); function cicons_init(){ global $wpdb; //let's start by defining our table name $table_name = $wpdb->prefix . "ci_post_ref"; //now, we make sure that such a table doesn't already exist. //if our desired table name already exist, we will not Create it again! if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { //we will be creating a table that holds two key pieces of information: icon id, and the post it belongs to. $create_cicons_info = "CREATE TABLE " . $table_name . " ( `post_id` INT NOT NULL , `icon_name` TEXT NOT NULL , PRIMARY KEY ( `post_id` ) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($create_cicons_info); } //create the upload directory wp_mkdir_p(ABSPATH."/wp-content/uploads/cicons"); } /** ** Function: Meta Box Function **/ function cicons_metabox_admin() { global $wpdb, $post; $currentPID = $post->ID; echo '