Skip to content

Instantly share code, notes, and snippets.

View serkanalgur's full-sized avatar
🇹🇷
🇦🇿 Selam / Salam / Hi!

Serkan Algur serkanalgur

🇹🇷
🇦🇿 Selam / Salam / Hi!
View GitHub Profile
@serkanalgur
serkanalgur / functions.php
Created June 15, 2022 09:29
Product Schema for WooCommerce
<?php
add_action( 'wp_head', 'add_product_info_to_head' );
function add_product_info_to_head() {
global $product;
if ( is_product() ) {
$image = wp_get_attachment_image_url( $product->get_image_id(), 'full', false );
echo '<script type="application/ld+json">
{
@serkanalgur
serkanalgur / BaseDate.vue
Last active August 31, 2022 11:19
Base Date Component Vue3
<template>
<span :title="humanFriendlyDate">{{ diffForHumans }}</span>
</template>
<script>
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import localizedDate from "dayjs/plugin/localizedFormat";
import tr from "dayjs/locale/tr";
dayjs.extend(relativeTime);
@serkanalgur
serkanalgur / font-awesome-5-all-icons.php
Created April 18, 2022 19:42
All Font Awesome 5 icons list pure php array.
<?php
$fa5all = array(
'fas fa-ad',
'fas fa-address-book',
'fas fa-address-card',
'fas fa-adjust',
'fas fa-air-freshener',
'fas fa-align-center',
'fas fa-align-justify',
@serkanalgur
serkanalgur / delete_posts.php
Last active March 30, 2022 17:22
Automatically Delete Posts older than 6 months ago
<?php
// Please use this function carefully.
// Changes can't undone. Best regards from Serkan Algur :)
// Let the function begin
function delete_oldest_posts_salgur( ) {
// We will collect posts from two years ago :)
$args = array(
'date_query' => array(
array(
'column' => 'post_date_gmt',
@serkanalgur
serkanalgur / random-color-user.php
Created July 6, 2021 13:47
Random colored user backgrounds with auto color calculation
<?php
/** Random Color Part Generator HEX **/
function RandomColorPart()
{
return mt_rand(0, 255);
}
/** Random Color Part Generator **/
@serkanalgur
serkanalgur / open_and_read_file.go
Created November 25, 2020 20:46
Open and Read File using phpfuncs module
package main
import (
"fmt"
"os"
"github.com/serkanalgur/phpfuncs"
)
func main(){
<?php
/**
* Yazı Adı : Geçmiş Yazıları ve Ortam Dosyalarını Otomatik Silmek
* Yazı Linki : https://wpadami.com/cms-sistemleri/wordpress/gecmis-yazilari-ortam-dosyalarini-otomatik-silmek.html.
**/
// Kodu lütfen dikkatli kullanın. Saygılarımla, Serkan Algur :)
// Kod başlasın
function delete_oldest_posts_salgur()
<?php
if (function_exists('register_sidebar')) {
register_sidebar([
'name' => 'Sol bilesen',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
]);
<?php
/**
* Yazı İsmi : 30 Günden Eski Mesajlarınıza Yorum Yapılmasını Engellemek
* Yazı Linki : https://wpadami.com/cms-sistemleri/wordpress/30-gunden-eski-mesajlariniza-yorum-yapilmasini-engellemek.html
*/
function close_comments($posts)
{
if (!is_single()) {
@serkanalgur
serkanalgur / create_json_extract.sql
Last active June 18, 2021 08:26
json_extract and json_unquote creator functions for Mysql < 5.7 . If you use translatable texts with Laravel you can use this. (I was forced to use Laravel with cPanel built with MySQL 5.6)
DELIMITER $$
CREATE FUNCTION `json_extract`(`details` TEXT, `required_field` VARCHAR(255)) RETURNS text CHARSET utf8mb4
BEGIN
RETURN TRIM(
BOTH '"' FROM SUBSTRING_INDEX(
SUBSTRING_INDEX(
SUBSTRING_INDEX(
details,
CONCAT(
'"',