• Resolved edward_plainview

    (@edward_plainview)


    Problem: Tablepress is not loaded if on the login page.

    Solution: In the class-tablepress.php file, in the run() function, instead of the “Exit early” return function, add a filter.

    Instead of

    if ( ( 'wp-login.php' === basename( $_SERVER['SCRIPT_FILENAME'] ) ) // Login screen
    			|| ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
    			|| ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
    			return;
    		}

    Perhaps

    $load_tablepress = true;
    if ( ( 'wp-login.php' === basename( $_SERVER['SCRIPT_FILENAME'] ) ) // Login screen
    			|| ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
    			|| ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
    			$load_tablepress = false;
    		}
    $load_tablepress = apply_filters( 'tablepress_should_load', $load_tablepress );
    if ( ! $load_tablepress )
     return;
    

    Why the problem: My plugin, Broadcast, distributes posts across sites in a WP network install, modifying tablepress shortcodes automatically.

    When broadcasting in the background, the queue add-on processes using the login URL.

    The login URL does not allow TablePress to load.

    No loading = unable to find the equivalent table ID for each site.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I’ve actually already added such filter in the upcoming TablePress 2.0, see https://tablepress.org/8-million-downloads-tablepress-2-0/

    The code is similar to yours: https://github.com/TablePress/TablePress/blob/main/classes/class-tablepress.php#L144-L160

    Note that TablePress 2.0 will (in addition to Shortcode) also bring a TablePress table block for the block editor, which might need adjustments then as well.

    One question though: Why are you hitting wp-login.php? That sounds quite weird to me. If you are modifying data on a different site, couldn’t/shouldn’t you maybe post to wp-admin/admin.php or admin-ajax.php? Or actually, why are you doing HTTP requests at all, instead of using the internal APIs (switch_to_blog(), etc.)?

    Regards,
    Tobias

    Thread Starter edward_plainview

    (@edward_plainview)

    Wow, that’s almost exactly the code I have. ??

    The reason for wp-login: the queue can process posts either by ajax or by http request. The HTTP request is for cron jobs, if the user does not want to wait around in admin for hundreds of posts to be

    Cron jobs are not logged in users, and the login page is hit because it forces a load of WordPress each time unlike, say, the front page that could just result in a cache hit and the plugins aren’t loaded.

    Happy with the answer. I’ll sit and wait for v2. And hope that none of my Tablepress users actually use the horrible GB tablepress block.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for the details! Good to hear that the filter hook will help then!

    Can you elaborate why you feel that the Gutenberg TablePress block is “horrible”? I’m always interested in hearing feedback here! Or is this more of a general criticism of the block editor?

    Best wishes,
    Tobias

    Thread Starter edward_plainview

    (@edward_plainview)

    My fault for not being clear! It’s Gutenberg generally, not anything related to TB.

    That “editor” has really messed things up for many of my users. From a normal Word-like editor to something that has visible / invisible blocks everywhere that don’t make any sense to a normal Windows/Mac user.

    An untested alpha version editor that greatly differs from what users are used to, put into core without regarding any user feedback, and going full steam ahead with big changes between each version. Haven’t yet met a user that likes it compared to Tinymce.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for the clarification! Yes, there certainly are shortcomings, but I believe that things have improved greatly over the last couple of releases — at least that’s my take from testing and using it during the development of the TablePress table block and while working on the redesign of the TablePress website that’s coming soon.

    Best wishes,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Allow TB to be loaded with a filter’ is closed to new replies.