Changeset 1854499
- Timestamp:
- 04/07/2018 12:13:27 PM (8 years ago)
- File:
-
- 1 edited
-
nomination-and-voting/trunk/voting.php (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nomination-and-voting/trunk/voting.php
r1348359 r1854499 3 3 Plugin Name: nomination and voting 4 4 Plugin URI: # 5 Description: nomination and voting 5 Description: nomination and voting 6 6 Author: macmonir 7 7 Version: 1.1 … … 12 12 function wpnv_install(){ 13 13 global $wpdb; 14 14 15 15 $table_name1 = $wpdb->prefix . "nv_nomination"; 16 16 $table_name2 = $wpdb->prefix . "nv_nominee"; … … 18 18 $table_name4 = $wpdb->prefix . "nv_vote"; 19 19 20 20 21 21 $sql1 = "CREATE TABLE IF NOT EXISTS ".$table_name1." ( 22 22 `id` int(11) NOT NULL AUTO_INCREMENT, … … 26 26 PRIMARY KEY (`id`) 27 27 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 28 28 29 29 $sql2 = "CREATE TABLE IF NOT EXISTS ".$table_name2." ( 30 30 `id` int(11) NOT NULL AUTO_INCREMENT, 31 31 `nominee_name` varchar(255) NOT NULL, 32 32 PRIMARY KEY (`id`) 33 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 33 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 34 34 35 35 $sql3 = "CREATE TABLE IF NOT EXISTS ".$table_name3." ( … … 38 38 `name` varchar(255) DEFAULT NULL, 39 39 PRIMARY KEY (`id`) 40 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 40 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 41 41 42 42 $sql4 = "CREATE TABLE IF NOT EXISTS ".$table_name4." ( … … 46 46 `category` int(11) NOT NULL, 47 47 PRIMARY KEY (`id`) 48 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 49 48 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 49 50 50 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 51 51 dbDelta($sql1); … … 56 56 } 57 57 58 function wpnv_custom_init() 58 function wpnv_custom_init() 59 59 { 60 60 $labels = array( … … 69 69 'search_items' => __('Search Voting Poll'), 70 70 'not_found' => __('No Voting Poll found'), 71 'not_found_in_trash' => __('No Voting Poll found in Trash'), 71 'not_found_in_trash' => __('No Voting Poll found in Trash'), 72 72 'parent_item_colon' => '', 73 73 'menu_name' => 'Vote' … … 78 78 'public' => true, 79 79 'publicly_queryable' => true, 80 'show_ui' => true, 81 'show_in_menu' => true, 80 'show_ui' => true, 81 'show_in_menu' => true, 82 82 'query_var' => true, 83 83 'rewrite' => true, 84 84 'capability_type' => 'post', 85 'has_archive' => true, 85 'has_archive' => true, 86 86 'hierarchical' => false, 87 87 'menu_position' => null, 88 88 'supports' => array('title','editor') 89 ); 89 ); 90 90 register_post_type('vote',$args); 91 92 91 92 93 93 // Add new taxonomy, make it hierarchical (like categories) 94 94 $labels = array( … … 99 99 'parent_item' => __( 'Parent VotingCategory' ), 100 100 'parent_item_colon' => __( 'Parent VotingCategory:' ), 101 'edit_item' => __( 'Edit VotingCategory' ), 101 'edit_item' => __( 'Edit VotingCategory' ), 102 102 'update_item' => __( 'Update VotingCategory' ), 103 103 'add_new_item' => __( 'Add New VotingCategory' ), 104 104 'new_item_name' => __( 'New VotingCategory Name' ), 105 105 'menu_name' => __( 'VotingCategory' ), 106 ); 106 ); 107 107 108 108 register_taxonomy('VotingCategory',array('vote'), array( … … 118 118 function nomination_menu(){ 119 119 //add_menu_page( "Voting", "Voting and Nomination", "administrator", "vote_nomination", "wp_nv_settings" ); 120 add_submenu_page('edit.php?post_type=vote', 'Voting and Nomination Settings', 'Settings', 'administrator', 'vote_nomination_settings', 'wp_nv_settings'); 121 add_submenu_page('edit.php?post_type=vote', 'All Nominees', 'All Nominees', 'administrator', 'all_nominee', 'wp_nv_nominee_list'); 122 add_submenu_page('edit.php?post_type=vote', 'All Voters', 'All Voters', 'administrator', 'all_voter', 'wp_nv_voter_list'); 123 124 125 120 add_submenu_page('edit.php?post_type=vote', 'Voting and Nomination Settings', 'Settings', 'administrator', 'vote_nomination_settings', 'wp_nv_settings'); 121 add_submenu_page('edit.php?post_type=vote', 'All Nominees', 'All Nominees', 'administrator', 'all_nominee', 'wp_nv_nominee_list'); 122 add_submenu_page('edit.php?post_type=vote', 'All Voters', 'All Voters', 'administrator', 'all_voter', 'wp_nv_voter_list'); 123 124 125 126 126 } 127 127 … … 148 148 function wp_nv_nominee_list(){ 149 149 global $wpdb; 150 $where=""; 151 $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_nominee ". $where); 152 include("tpls/nominee_list.php"); 150 $where=""; 151 $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_nominee ". $where); 152 include("tpls/nominee_list.php"); 153 153 } 154 154 function wp_nv_voter_list(){ 155 155 156 156 global $wpdb; 157 $where=""; 158 $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_visitor wvs inner join ".$wpdb->prefix."nv_vote wv on wvs.id=wv.visitorid inner join ".$wpdb->prefix."nv_nominee wn on wn.id=wv.voterid ". $where); 159 include("tpls/voter_list.php"); 157 $where=""; 158 $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_visitor wvs inner join ".$wpdb->prefix."nv_vote wv on wvs.id=wv.visitorid inner join ".$wpdb->prefix."nv_nominee wn on wn.id=wv.voterid ". $where); 159 include("tpls/voter_list.php"); 160 160 } 161 161 162 162 function wp_nv_settings(){ 163 164 include("tpls/settings.php"); 163 164 include("tpls/settings.php"); 165 165 } 166 166 … … 176 176 177 177 function wp_nomination_frontend(){ 178 178 179 179 //$concat= get_option("permalink_structure")?"?":"&"; 180 180 $mode=get_option('_wp_nv_mode'); … … 204 204 if($nid==0){ 205 205 //insert into nominee 206 $wpdb->insert( 207 'wp_nv_nominee',206 $wpdb->insert( 207 $wpdb->prefix.'nv_nominee', 208 208 array( 'nominee_name' => $_POST['nominee']), array('%s')); 209 209 $nid=$wpdb->insert_id; 210 210 } 211 212 211 212 213 213 //insert into nomination 214 $wpdb->insert( 215 $wpdb->prefix.'nv_nomination', 216 array( 217 'visitorid' => $id, 214 $wpdb->insert( 215 $wpdb->prefix.'nv_nomination', 216 array( 217 'visitorid' => $id, 218 218 'nomineeid' => $nid , 219 'category' => $_POST['cat'] 220 221 ), 222 array( 219 'category' => $_POST['cat'] 220 221 ), 222 array( 223 223 '%d', 224 '%d', 225 '%d' 226 ) 224 '%d', 225 '%d' 226 ) 227 227 ); 228 228 die("submitted"); … … 253 253 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; 254 254 if ( !current_user_can( 'edit_post', $post_id ) ) return; 255 255 256 256 update_post_meta($post_id,'vote_category',$_POST['cat']); 257 257 update_post_meta($post_id,'voter_nomineeid',$_POST['voter_nomineeid']); … … 271 271 $nominees =array(); 272 272 $nominees_name =array(); 273 $cat = get_post_meta($value->ID, 'vote_category',true); 273 $cat = get_post_meta($value->ID, 'vote_category',true); 274 274 $nominees= get_post_meta($value->ID, 'voter_nomineeid',true); 275 275 $nominees_name= get_post_meta($value->ID, 'voter_nomineename',true); 276 277 276 277 278 278 if($cat){ 279 279 280 280 $catname=$data = $wpdb->get_results("select name from ".$wpdb->prefix."terms where term_id='".$cat."' "); 281 281 $vcat[$cat]=$catname[0]->name; 282 282 $pid[$cat]=$value->ID; 283 283 } 284 284 285 285 //if($nominees) 286 286 287 287 } 288 288 include_once("tpls/asking_voting.php"); … … 290 290 return; 291 291 } 292 292 293 293 } 294 294 … … 300 300 $html=""; 301 301 global $wpdb; 302 302 303 303 /*print_r($nominees); 304 304 print_r($nominees_name);die();*/ 305 305 $data = $wpdb->get_results("select *,wn.id as id from ".$wpdb->prefix."nv_nominee wn inner join ".$wpdb->prefix."nv_nomination wnm on wn.id=wnm.nomineeid where category='".$_POST['catid']."' group by nomineeid"); 306 306 307 307 if(count($data)) 308 308 foreach($data as $val){ … … 327 327 } 328 328 //$wpdb->last_query; 329 330 329 330 331 331 //echo $id; 332 332 $dataf = $wpdb->get_results("select id from ".$wpdb->prefix."nv_vote where visitorid='".$id."' and category='".$_POST['cat']."' and (social='facebook' or social='twitter')"); … … 338 338 } 339 339 } 340 340 341 341 //echo $count; 342 342 //insert into nomination … … 346 346 if($_COOKIE['email']){ 347 347 $social=$_COOKIE['email']; 348 $wpdb->insert( 349 'wp_nv_vote',350 array( 351 'visitorid' => $id, 348 $wpdb->insert( 349 $wpdb->prefix.'nv_vote', 350 array( 351 'visitorid' => $id, 352 352 'voterid' => $_POST['nominee'], 353 'category' => $_POST['cat'], 354 'social' => "facebook" 355 356 ), 357 array( 353 'category' => $_POST['cat'], 354 'social' => "facebook" 355 356 ), 357 array( 358 358 '%d', 359 '%d',360 359 '%d', 361 '%s' 362 ) 360 '%d', 361 '%s' 362 ) 363 363 ); 364 364 } … … 367 367 if($_COOKIE['twitter_anywhere_identity']){ 368 368 $social=$_COOKIE['twitter_name']; 369 $wpdb->insert( 370 'wp_nv_vote',371 array( 372 'visitorid' => $id, 369 $wpdb->insert( 370 $wpdb->prefix.'nv_vote', 371 array( 372 'visitorid' => $id, 373 373 'voterid' => $_POST['nominee'] , 374 'category' => $_POST['cat'], 375 'social' => "twitter" 376 377 ), 378 array( 379 '%d', 380 '%d', 381 '%d', 382 '%s' 383 ) 374 'category' => $_POST['cat'], 375 'social' => "twitter" 376 377 ), 378 array( 379 '%d', 380 '%d', 381 '%d', 382 '%s' 383 ) 384 384 ); 385 385 } … … 390 390 if($sc=="facebook"){ 391 391 if($_POST['tw']){ 392 if($_COOKIE['twitter_anywhere_identity']){ 393 $wpdb->insert( 394 'wp_nv_vote',395 array( 396 'visitorid' => $id, 392 if($_COOKIE['twitter_anywhere_identity']){ 393 $wpdb->insert( 394 $wpdb->prefix.'nv_vote', 395 array( 396 'visitorid' => $id, 397 397 'voterid' => $_POST['nominee'] , 398 'category' => $_POST['cat'], 399 'social' => "twitter" 400 401 ), 402 array( 398 'category' => $_POST['cat'], 399 'social' => "twitter" 400 401 ), 402 array( 403 403 '%d', 404 '%d',405 404 '%d', 406 '%s' 407 ) 405 '%d', 406 '%s' 407 ) 408 408 ); 409 409 } … … 413 413 if($_POST['fb']){ 414 414 if($_COOKIE['email']){ 415 $wpdb->insert( 416 'wp_nv_vote',417 array( 418 'visitorid' => $id, 415 $wpdb->insert( 416 $wpdb->prefix.'nv_vote', 417 array( 418 'visitorid' => $id, 419 419 'voterid' => $_POST['nominee'], 420 'category' => $_POST['cat'], 421 'social' => "facebook" 422 423 ), 424 array( 425 '%d', 426 '%d', 427 '%d', 428 '%s' 429 ) 420 'category' => $_POST['cat'], 421 'social' => "facebook" 422 423 ), 424 array( 425 '%d', 426 '%d', 427 '%d', 428 '%s' 429 ) 430 430 ); 431 431 } … … 445 445 session_start(); 446 446 include_once('twitteroauth/twitteroauth.php'); 447 //require_once('config.php'); 448 447 //require_once('config.php'); 448 449 449 //postToTwitter(CONSUMER_KEY, CONSUMER_SECRET, oauth_token, oauth_token_secret); petalert application 450 450 postToTwitter("47CcqrU8EyPgbcZD9pmfZg","VYhl4pCsHrokZ4fiGctUnDErXL9JK6wFaOrMTn4s","125561843-zdGAagUe0bEka178R1jVYXXhC6FLbeLPYM8jZlTf","l5SUvacxP6nXqvec1AA27Gg9bu9wTdLW9PDojKUMes"); … … 454 454 function postToTwitter($CONSUMER_KEY, $CONSUMER_SECRET, $oauth_token, $oauth_token_secret){ 455 455 $msg=get_option('_wp_nv_fb_twiter_text1'); 456 456 457 457 $msg=str_replace("{nominee}",$_POST['name'],$msg); 458 458 $connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $oauth_token, $oauth_token_secret); … … 460 460 //var_dump($content->response); 461 461 //print_r($content); 462 $connection->post('statuses/update', array('status' => $msg)); 463 } 464 465 466 467 462 $connection->post('statuses/update', array('status' => $msg)); 463 } 464 465 466 467 468 468 wp_enqueue_script("jquery"); 469 wp_enqueue_script('jquery-form'); 469 wp_enqueue_script('jquery-form'); 470 470 wp_enqueue_script('jquery-cookie',plugins_url("/nomination-and-voting/js/jquery.cookie.js")); 471 471 if(is_admin()){ … … 477 477 //metabox 478 478 //add_action( 'add_meta_boxes', 'wpnv_add_custom_box' ); 479 480 } 481 add_action("wp_head","wp_nomination_frontend"); 479 480 } 481 add_action("wp_head","wp_nomination_frontend"); 482 482 add_action("init","wp_nomination_submit"); 483 483 add_action("init","nominee_for_cat");
Note: See TracChangeset
for help on using the changeset viewer.