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); } 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); ?> 0) echo 'checked'; ?>/> 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(isset($_POST["is_checked"]) && ($status[0]->post_status=='publish')) { //INSERT INTO THE DATABASE $insert_structure = "INSERT INTO `".$table."`(post_id) VALUES (".$post_id.")"; $wpdb->query($insert_structure); } } /* 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) { $result = '
'.$content; } else { $result = $content; } return $result; } function attributor_custom() { add_menu_page('custom', 'Attributor FairShare', 7, "", 'attributor_custom_fct'); } function attributor_custom_fct() { global $wpdb; if((isset($_POST['save']))&&($_POST['save']=='Save')) {?>
Attributor FairShare plugin setting has been updated.
prefix."attributor"; if($_POST['all_checked']=='on') { $delete_structure = "DELETE FROM ".$table; $wpdb->query($delete_structure); $insert_structure = "INSERT INTO `".$table."`(post_id) SELECT ID FROM wp_posts WHERE post_status='publish'"; $wpdb->query($insert_structure); } else { $delete_structure = "DELETE FROM ".$table; $wpdb->query($delete_structure); } } ?>
prefix."attributor"; $select_pages = $wpdb->get_results('SELECT * FROM wp_posts WHERE post_status="publish"'); $attributor_pages = $wpdb->get_results('SELECT t1.* FROM wp_posts AS t1 join '.$table.' AS t2 ON t1.ID=t2.post_id WHERE t1.post_status="publish"'); if(count($select_pages)!=count($attributor_pages)) { $check = false; } else { $check = true; } ?> />