Tuesday, July 7, 2026

Wordpress debug log function



Wordpress error log code:

if ( ! function_exists( 'write_log' ) ) {
function write_log( $data ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$log_file = WP_CONTENT_DIR . '/debug.log';

// Ensure timezone
$timezone = new DateTimeZone('Europe/Helsinki');
$date = new DateTime('now', $timezone);
$datetime = $date->format('Y-m-d H:i:s');

if ( is_array( $data ) || is_object( $data ) ) {
$log_message = '[' . $datetime . '] ' . print_r( $data, true ) . PHP_EOL;
} else {
$log_message = '[' . $datetime . '] ' . $data . PHP_EOL;
}

error_log( $log_message, 3, $log_file );
}
}
}

.:Happy Coding:.

Sunday, January 18, 2026

Workflow of WordPress project in a team with Git

1. We should not push any Wordpress core folders or files to github.

2. Only push custom theme and custom plugin into github.

3. So, in this case first create a .gitignore files that ignore all core folders and files to push into github.

Example .gitignore code:

# ===============================
# WordPress Core (optional)
# ===============================
/wp-admin/
/wp-includes/
/wp-*.php
/xmlrpc.php
/readme.html
/license.txt

# ===============================
# WordPress Content
# ===============================
/wp-content/uploads/
/wp-content/cache/
/wp-content/upgrade/
/wp-content/ai1wm-backups/
/wp-content/backup*/
/wp-content/backups/
/wp-content/wflogs/
/wp-content/debug.log
/wp-content/themes/index.php

