Forum Replies Created

Viewing 15 replies - 16 through 30 (of 172 total)
  • Hi,

    First I apologize.
    When I redact the message I was as feeling to answer to caimin_nwl (@caimin_nwl) because the problem is quite symmetric.

    The enhanced code has been added into login with ajax plugin (LWA). So for QM it must be slightly modified to fit the context (the check for example of the ajaxurl).

    I have forgotten a little but essential piece of code : the function which answers and the ajax actions, here is :

        function ajax_check_admin_user_logged_in() {
            $isit = (is_user_logged_in() && is_admin())?'yes':'no';
            // todo ###b80321 the response of ajax contains often other elements, this problem is to solve. Temporarily a filter acts on the string between the delimiters : [ulogbegin]<the answer>[ulogend]
            echo ("[ulogbegin][Check admin user ended with : [".$isit)."]][ulogend]";
            wp_die();
        }
        add_action('wp_ajax_is_admin_user_logged_in', 'ajax_check_admin_user_logged_in');
        add_action('wp_ajax_nopriv_is_user_logged_in', 'ajax_check_admin_user_logged_in'); // For case of a not logged in user (visitor)

    About the subject : is it a very particular case, I can tell this.

    LWA provides a perfect widget for login and there are many users which uses it.

    Then when you are developing QM is a major tools, so I do not think that the situation to have both running is exceptional.

    There is no other condition else than to have to log with the main WP login page (particularly when you reconnect after browser restart on several previously opened admin pages). In such condition there no other solution than mine to reload successfully the right “pages” (several admin urls), this restores the work context (for example remember that you where modifying widgets or menu or…and… when you had to restart accidentally or decide to stop for the night).

    Hi,
    I think that to reproduce is easy.
    Nevertheless I perfectly understand your position regardless this problem, I have the same time use problem.

    Best regards

    Trebly
    _____________________________________________________________________________
    This is the add-on, the js does everything :

    If QM is not present this will have no effect.
    The code js and the css are set into a subdir named “Trebly_login_ext”.

    To add into public static function init() the enque js and css

    // BEGINadd-on by Trebly script and css
                wp_enqueue_script( "trebly-add-on-login", plugin_dir_url( __FILE__ ) . 'Trebly_login_ext/function_login_ext.js', array( 'jquery' ), 'F2-1c5-b80402-1');
                wp_enqueue_style( "trebly-add-on-login", plugin_dir_url( __FILE__ ) . 'Trebly_login_ext/function_login_ext.css', array(), '2.12.1g-b80402');
                // ENDadd-on Trebly
    /**
     * Created by bty-a on 21/03/2018.
     */
    
    // Management of user login
    /*
     The purpose of this section is to manage the case when after displaying the logging page an admin user has been connected by another mean.
     if you fill again the form with admin IDs and query monitor is activated you will get a loop. This is because query monitor will display his results for the new submission, again.
     At a moment you must break the loop.
     This can be done by checking the user connection without submitting the form.
     To check the user connection where going to use an AJAX request.
     If the result is that an admin is connected, then the link "redirect_to (url)" can be used.
     If an admin user is not activated(logged in) the link would lead to a new logging page.
     If query monitor is not activated, after this submission of the form you will reach the redirected_to url.
     But if there are several logging pages you will have to repeat the filling of logging data for each one.
     This is the reason why we have defined to elements added to the logging page:
     - a button to check the user
     - a link to redirect the logging page to the redirect_to url
     With this the user can directly activate the link if he is sure that it is logged in
     Accordingly with the results of the user check the title of the link will be adapted for an accurate warning.
     For now this is added to the plugging query monitor.
     But this could be added to simple login.
     */
    
    (function( $ ) {
    
    $(document).ready(function () {
        if (window.location.href.indexOf("wp-login.php") != -1 && window.location.href.indexOf("%2Fwp-admin") != -1) {
            var data_admin_user_log = {
                action: 'is_admin_user_logged_in' // name of action declared into php ajax function for checking the admin logged in
            };
    
    // some xxT text vars and flag to manage context
            var loggedinT ="";
            var checkuserT = '';
            var isloggedin_admin=false;
            var check_flipflop = false;
            var l_ajaxurl = "";
    
            // var ajaxurl=window.ajaxurl;
           // var ajaxurl=qm_l10n.ajaxurl; /* todo ###b80320 - set a value from wp not necessarily qm_110n to use the function out of qm context in the future */
            if( typeof LWA !== 'undefined' && LWA.ajaxurl !="" ) { l_ajaxurl = LWA.ajaxurl;
            } else {
                alert('Invalid context to use Ajax\n some functions can not to be operational');
            }
    
             /**
             * The function is not used split into the ajax command
             */
            var get_user_status = function() {
                var response = "";
                if (l_ajaxurl !="") {
                    $.post(l_ajaxurl, data_admin_user_log, function(response) {
                        if(response.indexOf('yes')!= -1 ) {
                            // user is logged in
                            loggedinT = "You are logged in as admin : the link \"redirect to\" is activable";
                            alert("Content returned by Ajax request : \n["+ response +']');
                            check_flipflop = !isloggedin_admin; // set to true if isloggedin_admin was false
                            isloggedin_admin=true;
                            checkuserT = " the user has been already checked as admin from here, repeat the check?";
    
                        } else {
                            // user is not logged in
                            loggedinT = "You are not logged in this link cannot be activated it would lead to a new login page (ajax answer is : ["+response+"]";
                            alert("Content returned by Ajax request : ["+ loggedinT+']');
                            check_flipflop = isloggedin_admin; // set to true if isloggedin_admin was true
                            isloggedin_admin=false;
                            checkuserT = " the user has been already checked not as admin from here, repeat the check ?"
                        }
                    });
                } else {
                    alert('Invalid context to use Ajax\nundefined local ajaxurl (l_ajaxurl)\n : unable to get user status');
                }
            };
            /*
             Insert new elements : two buttons and the "redirect_to" link
             */
            // document useful elements
            var loginpanel = document.getElementById("login");
            var backtoblog = document.getElementById("backtoblog");
            var linkback = document.getElementsByName("redirect_to");
            var response ="";
    
            // if (qmdiv !=null && qmwrapper != null && qmtitle0 !=null && linkback != null) {
            if (backtoblog != null && loginpanel != null && linkback != null) {
     
                var loginform0 = document.getElementById('loginform');
                loginform0.style.backgroundColor = "lightgrey";
    
                var warning0 = document.createElement('span');
                warning0.innerHTML = "WARNING : this form cannot be used to login&nbsp;-&nbsp;you must use the \"clean login\" button";
                warning0.className = 'warning0';
                loginpanel.insertBefore(warning0,loginpanel.childNodes[0]);
    
                var loginAddDiv= document.createElement('div');
                loginAddDiv.className = "login-ext-div";
                loginpanel.appendChild(loginAddDiv);
    
                var margin0 = document.createElement('span');
                margin0.innerHTML = "&nbsp;-&nbsp;";
                loginAddDiv.appendChild(margin0);
                // Added b80320 - a button to check the user
     
                var buttonUser0 = document.createElement("button");
                buttonUser0.id = "checkUser0";
                buttonUser0.type = "button";
                buttonUser0.value = "User ?";
                buttonUser0.className = "login-ext-elmts";
                buttonUser0.title = "Check if an admin user is logged in";
                buttonUser0.innerHTML = 'Check User'; //+checkuserT;
                loginAddDiv.appendChild(buttonUser0);
     
                var margin3 = document.createElement('span');
                margin3.innerHTML = "&nbsp;-&nbsp;";
                loginAddDiv.appendChild(margin3);
    // Added b80320-21 - a link to launch the clean login but this doesn't function without explanation (in WP ?) see new version
     
                var linkLogin0 = document.createElement("a");
                linkLogin0.id = "login0";
                linkLogin0.type = "link";
                linkLogin0.href = window.location.href.substr(0,window.location.href.indexOf("?"));
                linkLogin0.target = "_blank" ; // a new tab to not forget the redirect_to link
                linkLogin0.value = "Login";
                linkLogin0.className = "login-ext-elmts";
                linkLogin0.title = "Launches a clean login in a new tab \n note that the current form cannot be used to login";
                linkLogin0.innerHTML = 'Clean login';
                loginAddDiv.appendChild(linkLogin0);
    
                var margin1 = document.createElement('span');
                 margin1.innerHTML = "&nbsp;-&nbsp;";
                loginAddDiv.appendChild(margin1);
    
                var linkback0 = document.createElement("a");
                linkback0.id = "redirect_to";
                linkback0.href = linkback[0].value ;
                linkback0.className = "login-ext-elmts";
                linkback0.innerHTML = 'Back to initial request'; // : testing version with returned string by Ajax ='+"["+response+"]";
                linkback0.remark = "This link can redirect to the original url if an admin user or a user which can see query monitor results\n"+
                    "is logged in and if the link is directed to an accessible target for the a user which has been connected by another mean\n"+
                    "than this login page. If you are not sure about the connection check the current logged in by using the dedicated button";
                // loginpanel.childNodes[1].insertAdjacentElement('beforebegin', linkback0); // added by default at the end of div login
                linkback0.title=linkback0.remark;
                loginAddDiv.appendChild(linkback0);
    
            }
    
            /*
             Action on event on new elements
             */
    
            $("#checkUser0")
                .click(function(the_event){
                    the_event.stopImmediatePropagation();
                    $.post(l_ajaxurl, data_admin_user_log, function(response) {
                        // todo ####b80321 here sanitize and filter ajax response
    
                        // Filter the response
                        const regex = /\[ulogbegin\](.*)?\[ulogend\]/g;
                        m = regex.exec(response);
                        if(m !=null && m[1] != null && m[1].indexOf('[yes]')!= -1 ) {
                            // user is logged in, 
                            alert ('An admin is logged in');
                            loggedinT = "You are logged in as admin : the link \"redirect to\" is activable";
                           // alert("Content returned by Ajax request : \n["+ response +']');
                            check_flipflop = !isloggedin_admin; // set to true if isloggedin_admin was false
                            isloggedin_admin=true;
                            checkuserT = " the user has been already checked as admin from here, repeat the check?";
                            // todo ###b80321 create a button to display the remark
                            linkback0.title = 'The user has been checked here as admin the link can normally be used.\n'+linkback0.remark;
    
                        } else {
                            // user is not logged in,
                            alert("There is no admin user logged in");
                            loggedinT = "You are not logged in this link cannot be activated it would lead to a new login page"; // (ajax answer is : ["+response+"]";
                           // alert("Content returned by Ajax request : ["+ response+']');
                            check_flipflop = isloggedin_admin; // set to true if isloggedin_admin was true
                            isloggedin_admin=false;
                            checkuserT = " the user has been already checked not as admin from here, repeat the check ?" ;
                            linkback0.title = 'The user has NOT been checked here as admin, the link can, may be, not to reach his target.\n'+linkback0.remark;
                        }
                    });
    
                  });
    
            $("#redirect_to")
                .click(function(the_event){
                    if (isloggedin_admin == true){
                        return true;
                    } else {
    
                        if (confirm("BE CAREFUL : You must be logged in as admin to activate this link successfully\n" +
                            "The user as not been checked from this page\nConfirm") == true) {
                            return true;
                        } else {
                            the_event.stopImmediatePropagation();
                            return false;
                        }
                    }
                })
                .hover( function(){
                    if (check_flipflop) { // do something if value have changed
                        if (isloggedin_admin ){
                            $(this)[0].title = loggedinT; // todo ###introduce changing the message for title depending of user status
    
                        } else {
                            $(this)[0].title = loggedinT;
                        }
                    }
                    return true;
                });
            
        } // if url login.php
    });
    
    }) ( jQuery ); /* jQuery */

    To add css file

    /**
    Author : Trebly b80322
     */
    /**
    *      - added style for display of function_login_ext.js : extension of LWA login for login.php page
    */
    
    .login-ext-div { /* the whole div for button and link extend */
        /* No special attributes defined b80322 */
    }
    .warning0 {
        display: block;
        margin-bottom: 2em !important; /* if not should be overlapped by ".login" */
        color: red;
        font-weight: 800;
        text-align: center;
    }
    
    .login-ext-elmts {
        /* uses temporarily the standard to display the button and links into the div .login-ext-div */
    }

    Hi Alex,

    Thanks.

    My idea was exactly to find if this API can give ways to the new features of which I have the concept in my thought.
    In these new feature there is in my opinion an important function which feature is :

    Be able to check if an object managed by UAM (defined by the objects selection list, most types of “posts”) is accessible from a defined point into the code :
    boolean uam_check('access_full', $post) for example.
    This can allow to display just a warning better than to reach the main template with message “you have not access…” for example.
    But another way is a filter which could be used to extend wp function “current_user_can(“view_post”)” when uam is used

    I have others proposals.

    Note that I began the French translation of UAM, it is not so long but I had several hard bugs which made me completely overloaded last weeks, with many things waiting.

    Best regards

    Trebly
    ______________________________________________________________________________
    note : I know well how to translate UI (using poedit) but I don’t know how to translate the whole presentation of the plugin. I just began one month ago to look at developers documentation, but I am currently stopped. I have developed or enhanced several plugins for my own usage and I plan to transform them into operational (for others users) plugin. I will have no time to do it and maintain these plugins so I need to find other developers who would take care of these plugins. I maintain some plugins which are no more supported seriously and which I have integrated into larger plugins, often after a while there were only a few content of the original.

    Hi,

    Thanks for the answer.

    There are many <span style=”display:none” or class=”…”> which class have attribute display:none.

    Evermore there are current plugins (that I do not control) which uses elements hidden using display:none.

    There are scripts which hide elements dynamically using (JQuery) display:none;

    It is not possible to change everything in these pieces of code to fit your specifications.

    I think that the solution should be inverted, there should be three cases :

    • any element with display:none is not printed by default
    • an element which is not displayed normally at screen would have either :
      • a class with an attribute display:<something> into a @device print {}containing the right display attribute
      • print can be forced by class “print-yes” class
    • an element which is displayed normally at screen can be hidden to print either
      • using class “print-no”
      • by block @device print {} containing the right display attribute

    So, in my opinion, your solution is crippling for a normal and standard usage.

    Best regards

    Trebly

    Hi,

    Sorry, I have not found the API documentation into Github repository.

    Note : I began the French translation.

    I have submitted two enhancement proposals on WP support.
    I began a “objects model” to explain UAM features and for which I uses a text that I have written as answer to a user eval (1 star) on the support forum,the title of this text (and an svg drawing) could be “for understanding UAM basic concepts”.

    Best regards

    Trebly

    Hi,

    Did you read my message ?

    note : I uses Chrome.

    Is-it a problem to reply to my question ?

    There is a true problem and a partial solution found.

    I have a quick summary :

    • When after a crash an admin url is submitted (automatic by browser context restauration) the “login page is displayed. In this case, because QM is defined to operate only with admin user, QM is not activated and doesn’t display any report
    • When you login from the previous “login page”, normally, if successful, you are redirected the the admin page which url was given to the browser at beginning. But because QM is then activated (login successful) QM report is loaded and the redirection is not performed. Then you get a “login page” from which nothing can be done : new try with the login submit will fail and in fact will disconnect you while you were logged in ; and there is no way to redirect while (verified) you are connected. It is a dead lock (for the current tab and all others tab which display at same time this same login page unusable).

    In this are implicated :

    • WP login process
    • QM : the alone case which breaks the login page redirection and for which WP login page cannot function. Practically if the login doesn’t use “Login with Ajax” QM report is never displayed (the redirection is performed before QM report can be displayed)
    • Plugin login with Ajax which can workaround the problem

    I have developed an add-on to LWA which allows to redirect to original url. This solves the problem for me but it remains alive, I ma sure of this, for others WP users who uses simultaneously LWA and QM.

    Best regards

    Trebly
    _________________________________________________________________________________
    note : The previous message was very long because I had not found the exact problem. It is not simple to solve such a problem fully alone.

    Hi,

    Did you read my message ?

    note : I uses Chrome.

    Is-it a problem to reply to my answer ?

    Best regards

    Trebly

    Hi,

    I have not found the problem but solved temporarily and got back my data.

    The record “sidebars_widgets” was shortened (not truncated) and exactly all “widget_enhancedtextwidget” had been suppressed.

    I got the same record from a very recent back-up and found that it was ok (by reading json data), so I replaced it and everything goes back right. I got back my widgets.

    The problem is : how and why this could happen. I never had this. There is a true problem either with ajax update, either with “widget_enhancedtextwidget” which could produce the deletion of their description from the record “sidebars_widgets”

    I think it is necessary to find the reason but I am not in the position to do it(knowledge and contacts into the WP community, even I write a lot of messages and I have developed or enhanced several plugins but which are not registered nor packaged) .

    Best regards

    Trebly

    Hi,

    I have checked the database, into table “wp_otions” the option_name “widget_enhancedtextwidget” is present with all the widgets and the right values for the content.

    Then the problem is why these widget doesn’t appear into my widgets special sidebar. The others widgets of this sidebar appear there are only widget_enhancedtextwidget which disappeared.

    Best regards, hope a quick answer

    Trebly

    Hi,

    This morning I tried again and then I got a display.

    I could verify that when you get this new url with the “#” as hash (without “?” query) if you click inside the viewport you can get the waited preview loaded from your site.
    I have too made an inspection of the html contents loaded and found scripts and styles (css) elements.

    My temporary conclusion is that you get the waited display of the print preview if your server answers immediately. But if this is not immediate (or very long the user can’t understand) the display is the precedent (of the user for which a print is requested).

    I think that a message should be displayed if this step is reached, and invite to repeat by a click into the viewport or more clearly a button “repeat call to print function”.

    I have not found a mean to change this because the user has not the control of this content.

    May be the cause of the phenomenon is that I have a very reactive line and server. Nevertheless such circumstances “print server doesn’t answer until now” should produce a display to guide the user.

    Best regards.

    Note : because I begin tests of printfriendly I have several question that I separate. It is not harassment, just a phase in which all questions come at same time.

    • This reply was modified 1 year, 10 months ago by Trebly.

    Hi,

    Not a bug.

    I found the reason. The values are inherited from category rights, so they cannot be modified directly. This is not not so much clear (French version) : should probably translate the right description which could be simply “inherited from category” which have given in French “Appartenance donnée à un groupe par catégorie” this words need a good time to understand (not understandable in French and no immediate translation, need to tell to oneself “what is the meaning of this”), the whole given into information box.

    Best regards

    Trebly

    Note : documentation about this, where ?

    Hi,

    The problem is solved.
    It was a memory problem which occurs when both plugins are loaded.
    With the presence of Yoast and of my plugin I get an exhausted memory (I could find it quicker if I had not missed a log).

    This was coming from my plugin, it analyses most outputs to generate a popup widget which gives a way to quickly reach any header (tag Hx) found into most of ouputs.
    For a reason that I have not yet analysed, if Yoast is enabled when the particular function of the plugin is submitted the analyse sends a request of memory which was just upper the maximum heap which can be allocated on the server. And it is launched for an exam of the ob (should filter better the <body>) at the end of whole process (this occurs just before ajax response to request).

    I have inactivated the function in this case for the moment and I will later integrate overload memory catch exception.

    After two hours of search into post-edit HTML sources, I couldn’t find anything.
    But when I reset and launched and exam short logs, I found quickly.

    Best regards
    Trebly
    ________________________________________________________
    note :
    PhpStrom has some difficulties with the “<# … #> and misses some tags which creates “false errors”

    When all plugins are inactivated the problem disappears.
    I have found the involved plugin which creates the incompatibility.
    For this I used inactivation by dichotomy (63 plugins).

    But the problem is not solved at all because this plugin, which I need absolutely, has no code loaded and no action in backend. I am the author. It creates frontend tables of content of posts. The theme has an important js loaded for frontend management (widely enhanced from twentythirteen).

    So, for now, I don’t understand at all how the plugin or the theme for which no code is loaded (nor anything visible in debugger) and which has no local js code loaded can if activated create a problem. I have no idea for the moment about how to find a solution. There is nothing to track…

    I am going to try to compare the whole HTML content and DOM with and without the plugin activated.
    Best regards

    Hi,

    I have done it before seing this message but the result is the same.

    So for now because I can’t edit post, I have inactivated Yoast SEO.

    Last time I had a conflict, I inactivate all plugins and activate again till a problem was found this have needed one month of work, and one year after I have still some problem. The reason, while you are debugging there are upgrades with new incompatibilities.

    I have one which has been found nine month ago and still not solved. But for this I had to develop an add-on to a plugin : I used three days to write myself a workaround.

    For this problem, I am quite sure to find the solution by using a more efficient way.

    The most probable is that the query of the url is set to null somewhere. This happens commonly when vars are not encapsulated into objects, with “public” vars of scripts and doubled names into separate scripts.

    The problem is simple to solve, the steps of thoughts are :

    • The “update command” is not (well) executed and the url is truncated during this phase (new window.location has no more the query part).
    • This means that the update of the post is not submitted : an error occurs before
    • The window.location reset fails because an empty query (empty value) in into the url
    • This occurs only when Yoast is used and with an error on a json stored value which should never be empty for Yoast…

    With this (vars names) it is easy to track the error with the debugger and a good code editor.

    But for this I need the extended js code which will give me the name of the var. After I am sure that it is not long to find the conflict.

    But while I was going to get the involved extended js code of Yoast and execute from it, I could not find where it is accessible. The repository seems to contain only the minified js.

    Please help me.

    Best regards

    Trebly

    Note : the conflict check didn’t give result.

    Hi,

    I am quite sure that you can reproduce it.

    1. activate login with ajax
      • activate query monitor
      • load as admin the admin mainboard (or any page)
      • disconnect the browser (restart computer or simply cancel the browser task)
      • restart the browser and tell it to restore “closed tabs on crash”

    This should produce that the previous admin board will display necessarily the main login page (the admin is disconnected by the close of the browser).

    1. Give your credentials ad admin : id and pswd and submit
      • If query monitor is not activated you are then directed to the ancient url succesfully, but if query monitor is activated the login page a displayed again and you can find at bottom of page the report of QM

    After this second step : try to load your ancient url from this point and from this login page. You will not be able to do it.

    If this point is not reached, tell me, I will send you short url to download a short video which shows this and after the tries to connect as admin from this login page which fails.

    Best regards

    Trebly

Viewing 15 replies - 16 through 30 (of 172 total)