prefix."attributor"; $structure = "CREATE TABLE IF NOT EXISTS `". $table."` ( id INT(9) NOT NULL AUTO_INCREMENT, post_id VARCHAR(255) NOT NULL, UNIQUE KEY id (id) );"; $wpdb->query($structure); add_option("fairshare_position",""); $insert_structure = "INSERT INTO `".$table."`(post_id) SELECT ID FROM wp_posts WHERE post_status='publish'"; $wpdb->query($insert_structure); //add_option("checked","unchecked"); } function page_field() { if( function_exists( 'add_meta_box' )) { add_meta_box('attributor', __('Attributor FairShare'), 'post_attributor', 'page', 'advanced', 'core'); add_meta_box('attributor', __('Attributor FairShare'), 'post_attributor', 'post', 'advanced', 'core'); } } /* BACK-END attributor DISPLAY */ function post_attributor($post) { global $wpdb; $page_id=$post->ID; $table=$wpdb->prefix."attributor"; $structure = "SELECT * FROM `". $table."` WHERE post_id=".$post->ID; $myrows = $wpdb->get_results($structure); ?> /> prefix."attributor"; $delete_structure = "DELETE FROM `". $table."` WHERE post_id=".$post_id; $wpdb->query($delete_structure); $status = $wpdb->get_results('SELECT post_status FROM wp_posts WHERE ID='.$post_id); //IF WE SET THAT THE POST WILL INCLUDE THE attributor WIDGET if(($status[0]->post_status=='publish')) { $myFile = WP_CONTENT_DIR."/uploads/log.txt"; $fh = fopen($myFile, 'a'); if(isset($_POST["is_checked"])) { $text = "Saved checked box for post ".$post_id."\n"; fwrite($fh, $text); //INSERT INTO THE DATABASE } else { $text = "Saved unchecked box for post ".$post_id."\n"; fwrite($fh, $text); $insert_structure = "INSERT INTO `".$table."`(post_id) VALUES (".$post_id.")"; $wpdb->query($insert_structure); } fclose($fh); } } /* attributor UNINSTALL */ function info_uninstall() { global $wpdb; $table=$wpdb->prefix."attributor"; $structure = "DROP TABLE `". $table."`;"; $wpdb->query($structure); } //FUNCTION FOR INSERTING attributor WIDGET INTO SELECTED POSTS function protect($content ) { global $wpdb; global $post; $table = $wpdb->prefix."attributor"; //VERIFY IF THE POST IS SET TO HAVE attributor WIDGET IN IT $is_attributor = $wpdb->get_results('SELECT * FROM '.$table.' WHERE post_id='.$post->ID); if(count($is_attributor)==0) { $pos = get_option('fairshare_position'); $result = ''; switch($pos){ case 'top-left': case 'top-right': case 'top-center': $result .= '
'.$content; break; case 'bottom-left': case 'bottom-right': case 'bottom-center': $result .= $content.''; break; case 'middle-left': case 'middle-right': $result.= '