PATH:
home
/
lab2454c
/
archfort.com
/
wp-content
/
themes
/
hello-theme-child-master
<?php /** * Theme functions and definitions * * @package HelloElementorChild */ /** * Load child theme css and optional scripts * * @return void */ function hello_elementor_child_enqueue_scripts() { wp_enqueue_style( 'hello-elementor-child-style', get_stylesheet_directory_uri() . '/style.css', [ 'hello-elementor-theme-style', ], '1.0.0' ); wp_enqueue_style( 'hello-elementor-modal-style', get_stylesheet_directory_uri() . '/modal.css', [], '1.0.0' ); wp_enqueue_script('wp-jquery-cookie', '//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js', array('jquery'), null, true); } add_action( 'wp_enqueue_scripts', 'hello_elementor_child_enqueue_scripts', 20 ); function javascript_variables() { ?> <script type="text/javascript"> var ajax_url = '<?php echo admin_url("admin-ajax.php"); ?>'; var ajax_nonce = '<?php echo wp_create_nonce("secure_nonce_name"); ?>'; var isUser = <?php echo is_user_logged_in()?1:0;?>; var myAccountUrl = '<?php echo site_url('/my-account/');?>'; </script><?php } add_action('wp_head', 'javascript_variables'); add_action('wp_ajax_send_form', 'send_form'); add_action('wp_ajax_nopriv_send_form', 'send_form'); function send_form() { if (empty($_POST["invite_only"])) { echo "Insert your Invite code please"; wp_die(); } if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) { echo 'Insert your email please'; wp_die(); } $invite = $_POST["invite_only"]; if (!empty($invite)) { $generated_code = []; $code = get_field('generate_codes', 'option'); if (!empty($code)) { foreach ($code as $c) { if(!!$c['']){ array_push($generated_code, $c['']); } } } if (in_array($invite, $generated_code)) { echo "success"; } else { echo "Invalid Invite Code"; } } wp_die(); } function show_modal_on_load() { ?> <div id="myModal" class="modal fade" data-bs-keyboard="false" data-bs-backdrop="false"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Invitation</h5> </div> <div class="modal-body"> <?php if ( has_custom_logo() && ( 'title' !== hello_elementor_get_setting( 'hello_header_logo_type' ) || $is_editor ) ){?> <div class="site-logo <?php echo esc_attr( hello_show_or_hide( 'hello_header_logo_display' ) ); ?>"> <?php the_custom_logo(); ?> </div> <?php }?> <div class="invite_form"> <form action="" method="POST" name="invite_codes"> <h5> Sign up with email </h5> <div class="form-group"> <label>Invitation Code: </label> <input type="text" name="invite_only" class="form-control" required> </div> <div class="form-group"> <label>Email Address: </label> <input type="email" name="email" class="form-control" required> </div> <input type="hidden" name="action" value="send_form" style="display: none; visibility: hidden; opacity: 0;"> <button type="submit">Submit!</button> </form> </div> </div> </div> </div> </div> <script> (function($){ window.onload = () => { if(typeof $.cookie('invite_code') === 'undefined' && isUser==0) { $("#myModal").show(); $("#myModal").modal('show'); } if(isUser==0) { $("#myModal").show(); $("#myModal").modal('show'); } } $('form[name="invite_codes"]').on('submit', function() { var form_data = $(this).serializeArray(); form_data.push({ "name": "security", "value": ajax_nonce }); $.ajax({ url: ajax_url, type: 'post', data: form_data, success: function(response) { if (response == 'success') { $.cookie("invite_code", 1, { expires: 7, path: '/' }); $("#myModal").hide(); $("#myModal").modal('hide'); } else { alert(response); } }, fail: function(err) { alert("There was an error: " + err); } }); return false; }); })(jQuery) </script> <?php } add_action( 'wp_footer', 'show_modal_on_load' );
[+]
..
[-] style.css
[edit]
[-] modal.css
[edit]
[-] readme.txt
[edit]
[-] screenshot.png
[edit]
[-] functions.php
[edit]