• Resolved cuppa500

    (@cuppa500)


    I think I have WordPress version 4.8.3, (latest version) but can’t check as I cannot access my admin page.

    I updated the Travelmap plugin today & since then all attempts to access my admin page get the following error message. I think the update was released just today.

    Parse error: syntax error, unexpected ‘[‘, expecting ‘)’ in /home/content/c/u/p/cuppa500/html/Blog/wp-content/plugins/travelmap-blog/admin/class-travelmap-admin.php on line 103

    I have located the file ‘class-travelmap-admin.php’ on my godaddy website
    & line 103 reads as follows:

    $string .= substr(str_replace([‘/’, ‘+’, ‘=’], ”, base64_encode($bytes)), 0, $size);

    I have no idea what a parse or syntax error is, but assume there is something wrong in line 103. It appears I may be able to edit it directly on my host’s site but to do so need to know what to change. Can anyone see what is wrong?

    At this stage I would be very happy just to revert to the previous version of the plugin & get my admin page (& map) back again, but if all that is needed is a minor change to line 103 & doing so on my godaddy site would achieve that, that would be fine too.

    If editing the line on my Godaddy files site is a bad idea ….. please let me know how else to get my site back asap.

    Thank you for your help.
    Cuppa.

    ps. In case it helps the following is the entire class-travelmap-admin.php file

    <?php if ( !defined( ‘ABSPATH’ ) ) { exit; }

    define(‘TRAVELMAP_ADMIN_PARTIALS_DIR’, plugin_dir_path( __FILE__ ).’partials/’);

    class TravelMap_Admin
    {
    public function __construct()
    {
    // Scripts
    add_action(‘admin_enqueue_scripts’, array($this, ‘enqueue_admin_scripts’));

    // Menu
    add_action(‘admin_menu’, array($this, ‘add_admin_menu’), 20);
    }

    public function enqueue_admin_scripts()
    {
    wp_enqueue_style(
    ‘travelmap’, // handle
    plugin_dir_url( __FILE__ ).’css/travelmap-admin.css’, // src
    null, // dependencies
    false, // version
    ‘all’ // media query
    );
    }

    public function add_admin_menu()
    {
    if ( !current_user_can(‘manage_options’) ) {
    return;
    }
    add_menu_page(
    ‘TravelMap’, // Page Title
    ‘TravelMap’, // Menu Title
    ‘manage_options’, // Capability
    ‘travelmap’, // Menu Slug
    array($this, ‘admin_page_html’), // Display function,
    $this->get_admin_svg_icon(), // Icon
    39 // Menu Position
    );
    }

    public function get_admin_svg_icon()
    {
    $svg = file_get_contents(plugin_dir_path( __FILE__ ).’images/travelmap.svg’);

    return ‘data:image/svg+xml;base64,’ . base64_encode($svg);
    }

    public function admin_page_html()
    {
    // Remove footer text
    add_filter( ‘admin_footer_text’, array($this, ‘clear_admin_footer’) );

    // Iframe URL
    $iframe_url = $this->get_admin_page_url();

    // Template
    include( TRAVELMAP_ADMIN_PARTIALS_DIR.’travelmap-admin-page.php’ );
    }

    public function clear_admin_footer()
    {
    return ”;
    }

    public function get_admin_page_url()
    {
    // User id
    $wp_user_id = $this->get_user_id();

    // Locale
    $locale = get_locale();
    if ( $locale )
    $locale = substr($locale, 0, 2);

    // URL
    return TRAVELMAP_WP_URL.’?’.TRAVELMAP_WP_USER_KEY.’=’.$wp_user_id.’&locale=’.$locale;
    }

    public function get_user_id()
    {
    $wp_user_id = get_option( TRAVELMAP_WP_USER_KEY );

    if ( !$wp_user_id )
    {
    $wp_user_id = $_SERVER[‘HTTP_HOST’].’-‘.$this->str_random( TRAVELMAP_WP_USER_LENGTH );
    add_option( TRAVELMAP_WP_USER_KEY, $wp_user_id );
    }

    return $wp_user_id;
    }

    public function str_random($length = 16)
    {
    $string = ”;

    while (($len = strlen($string)) < $length) {
    $size = $length – $len;

    $bytes = random_bytes($size);

    $string .= substr(str_replace([‘/’, ‘+’, ‘=’], ”, base64_encode($bytes)), 0, $size);
    }

    return $string;
    }

    }

    new TravelMap_Admin();

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter cuppa500

    (@cuppa500)

    Problem was my web host provides an older version of PHP which was not compatible with the update. Author of the plugin has been very helpful & made a new update compatible with my version of PHP. All is back up & working. Phew!

Viewing 1 replies (of 1 total)
  • The topic ‘udated plugin, now cannot access dashboard/admin’ is closed to new replies.