Skip to content

Instantly share code, notes, and snippets.

@gitussr
gitussr / template-upcoming-tour.php
Created July 6, 2023 11:08
Upcoming Tour ASC order according to ACF Date Picker Field
$current_date = date('Ymd'); // Get the current date in the format YYYYMMDD
$args = array(
'post_type' => 'tour',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'travel_date', // ACF field name
'value' => $current_date,
'compare' => '>=', // Filter tours with travel_date greater than or equal to the current date
@gitussr
gitussr / index.php
Created July 6, 2023 13:51
ACF Group Repeater Loop
<?php if ( ! have_rows( 'services' ) ) { return false; } ?>
<?php if ( have_rows( 'services' ) ) : ?>
<?php while ( have_rows( 'services' ) ) : the_row(); ?>
<?php if ( have_rows( 'services_list' ) ) : ?>
<?php
/*
Crunchify Tips - Clean up WordPress Header START
The crunchify_remove_version() function is a WordPress function that removes the WordPress version number from the header of a WordPress site. This can be useful for security purposes, as it makes it more difficult for attackers to determine what version of WordPress a site is running. The function works by adding a filter to the the_generator hook, which is responsible for outputting the WordPress version number. The filter simply returns an empty string, which effectively removes the version number from the header.
The rest of the code in the snippet removes various other unnecessary elements from the header of a WordPress site. These elements include:
* The emoji detection script
* The emoji styles
* The REST API output link
@gitussr
gitussr / readme.md
Last active December 9, 2023 12:53
SQL CRUD process

INSERT QUERY

To insert data into a table, you can use the INSERT INTO statement. Here's an example:

INSERT INTO table_name (column1, column2, column3)
VALUES (value1, value2, value3);

For instance, if you have a table called customers with columns id, name, and email, and you want to insert a new customer, the SQL code would look like this:

@gitussr
gitussr / index.php
Created May 8, 2024 08:26
PHP Form validation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Secure Form</title>
</head>
<body>
<h1>Registration Form</h1>
<form action="process.php" method="post">
<label for="name">Name:</label>
@gitussr
gitussr / index.php
Created May 8, 2024 08:35
Blogpost Form Validation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Create Blog Post</title>
</head>
<body>
<h1>Create Blog Post</h1>
<?php if (isset($_SESSION['errors'])): ?>
<div class="error">
@gitussr
gitussr / functions.php
Created May 15, 2024 05:37
WordPress Functions File
<?php
/**
* Enqueue Theme Assets
* */
function freightsave_assets() {
//Bootstrap Core CSS
wp_enqueue_style( 'bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css', '', '5.3.3', 'all' );
wp_enqueue_style( 'bootstrap-icon', 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css', '', '1.11.3', 'all' );
@gitussr
gitussr / readme.md
Last active June 10, 2024 11:07
Login System PHP and MySQL(Procedural)

Database Setup (users table):

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) NOT NULL UNIQUE,
  email VARCHAR(100) NOT NULL UNIQUE,
  password VARCHAR(255) NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
@gitussr
gitussr / readme.md
Last active June 28, 2024 05:35
Photo upload using PHP and MySQL

1. Database Connection (connect.php):

<?php

$db_host = "localhost";
$db_user = "your_username";
$db_password = "your_password";
$db_name = "your_database_name";

// Create connection
@gitussr
gitussr / db.js
Created December 13, 2024 10:47
Node JS with MongoDB
const { MongoClient } = require('mongodb');
const url = "mongodb://localhost:27017/";
// Connect to MongoDB
MongoClient.connect(url, { useUnifiedTopology: true }, async (err, client) => {
if (err) throw err;
try {
// Get the database
const dbo = client.db("mydb");