<commit_before><?php
/**
 * Template Name: Accept Badge
 *
 */

get_header(); // Loads the header.php template. 
//Getting the filename and the id from the url
        if(isset( $_GET['filename']) && ($_GET['id']) ){
            $path_json = $_GET['filename']; //Gets the encoded Json Path
            $path_json = base64_decode(str_rot13($path_json)); //Decodes the path
            $badge_name=$_GET['id'];
            b4l_save_badge_user_profil($path_json);
        }
        ?>
        <!-- Issuer API script (OpenBadges backpack) -->
        <script src="https://backpack.openbadges.org/issuer.js"></script>
        <script type="text/javascript">
            //Function for issuing the badge
            jQuery(document).ready(function($) {
                $('.js-required').hide();
                //Checks the navigator because the Issuer API isn't supported on MSIE Browsers
                if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){  
                    $('.acceptclick').hide();
                    $('.browserSupport').show(); //Writes an error message
                }else{
                    $('.browserSupport').hide();
                }
                $('#badge-error').hide();
                $('.acceptclick').click(function() {		
                    var assertionUrl = '<?php echo $path_json; ?>';
                    OpenBadges.issue([''+assertionUrl+''], function(errors, successes) {
                        if (errors.length > 0 ) {
                            $('#badge-error').show(); //Displays an error message
                            $.ajax({
                                url: '<?php get_post_type_archive_link( 'badge' ); ?>',
                                type: 'POST',
                                data: { 
                                    action:'award_action'
                                }
                            });
                        }

                        if (successes.length > 0) {
                            $('.acceptclick').hide();
                            $('#badge-error').hide();
                            $.ajax({
                                url: '<?php get_post_type_archive_link( 'badge' ); ?>',
                                type: 'POST',
                                data: { 
                                    action:'award_action'
                                }
                            });
                        }	
                    });    
                });
            });
       </script>
   
        
        <div id="bsp-award-actions-wrap">
            <div id="badgeSuccess">
                <h2>Congratulations! The "<?php echo $badge_name; ?>" badge has been awarded to you.</h2>
		        <!-- Just registered users can get the badge -->
				
				<?php
				if ( !is_user_logged_in() )  : // Message for non logged in users.?>
				    <h2>Remember, just registered users can accept the badge. <a title="Log in" href="http://badges4languages.com/wp-login.php">Log in</a> or <a title="open an account" href="http://badges4languages.com/wp-login.php?action=register">open an account</a>.</h2>
				<?php endif; ?>
				
				<?php if( rcp_is_active() )  : // Active link for winners of a badge.?>
					<h2 class="acceptclick">Please <a href='#' class='acceptclick'>accept</a> the award.</h2>
				<?php endif; ?>
				
            </div>
        </div>
        <div class="browserSupport">
            <p><span style="background-color: #f78181;"><strong>Microsoft Internet Explorer is not supported at this time. Please use Firefox or Chrome to retrieve your award.</strong></span></p>
        </div>
        <div id="badge-error">
            <p><span style="background-color: #f78181;"><strong>An error occured while adding this badge to your backpack.</strong></span></p>
        </div>
    
    
    <?php get_footer(); // Loads the footer.php template. ?>
       <?php
    
    
    /**
 * Save the data from the JSON file which is saved in the Wordpress server to 
 * display them on the user profile.<commit_msg>default wp for logged in in template<commit_after><?php
/**
 * Template Name: Accept Badge
 *
 */

get_header(); // Loads the header.php template. 
//Getting the filename and the id from the url
        if(isset( $_GET['filename']) && ($_GET['id']) ){
            $path_json = $_GET['filename']; //Gets the encoded Json Path
            $path_json = base64_decode(str_rot13($path_json)); //Decodes the path
            $badge_name=$_GET['id'];
            b4l_save_badge_user_profil($path_json);
        }
        ?>
        <!-- Issuer API script (OpenBadges backpack) -->
        <script src="https://backpack.openbadges.org/issuer.js"></script>
        <script type="text/javascript">
            //Function for issuing the badge
            jQuery(document).ready(function($) {
                $('.js-required').hide();
                //Checks the navigator because the Issuer API isn't supported on MSIE Browsers
                if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){  
                    $('.acceptclick').hide();
                    $('.browserSupport').show(); //Writes an error message
                }else{
                    $('.browserSupport').hide();
                }
                $('#badge-error').hide();
                $('.acceptclick').click(function() {		
                    var assertionUrl = '<?php echo $path_json; ?>';
                    OpenBadges.issue([''+assertionUrl+''], function(errors, successes) {
                        if (errors.length > 0 ) {
                            $('#badge-error').show(); //Displays an error message
                            $.ajax({
                                url: '<?php get_post_type_archive_link( 'badge' ); ?>',
                                type: 'POST',
                                data: { 
                                    action:'award_action'
                                }
                            });
                        }

                        if (successes.length > 0) {
                            $('.acceptclick').hide();
                            $('#badge-error').hide();
                            $.ajax({
                                url: '<?php get_post_type_archive_link( 'badge' ); ?>',
                                type: 'POST',
                                data: { 
                                    action:'award_action'
                                }
                            });
                        }	
                    });    
                });
            });
       </script>
   
        
        <div id="bsp-award-actions-wrap">
            <div id="badgeSuccess">
                <h2>Congratulations! The "<?php echo $badge_name; ?>" badge has been awarded to you.</h2>
		        <!-- Just registered users can get the badge -->
				
				<?php
				if ( !is_user_logged_in() )  : // Message for non logged in users.?>
				    <h2>Remember, just registered users can accept the badge. <a title="Log in" href="http://badges4languages.com/wp-login.php">Log in</a> or <a title="open an account" href="http://badges4languages.com/wp-login.php?action=register">open an account</a>.</h2>
				<?php endif; ?>
				
				<?php 
				if ( is_user_logged_in() )  :  // Active link for winners of a badge.?>
					<h2 class="acceptclick">Please <a href='#' class='acceptclick'>accept</a> the award.</h2>
				<?php endif; ?>
				
            </div>
        </div>
        <div class="browserSupport">
            <p><span style="background-color: #f78181;"><strong>Microsoft Internet Explorer is not supported at this time. Please use Firefox or Chrome to retrieve your award.</strong></span></p>
        </div>
        <div id="badge-error">
            <p><span style="background-color: #f78181;"><strong>An error occured while adding this badge to your backpack.</strong></span></p>
        </div>
    
    
    <?php get_footer(); // Loads the footer.php template. ?>
       <?php
    
    
    /**
 * Save the data from the JSON file which is saved in the Wordpress server to 
 * display them on the user profile.
{'fraction_non_alphanumeric': 0.1413096996553422, 'fraction_numerical': 0.006154603643525357, 'mean_word_length': 1.4038461538461537, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 103, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2956459', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2089, 'n_words': 521}