123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- <?php
- if (!class_exists("plug_login")) {
- class plug_login {
- function __construct($ns) {
- $this->title = __("Login", "dagsopt");
- $this->pluginname = $ns->pluginname;
- $this->file = $ns->file;
- $this->ns = $ns;
- }
- function start() {
- add_action('init', array(&$this, 'override_reset_password_form_redirect'));
- add_filter('login_headerurl', array(&$this, 'login_headerurl'));
- add_filter('login_headertext', array(&$this, 'login_headertext'));
- add_filter('login_message', array(&$this, 'login_message'));
- add_action('register_form', array(&$this, 'plugin_form'));
- if (defined("WP_SITEURL") && defined('WP_SITEURL_CDN')) {
- add_filter('stylesheet_directory_uri', array(&$this, 'l_stylesheet_directory_uri'));
- }
- add_action('login_head', array(&$this, 'login_head'));
- add_action('admin_enqueue_scripts', function () {
- /*
- if possible try not to queue this all over the admin by adding your settings GET page val into next
- if( empty( $_GET['page'] ) || "my-settings-page" !== $_GET['page'] ) { return; }
- */
- wp_enqueue_media();
- });
- add_filter('upload_mimes', function ($mime_types) {
- $mime_types['svg'] = 'image/svg+xml'; // Adding .svg extension
- $mime_types['json'] = 'application/json'; // Adding .json extension
- // unset( $mime_types['xls'] ); // Remove .xls extension
- // unset( $mime_types['xlsx'] ); // Remove .xlsx extension
- return $mime_types;
- }, 1, 1);
- add_action('admin_footer', function () {
- /*
- if possible try not to queue this all over the admin by adding your settings GET page val into next
- if( empty( $_GET['page'] ) || "my-settings-page" !== $_GET['page'] ) { return; }
- */
- ?>
- <script>
- jQuery(document).ready(function($){
- $(".uploadbutton").click(function(e){
- e.preventDefault();
- var self = $(this);
- var target = jQuery('.valuereciever', self.parent())
- var preview = jQuery('img', self.parent())
- var custom_uploader;
- if (custom_uploader) {
- custom_uploader.open();
- return;
- }
- custom_uploader = wp.media.frames.file_frame = wp.media({
- title: 'Choose Image',
- button: {
- text: 'Choose Image'
- },
- multiple: false
- });
- custom_uploader.on('select', function() {
- attachment = custom_uploader.state().get('selection').first().toJSON();
- console.log(attachment);
- target.val("/"+attachment.url.split("/").slice(3).join("/"));
- preview.attr("src", target.val() );
- });
- custom_uploader.open();
- })
- /* var custom_uploader
- , click_elem = jQuery('.uploadbutton')
- , target = jQuery('.valuereciever', click_elem.parent())
- click_elem.click(function(e) {
- e.preventDefault();
- //If the uploader object has already been created, reopen the dialog
- if (custom_uploader) {
- custom_uploader.open();
- return;
- }
- //Extend the wp.media object
- custom_uploader = wp.media.frames.file_frame = wp.media({
- title: 'Choose Image',
- button: {
- text: 'Choose Image'
- },
- multiple: false
- });
- //When a file is selected, grab the URL and set it as the text field's value
- custom_uploader.on('select', function() {
- attachment = custom_uploader.state().get('selection').first().toJSON();
- console.log(attachment);
- target.val("/"+attachment.url.split("/").slice(3).join("/"));
- });
- //Open the uploader dialog
- custom_uploader.open();
- });
- */
- });
- </script>
- <?php
- });
- }
- function override_reset_password_form_redirect() {
- $action = isset($_GET['action']) ? $_GET['action'] : '';
- $key = isset($_GET['key']) ? $_GET['key'] : '';
- $login = isset($_GET['login']) ? $_GET['login'] : '';
- if ('wp-login.php' === $GLOBALS['pagenow'] && ('resetpass' == $action)) {
- if (isset($_POST['wp-submit']) && $_POST['wp-submit'] == "Reset Password") {
- foreach ($_COOKIE as $key => $value) {
- if (stristr($key, "wp-resetpass")) {
- $v = explode(":", $value);
- $login = array_shift($v);
- }
- # code...
- }
- //print_r($GLOBALS);
- //wp_redirect(site_url('/wp-login.php') . '?action=welcome&user_login=' . $login);
- //exit;
- }
- }
- }
- function l_stylesheet_directory_uri($t) {
- return str_replace(WP_SITEURL, WP_SITEURL_CDN, $t);
- }
- function login_headerurl($t) {
- return "/";
- }
- function login_headertext($t) {
- return "Til forsiden";
- }
- function login_message($t) {
- $login = "";
- foreach ($_COOKIE as $key => $value) {
- if (stristr($key, "wp-resetpass")) {
- $v = explode(":", $value);
- $login = array_shift($v);
- }
- }
- $str = '<style type="text/css">
- body {
- background-size: cover;
- background-position: center center;
- background-image: url(' . stripslashes(get_option($this->pluginname . "_login_background_image")) . ');
- }
- .login h1 a {margin-top:-50px;padding-bottom: 5px; width: auto; height: 110px; background-size: auto; background-image: url(' . stripslashes(get_option($this->pluginname . "_login_image")) . ');}
- .login_holder {
- margin-top: 20px;
- margin-left: 0;
- padding: 26px 24px 46px;
- font-weight: 400;
- overflow: hidden;
- background: #fff;
- border: 1px solid #ccd0d4;
- box-shadow: 0 1px 3px rgb(0 0 0 / 4%);
- }
- </style>
- <script type="text/javascript">
- jQuery(document).ready(function($){
- var qq = {};
- $.each(document.location.search.substr(1).split("&"),function(c,q){
- var i = q.split("=");
- qq[i[0].toString()] = i[1].toString();
- });
- if(qq.action=="resetpass"){
- setTimeout(function(){
- window.location.href="/wp-login.php?action=welcome&user_login=' . $login . '"
- },500)
- }else{
- $("#user_login").val(qq["user_login"]);
- }
- })
- </script>
- <div class="login_holder">
- <p>';
- if (isset($_GET['action'])) {
- $str .= get_option($this->pluginname . "_login_support_splash_" . $_GET['action'], false);
- } else {
- $str .= get_option($this->pluginname . "_login_support_splash", false);
- }
- $str .= '</p></div>';
- return $str;
- }
- function help() {
- ?>
- <?php echo (__("Adds logo to login page", "dagsopt")) ?>
- <a href="/wp-login.php"><?php echo (__("Login page", "dagsopt")) ?></a>
- <?php
- }
- function login_head() {
- // $type = (empty($_REQUEST['type']) || !($_REQUEST['type'] == "Select" || $_REQUEST['type'] == "Pro")) ? "Select" : $_REQUEST['type'];
- $type = "Perspektiv";
- if ($type !== "") {
- ?>
- <script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- if(jQuery("form").attr('action').indexOf('register')>-1){
- jQuery("form").prepend('<h3>Ræson <?php echo ($type) ?></h3><br>');
- jQuery("p:contains('Brugernavn')").hide();
- jQuery("#user_email").attr("tabindex","24")
- jQuery("#r_navn").attr("tabindex","25")
- jQuery("#r_membership").attr("tabindex","26")
- jQuery("#wp-submit").attr("tabindex","27")
- var t = (jQuery('#login_error').html())+"";
- var a = t.split("\n");
- if(a.length && a[0].indexOf('brugernavn')>-1){
- a.shift();
- jQuery('#login_error').html(a.join("\n"));
- }
- jQuery("#user_login").hide();
- jQuery('label[for="user_login"]').hide();
- jQuery('#wp-submit').click(function(){
- console.log("SEND");
- jQuery('#user_login').val(jQuery('#user_email').val());
- });
- }
- });
- </script>
- <?php
- }
- ?>
- <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory');?>/style2.css">
- <?php
- }
- function plugin_form() {
- $type = "Perspektiv"; //;(empty($_REQUEST['type']) || !($_REQUEST['type'] == "Select" || $_REQUEST['type'] == "Pro")) ? "Select" : $_REQUEST['type'];
- //19094 __system_side_medlem_af
- //$tt = get_post( 19094);
- //print_r($_REQUEST);
- //$arra = explode("<hr>","".$tt->post_content);
- //$listen = array_pop($arra);
- $content = get_option($this->pluginname . "_login_groups", false) . "::::" . ($this->pluginname . "_login_groups");
- //$arr = explode("\n","".$listen);
- $arr = explode("\n", get_option($this->pluginname . "_login_groups", false));
- $sel = '<select name="r_membership" id="r_membership" class="input nnl" tabindex="26">';
- $sel .= '<option ' . ((!isset($_POST['r_membership']) || $_POST['r_membership'] === "") ? "selected" : "") . '>Vælg gruppe</option>';
- foreach ($arr as $ii => $title) {
- if (strlen($title) > 3) {
- $sel .= '<option value="' . $title . '" ' . ($_POST['r_membership'] === $title ? "selected" : "") . '>' . $title . '</option>';
- }
- }
- $sel .= '</select>';
- $html = '
- <style type="text/css">
- .nnl {
- background:#FBFBFB none repeat scroll 0 0;
- border:1px solid #E5E5E5;
- font-size:20px;
- margin-bottom:16px;
- margin-right:6px;
- margin-top:2px;
- padding:3px;
- width:97%;
- }
- </style>
- <div width="100%">
- <div>
- ' . $content . '
- </div>
- <input type="hidden" name="r_proselect" id="r_proselect" value="' . $type . '">
- <p>
- <label style="display: block; margin-bottom: 5px;">' . __('Navn', 'Navn') . '
- <input type="text" name="r_navn" id="r_navn" class="input nnl" value="' . $_POST['r_navn'] . '" size="20" tabindex="25" />
- </label>
- </p>
- <p>
- <label style="display: block; margin-bottom: 5px;">' . __('Medlem af', 'Medlem af') . '
- ' . $sel . '
- </label>
- </p>
- </div>
- ';
- echo $html;
- }
- function Option($pre) {
- update_option($pre . '_support_splash', $_POST[$pre . '_support_splash']);
- update_option($pre . '_support_splash_rp', $_POST[$pre . '_support_splash_rp']);
- update_option($pre . '_support_splash_welcome', $_POST[$pre . '_support_splash_welcome']);
- update_option($pre . '_support_splash_resetpass', $_POST[$pre . '_support_splash_resetpass']);
- update_option($pre . '_background_image', $_POST[$pre . '_background_image']);
- update_option($pre . '_image', $_POST[$pre . '_image']);
- update_option($pre . '_groups', $_POST[$pre . '_groups']);
- }
- function admin_line($pre) {
- ?>
- <hr>
- <div >
- <div style="width: 300px; height: 100px; overflow: hidden">
- <img height="100" src="<?php echo (stripslashes(get_option($pre . "_image"))); ?>">
- </div>
- <?php echo (__("Login image:", "dagsopt")) ?><br>
- <input type="text" name="<?php echo ($pre . '_image'); ?>" class="valuereciever" value="<?php echo (stripslashes(get_option($pre . "_image"))); ?>" />
- <button class="button uploadbutton">Upload</button>
- </div>
- <div >
- <div style="width: 300px; height: 100px; overflow: hidden">
- <img height="100" src="<?php echo (stripslashes(get_option($pre . "_background_image"))); ?>">
- </div>
- <?php echo (__("Login background image:", "dagsopt")) ?><br>
- <input type="text" name="<?php echo ($pre . '_background_image'); ?>" class="valuereciever" value="<?php echo (stripslashes(get_option($pre . "_background_image"))); ?>" />
- <button class="button uploadbutton">Upload</button>
- </div>
- <hr>
- <?php echo (__("Login splash html:", "dagsopt")) ?><br><textarea style="width: 100%; height: 150px;" name="<?php echo ($pre . '_support_splash'); ?>"><?php echo (stripslashes(get_option($pre . "_support_splash"))); ?></textarea>
- <hr>
- <?php echo (__("Login splash html rp:", "dagsopt")) ?><br><textarea style="width: 100%; height: 150px;" name="<?php echo ($pre . '_support_splash_rp'); ?>"><?php echo (stripslashes(get_option($pre . "_support_splash_rp"))); ?></textarea>
- <hr>
- <?php echo (__("Login splash html welcome:", "dagsopt")) ?><br><textarea style="width: 100%; height: 150px;" name="<?php echo ($pre . '_support_splash_welcome'); ?>"><?php echo (stripslashes(get_option($pre . "_support_splash_welcome"))); ?></textarea>
- <hr>
- <?php echo (__("Login splash html resetpass:", "dagsopt")) ?><br><textarea style="width: 100%; height: 150px;" name="<?php echo ($pre . '_support_splash_resetpass'); ?>"><?php echo (stripslashes(get_option($pre . "_support_splash_resetpass"))); ?></textarea>
- <hr>
- <?php echo (__("Groups", "dagsopt")) ?><br>
- <textarea name="<?php echo ($pre . '_groups'); ?>" rows="7" class="large-text code"><?php echo (stripcslashes(get_option($pre . "_groups"))); ?></textarea>
- <?php
- }
- }
- global $plug_login;
- $plug_login = new plug_login($this);
- $this->dagsopt['plug_login'] = $plug_login;
- }
|