diff --git a/assets/linkedin.png b/assets/linkedin.png new file mode 100644 index 00000000..6e2f555e Binary files /dev/null and b/assets/linkedin.png differ diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index eea3325f..dfd9ac13 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1394,6 +1394,9 @@ function qmnSocialShare(network, mlw_qmn_social_text, mlw_qmn_title, facebook_id "&" + "link=" + pageUrlEncoded + "&" + "name=" + encodeURIComponent(mlw_qmn_social_text) + "&" + "description="; } + if (network === 'linkedin') { + url = "https://www.linkedin.com/sharing/share-offsite?url=" + encodeURIComponent(mlw_qmn_social_text); + } if (network == 'twitter') { url = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(mlw_qmn_social_text); } @@ -1756,6 +1759,9 @@ jQuery(function () { if (network == 'twitter') { url = "https://twitter.com/intent/tweet?text=" + social_text; } + if (network == 'linkedin') { + url = "https://www.linkedin.com/feed/?text=" + social_text; + } var sTop = window.screen.height / 2 - (218); var sLeft = window.screen.width / 2 - (313); var sqShareOptions = "height=400,width=580,toolbar=0,status=0,location=0,menubar=0,directories=0,scrollbars=0,top=" + sTop + ",left=" + sLeft; diff --git a/php/classes/class-qmn-plugin-helper.php b/php/classes/class-qmn-plugin-helper.php index 41da8402..cca0bd78 100644 --- a/php/classes/class-qmn-plugin-helper.php +++ b/php/classes/class-qmn-plugin-helper.php @@ -642,6 +642,7 @@ public static function get_default_texts() { 'scheduled_timeframe_text' => '', 'twitter_sharing_text' => __('I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!', 'quiz-master-next'), 'facebook_sharing_text' => __('I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!', 'quiz-master-next'), + 'linkedin_sharing_text' => __('I just scored %CORRECT_SCORE%% on %QUIZ_NAME%!', 'quiz-master-next'), 'submit_button_text' => __('Submit', 'quiz-master-next'), 'retake_quiz_button_text' => __('Retake Quiz', 'quiz-master-next'), 'previous_button_text' => __('Previous', 'quiz-master-next'), diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 3ad6a341..11cd5c3f 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -2650,11 +2650,13 @@ public function display_social( $qmn_quiz_options, $qmn_array_for_variables ) { $qmn_social_media_text = array( 'twitter' => $qmn_quiz_options->social_media_text, 'facebook' => $qmn_quiz_options->social_media_text, + 'linkedin' => $qmn_quiz_options->social_media_text, ); } $qmn_social_media_text['twitter'] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text['twitter'], $qmn_array_for_variables ); $qmn_social_media_text['facebook'] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text['facebook'], $qmn_array_for_variables ); - $social_display .= "
quiz_name ) . "', '" . esc_js( $facebook_app_id ) . "');\">Facebookquiz_name ) . "');\">Twitter
"; + $qmn_social_media_text['linkedin'] = apply_filters( 'mlw_qmn_template_variable_results_page', $qmn_social_media_text['linkedin'], $qmn_array_for_variables ); + $social_display .= "
quiz_name ) . "', '" . esc_js( $facebook_app_id ) . "');\">Facebookquiz_name ) . "');\">Twitterquiz_name ) . "');\">Linkedin
"; } return apply_filters( 'qmn_returned_social_buttons', $social_display, $qmn_quiz_options, $qmn_array_for_variables ); } diff --git a/php/classes/class-qsm-install.php b/php/classes/class-qsm-install.php index 6c1fa9d4..869207ef 100644 --- a/php/classes/class-qsm-install.php +++ b/php/classes/class-qsm-install.php @@ -806,7 +806,7 @@ public function register_default_settings() { ), 'default' => 0, /* translators: %FACEBOOK_SHARE%: Facebook share link, %TWITTER_SHARE%: Twitter share link */ - 'tooltip' => __( 'Please use the new template variables instead.%FACEBOOK_SHARE% %TWITTER_SHARE%', 'quiz-master-next' ), + 'tooltip' => __( 'Please use the new template variables instead.%FACEBOOK_SHARE% %TWITTER_SHARE% %LINKEDIN_SHARE%', 'quiz-master-next' ), 'option_tab' => 'legacy', ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_options' ); @@ -1073,6 +1073,27 @@ public function register_default_settings() { ); $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' ); + // Registers linkedin_sharing_text setting + $field_array = array( + 'id' => 'linkedin_sharing_text', + 'label' => __( 'Linkedin Sharing Text', 'quiz-master-next' ), + 'type' => 'editor', + 'default' => 0, + 'variables' => array( + '%POINT_SCORE%', + '%AVERAGE_POINT%', + '%AMOUNT_CORRECT%', + '%TOTAL_QUESTIONS%', + '%CORRECT_SCORE%', + '%QUIZ_NAME%', + '%QUIZ_LINK%', + '%RESULT_LINK%', + '%TIMER%', + '%CURRENT_DATE%', + ), + ); + $mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' ); + // Registers facebook_sharing_text setting $field_array = array( 'id' => 'facebook_sharing_text', diff --git a/php/classes/class-qsm-settings.php b/php/classes/class-qsm-settings.php index 07683343..2b112915 100644 --- a/php/classes/class-qsm-settings.php +++ b/php/classes/class-qsm-settings.php @@ -360,6 +360,7 @@ private function load_settings() { $social_media_text = array( 'twitter' => $quiz_options->social_media_text, 'facebook' => $quiz_options->social_media_text, + 'linkedin' => $quiz_options->social_media_text, ); } @@ -394,6 +395,7 @@ private function load_settings() { 'total_user_tries_text' => $quiz_options->total_user_tries_text, 'twitter_sharing_text' => $social_media_text['twitter'], 'facebook_sharing_text' => $social_media_text['facebook'], + 'linkedin_sharing_text' => $social_media_text['linkedin'], 'previous_button_text' => $pagination_text[0], 'next_button_text' => $pagination_text[1], 'require_log_in_text' => $quiz_options->require_log_in_text, diff --git a/php/template-variables.php b/php/template-variables.php index e03e0d3f..87caf677 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -312,6 +312,14 @@ function mlw_qmn_variable_social_share( $content, $mlw_quiz_array ) { $social_display = "" . __( "; $content = str_replace( '%TWITTER_SHARE%', $social_display, $content ); } + if ( false !== strpos( $content, '%LINKEDIN_SHARE%' ) ) { + $ln_image = plugins_url( '', dirname( __FILE__ ) ) . '/assets/linkedin.png'; + $sharing = $mlwQuizMasterNext->pluginHelper->get_section_setting( 'quiz_text', 'linkedin_sharing_text', '%QUIZ_NAME%' ); + $sharing = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $sharing, "quiz_linkedin_sharing_text-{$mlw_quiz_array['quiz_id']}" ); + $sharing = apply_filters( 'mlw_qmn_template_variable_results_page', $sharing, $mlw_quiz_array ); + $social_display = "" . __( "; + $content = str_replace( '%LINKEDIN_SHARE%', $social_display, $content ); + } return $content; }