• Resolved vascogomes

    (@vascogomes)


    WordPress version 6.7.2
    Active theme: Newspaperup (version 1.1.7)
    Current plugin: EXMAGE – WordPress Image Links (version 1.0.22)
    PHP version 7.4.33 Error Details

    An error of type E_ERROR was caused in line 94 of the file /home/public/wp-content/plugins/exmage-wp-image-links/exmage-wp-image-links.php. Error message: Uncaught Error: Call to undefined function get_current_screen() in /home/public/wp-content/plugins/exmage-wp-image-links/exmage-wp-image-links.php:94
    Stack trace: 0 /home/public/wp-includes/class-wp-hook.php(324): EXMAGE_WP_IMAGE_LINKS->filter_exmage_in_library_page() 1 /home/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() 2 /home/public/wp-includes/plugin.php(565): WP_Hook->do_action() 3 /home/public/wp-includes/class-wp-query.php(1881): do_action_ref_array() 4 /home/public/wp-includes/class-wp-query.php(3852): WP_Query->get_posts() 5 /home/public/wp-includes/post.php(2541): WP_Query->query() 6 /home/public/wp-content/plugins/jetpack/modules/memberships/class-jetpack-memberships.php(877): get_posts() 7 /home/public/wp-content/plugins/jetpack/extension

Viewing 5 replies - 1 through 5 (of 5 total)
  • Kerk en IT

    (@kerkenit)

    I editen this file wp-content/plugins/exmage-wp-image-links/exmage-wp-image-links.php

    I replaced line 94 with ?$screen = false;//get_current_screen(); because get_current_screen() is missing. The site works again

    • This reply was modified 1 month ago by Kerk en IT. Reason: Wrong line number
    samysalahgad

    (@samysalahgad)

    public function filter_exmage_in_library_page( $query ) {
    if (!is_admin() || !function_exists(‘get_current_screen’)) {
    return;
    }

    $screen = get_current_screen();
    if ($screen && $screen->base === 'upload') {
        if (isset($_REQUEST['exmage_filter'])) {
            $exmage_filter = sanitize_text_field($_REQUEST['exmage_filter']);
            $meta_query = [];
    
            switch ($exmage_filter) {
                case 'only_downloaded':
                    $meta_query = [
                        'relation' => 'AND',
                        [
                            'key'     => '_exmage_external_url',
                            'compare' => 'EXISTS',
                        ],
                        [
                            'key'     => '_exmage_imported',
                            'compare' => 'EXISTS',
                        ]
                    ];
                    break;
                case 'only_undownloaded':
                    $meta_query = [
                        'relation' => 'AND',
                        [
                            'key'     => '_exmage_external_url',
                            'compare' => 'EXISTS',
                        ],
                        [
                            'key'     => '_exmage_imported',
                            'compare' => 'NOT EXISTS',
                        ]
                    ];
                    break;
                default:
                    $meta_query = [
                        'relation' => 'OR',
                        [
                            'key'     => '_exmage_external_url',
                            'compare' => 'EXISTS',
                        ],
                        [
                            'key'     => '_exmage_imported',
                            'compare' => 'EXISTS',
                        ]
                    ];
                    break;
            }
    
            $query->set('meta_query', $meta_query);
        }
    }

    }

    Thread Starter vascogomes

    (@vascogomes)

    @samysalahgad what is that?

    The recent update actually crashed websites.
    so the issue is with the way the get_current_screen() is called.

    get_current_screen() is only available to admin session.


    $screen = get_current_screen();
    if (is_admin() && $screen && $screen->base === 'upload') {

    The above is the way the recent update did the implementation – called get_current_screen() before checking is_admin().
    I made the adjustment below (doing the is_admin() check before calling the get_current_screen()).

    if(is_admin()){
    $screen = get_current_screen();
    if($screen && $screen->base === 'upload') {
    ....
    }
    }
    Plugin Support angelagrey

    (@angelagrey)

    Hi guys,

    Thank you for reaching out to us.

    We just updated this plugin addressing the error. Can you please pull the latest version and try again?

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.