# ===============================
# Plugins & Themes (keep only custom)
# ===============================
/wp-content/plugins/*
!/wp-content/plugins/your-custom-theme/

/wp-content/themes/*
!/wp-content/themes/your-custom-plugin/

# ===============================
# Config & Environment
# ===============================
wp-config.php
.env
.env.*
*.log
.htaccess

# ===============================
# OS / Editor files
# ===============================
.DS_Store
Thumbs.db
.vscode/
.idea/

# ===============================
# Composer / Node
# ===============================
/vendor/
/node_modules/
package-lock.json
yarn.lock

# ===============================
# Cache / Temp
# ===============================
*.cache
*.tmp

4. So, in github we'll see only three things, wp-content folder, index.php and .gitignore. Inside of wp-content, there will be themes folder and inside of that themes folder your custom theme.

5. So, after initial commit and push to github, it is time to clone it from github to your co-worker's local development environment.

6. In your co-worker's development environment, they will have wordpress installed. Then go inside your wordpress folder and in root run few git command:

- git init

- git remote add origin YOUR-REPOSITORY-LINK

- git fetch origin

- git checkout -f main

Co-workers are done and synced now!
Ready to start working...







Thursday, November 14, 2024

Suomen kieli (Imperfekti)

In Finnish, the imperfekti is the past tense that describes actions that happened in the past, like the English simple past (e.g., "I walked," "I saw"). It’s used for actions that are completed or that took place at a specific time.

Here's how to form the imperfekti and some examples:

Formation of Imperfekti

  1. Start with the basic form (verb stem) of the verb.
  2. Add a past tense marker, usually -i-, and sometimes adjust vowels or consonants as needed.
  3. Add the appropriate personal ending.

Examples

  1. Verb: asua (to live)

    • Stem: asu-
    • Imperfekti: asuin (I lived)
    • Sentences:
      • Minä asuin Helsingissä. (I lived in Helsinki.)
      • Hän asui Suomessa. (He/she lived in Finland.)
  2. Verb: syödä (to eat)

    • Stem: syö-
    • Imperfekti: söin (I ate)
    • Sentences:
      • Me söimme pizzaa eilen. (We ate pizza yesterday.)
      • Hän söi omenan. (He/she ate an apple.)
  3. Verb: juoda (to drink)

    • Stem: juo-
    • Imperfekti: join (I drank)
    • Sentences:
      • Join kahvia aamulla. (I drank coffee in the morning.)
      • He joivat teetä iltapäivällä. (They drank tea in the afternoon.)
  4. Verb: kävellä (to walk)

    • Stem: kävele-
    • Imperfekti: kävelin (I walked)
    • Sentences:
      • Kävelin puistossa. (I walked in the park.)
      • He kävelivät rannalla. (They walked on the beach.)

Irregular Verbs

Some verbs have changes in their stems or are irregular:

  • Verb: olla (to be)

    • Imperfekti: olin (I was)
    • Example: Olin kotona koko päivän. (I was at home all day.)
  • Verb: tehdä (to do)

    • Imperfekti: teki (he/she did)
    • Example: Hän teki läksyt nopeasti. (He/she did the homework quickly.)

Practice with Easy Sentences

  1. Eilen satoi vettä. (It rained yesterday.)
  2. Hän kirjoitti kirjeen. (He/she wrote a letter.)
  3. Katsoimme elokuvan illalla. (We watched a movie in the evening.)
  4. Lapset leikkivät ulkona. (The children played outside.)

Monday, October 28, 2024

Suomen Kieli (Taalla, Tuolla, Siella)

In Finnish, location-based words like "täällä," "tuolla," and "siellä" help describe where something is relative to the speaker or listener. Here’s a quick breakdown:

  1. Täällä = "Here" (Close to the speaker)
  2. Tuolla = "There" (In sight but not very close to the speaker)
  3. Siellä = "Over there" or "There" (Far from both the speaker and listener)

Easy Examples

Imagine a park, where:

  • You (the speaker) are sitting on a bench.
  • A friend is standing by a tree a little distance away.
  • A playground is visible but further away.

1. Täällä (Here)

  • You’re sitting on a bench and want to say, "I am here on the bench."
  • In Finnish, you’d say, "Minä olen täällä penkillä."
  • Täällä refers to the place close to you (the speaker).

2. Tuolla (There)

  • You point to your friend who’s standing by the tree, a little bit away from you.
  • You’d say, "Hän on tuolla puun luona."
  • Tuolla describes a place a bit away from you but still visible.

3. Siellä (Over there/There)

  • Now you point to the playground further away.
  • You’d say, "Leikkipaikka on siellä."
  • Siellä refers to a place far away from both you and your friend.

Wednesday, October 16, 2024

Upcoming webinar list (WebinarPress)

Upcoming webinar list (WebinarPress)

// Upcoming webinars shortcode
function regf_display_upcoming_webinars() {
$args = array(
'post_type' => 'wswebinars',
'posts_per_page' => -1,
'meta_key' => '_wswebinar_gener_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_wswebinar_gener_date',
//'value' => date('Y-m-d H:i:s'), // Compare with the current date to get past webinars
'value' => date('Y-m-d'),
'compare' => '>', // Get webinars that occurred before the current date
'type' => 'DATETIME',
),
),
);

$query = new WP_Query($args);
$posts = $query->posts;

ob_start();
echo '<ul>';
echo '<h2 class="widget-title past-webinars-list-title">Upcoming Webinars</h2>';
if ($posts) {
foreach ($posts as $post) {

//echo '<a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a><br>';
$meta_values_past_date = get_post_meta($post->ID, '_wswebinar_gener_date', true);
$meta_values_vurl = get_post_meta($post->ID, '_wswebinar_livep_vidurl', true);
echo get_the_title($post->ID) . ' ('. $meta_values_past_date .')' . ' - ' . '<a href="'. get_permalink($post->ID) .'">' . 'Join webinar' . '</a>' . '<br>';
wp_reset_query();
}
}
else {
echo 'No upcoming webinar';
}
echo '</ul>';
return ob_get_clean();
}
add_shortcode('upcoming_webinars', 'regf_display_upcoming_webinars');

Past webinar list (WebinarPress)

List of past webinars:

// Past webinars shortcode
function regf_display_past_webinars() {
$args = array(
'post_type' => 'wswebinars',
'posts_per_page' => -1,
'meta_key' => '_wswebinar_gener_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_wswebinar_gener_date',
//'value' => date('Y-m-d H:i:s'),
// Compare with the current date to get past webinars
'value' => date('Y-m-d'),
'compare' => '<',
// Get webinars that occurred before the current date
'type' => 'DATETIME',
),
),
);

$query = new WP_Query($args);
$posts = $query->posts;

ob_start();
echo '<ul>';
echo '<h2 class="widget-title">Past Webinars</h2>';
if ($posts) {
foreach ($posts as $post) {
//echo '<a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a><br>';
$meta_values_past_date = get_post_meta($post->ID,
'_wswebinar_gener_date', true);
$meta_values_vurl = get_post_meta($post->ID,
'_wswebinar_livep_vidurl', true);
echo get_the_title($post->ID) . ' ('. $meta_values_past_date .')' . ' - '
. '<a href="'. $meta_values_vurl .'">' . 'Watch webinar' . '</a>' . '<br>';
}
}
else {
echo 'No past webinar';
}
echo '</ul>';
return ob_get_clean();
}
add_shortcode('past_webinars', 'regf_display_past_webinars');


Sunday, October 6, 2024

Suomen Kieli (Vuorokausi)

Suomen Kieli (Vuorokausi):


1. Aamu (Morning): This refers to early morning, usually around 6:00 AM to 9:00 AM.

2. Aamupäivä (Before noon): Late morning, approximately from 9:00 AM to 12:00 PM.

3. Päivä (Daytime): Midday and early afternoon, typically from 12:00 PM to 3:00 PM.

4. Iltapäivä (Afternoon): Late afternoon, usually around 3:00 PM to 6:00 PM.

5. Ilta (Evening): The evening period, from 6:00 PM to 9:00 PM.

6. (Night): Nighttime, which generally starts around 9:00 PM and continues until 6:00 AM.

7. Aamuyö (Early morning hours): Early morning hours after midnight, typically from 12:00 AM to 6:00 AM.


Wordpress debug log function

Wordpress error log code: if ( ! function_exists ( 'write_log' ) ) { function write_log ( $data ) { if ( defined ( '...