Skip to content

Instantly share code, notes, and snippets.

View atomjoy's full-sized avatar

Atomjoy atomjoy

View GitHub Profile
@atomjoy
atomjoy / ResizeImage-InterventionImage-v3-Laravel.md
Last active March 31, 2025 10:18
Upload, Resize and Save images with Intervention Image v3 in Laravel Storage. Test UploadedFile::fake() with real image file.

Resize images with Intervention Image v3 in Laravel Storage

Upload, Resize and Save images with Intervention Image v3 in Laravel Storage. Test UploadedFile::fake() with real image file.

Upload form

<form action="/upload/avatar" method="post" enctype="multipart/form-data">
	@csrf
	<label>Image</label>
@atomjoy
atomjoy / Schema-LocalBusiness-WebSite.html
Last active September 3, 2024 11:24
Jak działają znaczniki uporządkowanych danych Google dotyczące firmy działającej lokalnie (LocalBusiness) i strony firmy (WebSite) schema.org.
<html>
<head>
<title>Page Title</title>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "Page Title",
"url": "https://example.org"
@atomjoy
atomjoy / Laravel-redirect-root-to-public.md
Last active September 3, 2024 11:25
Laravel 11 redirect root to public or create public_html storage link.

Redirect root to public in Laravel 11

Shared hosting Laravel rewrite root to public directory create .htaccess in Laravel application directory.

Htaccess

# Shared hosting Laravel rewrite root to public directory

# Php 8.2 Ovh
@atomjoy
atomjoy / Link-polecający-small-hosting.md
Last active September 3, 2024 11:29
Small.pl hosting link polecający
@atomjoy
atomjoy / Post-views-counter.php
Last active September 15, 2024 08:47
Post views counter in WordPress.
<?php
/*
* Set post views count using post meta
* Add to: single.php
*/
function countPostViews($key = 'post_views_count') {
$postID = get_the_ID();
$count = get_post_meta($postID, $key, true);
// Update the custom field value.
if($count == ''){
@atomjoy
atomjoy / Load-post.php
Last active September 5, 2024 23:45
How to enable post images and remove default generated image sizes in WordPress.
<?php
// Post formats
add_theme_support('post-formats', ['aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat']);
// Enable post thumbnails
add_theme_support('post-thumbnails');
// Update default thumbnails size (post-thumbnail, medium_large)
set_post_thumbnail_size(1280, 720, true);
@atomjoy
atomjoy / Load-script.php
Last active September 17, 2024 15:59
Load scripts and style with do_action hooks in Wordpress.
<?php
// Disable auto updates
add_filter('auto_update_plugin', '__return_false');
add_filter('auto_update_theme', '__return_false');
function load_css() {
// Load bootstrap css
wp_register_style('bootstrap', get_template_directory_uri() . '/css/bootstrap/bootstrap.min.css', [], false, 'all');
wp_enqueue_style('bootstrap');
@atomjoy
atomjoy / Wp-custom-pagination-links.php
Last active September 6, 2024 07:42
Wordpress custom pagination links function.
@atomjoy
atomjoy / Load-search.php
Created September 15, 2024 13:04
Search posts only fliter
<?php
// Search only in posts with wordpress ?s=
function search_filter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','search_filter');
@atomjoy
atomjoy / Custom-api-route.php
Created September 15, 2024 18:44
Wordpress custom rest api routes.
<?php
/**
* Subscribe user
*/
function subscribe_user(WP_REST_Request $request) {
// $params = $request->get_params();
// $email = $params['email'];
$email = $request->get_param('email');
return [