Skip to content

Instantly share code, notes, and snippets.

View kuzminT's full-sized avatar

Timofey Kuzmin kuzminT

View GitHub Profile
@kuzminT
kuzminT / postgresql-set-id-seq.sql
Created June 16, 2021 09:57 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@kuzminT
kuzminT / wp_sanitize_file_name.php
Created March 19, 2019 09:26 — forked from edirpedro/wp_sanitize_file_name.php
Translit file names to simple chars, this prevent WordPress to allow accents and special chars at file names that breaks in some server's configuration.
/*
* Translit file names to simple chars,
* this prevent accents and special chars at file names.
***********************************************************************/
function my_sanitize_file_name($filename) {
return remove_accents($filename);
}
add_filter('sanitize_file_name', 'my_sanitize_file_name');
/*
@kuzminT
kuzminT / functions.php
Created February 13, 2019 14:51 — forked from i-like-robots/functions.php
Wordpress custom comment form
<?php
/**
* Comment form hidden fields
*/
function comment_form_hidden_fields()
{
comment_id_fields();
if ( current_user_can( 'unfiltered_html' ) )
{
// getCookie(), setCookie(), deleteCookie()
// возвращает cookie если есть или undefined
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
))
return matches ? decodeURIComponent(matches[1]) : undefined
@kuzminT
kuzminT / gist:793f516ef268785f8078377bb528b41f
Created February 6, 2019 09:31 — forked from ivandoric/gist:e4e46294c4d35eac0ec8
wordpress: create custom reset password page
<?php //Add all of this tu custom page template ?>
<?php
global $wpdb;
$error = '';
$success = '';
// check if we're in reset form
if( isset( $_POST['action'] ) && 'reset' == $_POST['action'] )
{
@kuzminT
kuzminT / like-it-enqueue.php
Created January 30, 2019 13:01 — forked from shizhua/like-it-enqueue.php
Add a like button without a plugin in WordPress
add_action( 'wp_enqueue_scripts', 'pt_like_it_scripts' );
function pt_like_it_scripts() {
if( is_single() ) {
wp_enqueue_style( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'css/like-it.css' );
if (!wp_script_is( 'jquery', 'enqueued' )) {
wp_enqueue_script( 'jquery' );// Comment this line if you theme has already loaded jQuery
}
wp_enqueue_script( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'js/like-it.js', array('jquery'), '1.0', true );