Changing the URL of “Edit in WordPress” icon in the Bricks editor

One of the clickable icons in the Bricks builder’s toolbar is the WordPress icon that links to the current Page or template WP post editor.

If you want to change this icon’s URL to the site’s WP dashboard, including its tooltip, here’s how it can be done.

Install and activate WPCodeBox.

Add a new snippet.

Title: Link WP icon in the Bricks editor to dashboard

Type: JavaScript

Open the condition builder.

Enter this condition:

<?php 
bricks_is_builder_main();

Save and close.

Paste this code:

document.addEventListener('DOMContentLoaded', function() {
  const editInWordPressLi = document.querySelector('#bricks-toolbar li[data-balloon="Edit in WordPress"]');

  if (editInWordPressLi) {
    editInWordPressLi.querySelector('a').setAttribute('href', '/wp-admin/');
    editInWordPressLi.setAttribute('data-balloon', 'WordPress Dashboard');
  }
});

Before:

After:

Reference

https://brickslabs.com/using-wpcodebox-for-bricks-specific-snippets/

Instant access to 390+ Bricks code tutorials with BricksLabs Pro

Leave the first comment