Skip to content

Instantly share code, notes, and snippets.

@carmoreira
Created July 18, 2022 10:04
Show Gist options
  • Save carmoreira/e16170a6cbc2ac44a4bcc74c69395c77 to your computer and use it in GitHub Desktop.
Save carmoreira/e16170a6cbc2ac44a4bcc74c69395c77 to your computer and use it in GitHub Desktop.
Add more share button to Advisor Quiz WordPress plugin
// Replace this function in your front.php to give customers more share buttons.
function advq_get_after_results_content($id,$data,$options) {
$html = '';
if(isset($data['code_after_results']) && $data['code_after_results'] != ''){
$html .= '<div class="advq_integration_after_results">';
if( $options['render_shortcodes_integration'] ){
$html .= do_shortcode(nl2br($data['code_after_results']));
}
else {
$html .= $data['code_after_results'];
}
$html .= '</div>';
}
if(isset($data['social_sharing']) && $data['social_sharing'] == 1){
$shareresults = isset($data['share_results_label']) ? $data['share_results_label'] : __('Share your results','advq');
$url = add_query_arg( array(
'qid' => $id.'qr'.'{rid}',
//'qresult' => '{rid}',
), advq_get_current_url() );
$urlcopy = str_replace('&', '%26', $url);
$fb_text = '{result} '.get_the_title($id);
$vk_text = '{result} %0A'.get_the_title($id);
$twitter_text = '{result} %0A'.get_the_title($id).': '.$urlcopy;
$linkedin_text = '{result} %0A'.get_the_title($id);
$telegram_text = '{result} %0A'.get_the_title($id).': '.$urlcopy;
$whatsapp_text = '{result} %0A'.get_the_title($id).': '.$urlcopy;
$odnoklassniki_text = '{result} %0A'.get_the_title($id);
$html .='<div class="advq-share"><div class="advq-share-text">'.$shareresults.'</div><div class="advq-share-buttons">';
if(true){ $html .='<div class="advq-share-link advq-fb-link"><a data-social-network="facebook" href="https://www.facebook.com/sharer/sharer.php?u='.urlencode($url).'&text='.$fb_text.'" target="_blank" title="Facebook"><i class="fa fa-facebook-square" aria-hidden="true"></i></a></div>';};
if(true){ $html .='<div class="advq-share-link advq-vk-link"><a data-social-network="vk" href="https://www.vk.com/share.php?url='.urlencode($url).'&title='.$vk_text.'" target="_blank" title="VK"><i class="fa fa-vk" aria-hidden="true"></i></a></div>';};
if(true){ $html .='<div class="advq-share-link advq-twitter-link"><a data-social-network="twitter" href="https://twitter.com/intent/tweet?source='.urlencode($url).'&text='.$twitter_text.'" target="_blank" title="Tweet"><i class="fa fa-twitter" aria-hidden="true"></i></a></div>';};
if(!true){ $html .='<div class="advq-share-link advq-linkedin-link"><a data-social-network="linkedin" href="https://www.linkedin.com/sharing/share-offsite/?url='.urlencode($url).'&title='.$linkedin_text.'" target="_blank" title="Share on Linkedin"><i class="fa fa-linkedin-square" aria-hidden="true"></i></a></div>';};
if(true){ $html .='<div class="advq-share-link advq-telegram-link"><a data-social-network="telegram" href="https://www.t.me/share/url?text='.$telegram_text.'" target="_blank" title="Telegram"><i class="fa fa-telegram" aria-hidden="true"></i></a></div>';};
if(true){ $html .='<div class="advq-share-link advq-whatsapp-link"><a data-social-network="whatsapp" href="https://api.whatsapp.com/send/?text='.$whatsapp_text.'" target="_blank" title="WhatsApp"><i class="fa fa-whatsapp" aria-hidden="true"></i></a></div>';};
if(true){ $html .='<div class="advq-share-link advq-odnoklassniki-link"><a data-social-network="odnoklassniki" href="https://connect.ok.ru/offer?url='.urlencode($url).'" target="_blank" title="Odnoklassniki"><i class="fa fa-odnoklassniki" aria-hidden="true"></i></a></div>';};
$html .='</div></div>';
}
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment