View Categories

Changing Time Format and Language in Groundhogg Social Proof Popup

Document

Before


After



💡

Purpose:

The PHP code snippet modifies how the time difference is represented in the Groundhogg social proof popup. Originally, the time difference was displayed in English as "2 hours ago". The updated code shifts the position of "ago" to precede the time difference and changes the language to German. The new display is "vor 2 Stunden" which translates to "before 2 hours".


💥

Note:

Before proceeding with the following steps, ensure you have a recent backup of the website. Directly editing PHP files may break the site if not done correctly. If you're unsure, please seek help from a professional or use a staging site to test changes first.


🗺️

Location:

Follow the steps below to locate the file where the PHP code modification needs to be performed:

  1. Install the WP File Manager plugin (Plugin Link) on WordPress website.

  2. Navigate to the WP File Manager on your WordPress dashboard.

  3. Click on the wp-content folder to expand it.

  4. Inside wp-content, navigate to the plugins folder.

  5. In the plugins folder, locate and open the groundhogg-proof plugin folder.

  6. Within the groundhogg-proof folder, find and open the API folder.

  7. Inside the API folder, you'll find the proof-api-v4.php file.

  8. Right-click on the proof-api-v4.php file and select Code Editor from the context menu.

  9. Within the proof-api-v4.php file, find the section of code that defines the 'timePassed' parameter. Replace the code at line 97 with the provided PHP snippet code.



🔷

Code Snippet: PHP

'timePassed' => sprintf( __( "vor %s.", 'groundhogg-proof' ), human_time_diff( $event->get_time(), time() ) ),



Special Notes:

  • The updated code changes the text from English to German and alters the position of the word indicating past time ("ago" in English, "vor" in German) to be in front of the time difference. If your website language differs, replace "vor" with the corresponding word in your language and adjust the syntax as needed.

  • This code is added directly in the plugin's PHP file. It's important to be aware that updates to the plugin could remove this custom code. It's a good idea to keep a copy of this code and to check your customization after every plugin update to make sure it's still working.

  • This change is hard-coded, which means it cannot be modified from the WordPress dashboard. If you need to adjust it, you will have to change the code directly.

  • Don't forget to clear the cache on your site after you make changes to PHP files. Clearing the cache makes sure your changes take effect.

Powered by BetterDocs

Schreibe einen Kommentar