I'm writing my own WordPress plugin, which is why some of the code might look a little weird. But my problem is with plain old PHP.
I created a list of players, each player has a unique URL. I want to have a "Copy Link" button on each row/player. But I can't seem to get this to work.
I don't want to update the site on copy, so I guess I need to use something like Ajax. But I have no experience.
I tried creating it using JavaScript but when I pass in the link (string) it keeps printing an error. It prints: "Unexpected token ':'. Expected ')' to end parameter list."
I have set up my PHP file like this:
ID, 'email')[0]; $player_status = get_post_meta($player->ID, 'status')[0]; $player_link = get_permalink($player->ID); if ($player_status == 'Not completed') { array_push($not_completed_players, 'true'); } $return_html .= '
' . $player->post_title . '
' . $player_email . '
' . $player_status . '
You should surround the parameters of the
copyToClipboard
function with double or single quotes. This solution escapes'
by adding a backslash (\
):Your player link may contain
https:
and the colon will cause an error message.