I'm declaring a function on a plugin's PHP. The plugin loads code at the top of each post (Post Layout is the plugins name).
Cannot redeclare vote_up() (previously declared in /home/content/08/10290908/html/wp-content/plugins/post-layout/plugin.php(181) : eval()'d code:4) in /home/content/08/10290908/html/wp-content/plugins/post-layout/plugin.php(181) : eval()'d code on line 36
that's the displayed error message, it isnt because the function has already been declared in the functions.php (I know because I tested it by renaming it to all sorts of names) It says it's already declared in the plugin I'm using to load the code.
Heres the code:
<?php
function vote_up(){
if($post_vote == "9"){
}
elseif($post_vote == "8"){
update_post_meta( get_the_ID(), 'post_vote', '9', '8');
}
elseif($post_vote == "7"){
update_post_meta( get_the_ID(), 'post_vote', '8', '7');
}
elseif($post_vote == "6"){
update_post_meta( get_the_ID(), 'post_vote', '7', '6');
}
elseif($post_vote == "5"){
update_post_meta( get_the_ID(), 'post_vote', '6', '5');
}
elseif($post_vote == "4"){
update_post_meta( get_the_ID(), 'post_vote', '5', '4');
}
elseif($post_vote == "3"){
update_post_meta( get_the_ID(), 'post_vote', '4', '3');
}
elseif($post_vote == "2"){
update_post_meta( get_the_ID(), 'post_vote', '3', '2');
}
elseif($post_vote == "1"){
update_post_meta( get_the_ID(), 'post_vote', '2', '1');
}
elseif($post_vote == "0"){
update_post_meta( get_the_ID(), 'post_vote', '1', '0');
}
else{//do nothing
};
}
//if the post is pending show
if(get_post_status() == 'pending') {
//if the user is logged in show
if ( is_user_logged_in() ) {
add_post_meta( get_the_ID(), 'post_vote', '0', true );
$post_vote = get_post_meta( get_the_ID(), 'post_vote', true );
echo 'Votes: ' . $post_vote;
echo ' <form action="xxx" method="post" onclick="return vote_up()">';
echo ' <input type="button" value="Vote Up" />';
echo '</form>';
} else {
echo'Please Sign in to Vote';
}
} else {
// do nothing
}
?>
The code above is basically trying to make it so that when you click on the button, the vote meta_key goes up by one. It's for voting so once 10 users vote on it, it will publish.
This stupid buttons such a hassle, I can't move on until I have it working even tried to pay some guy to fix the button and he didn't have a clue
functions.php
and the plugin have a function of the same name?