Skip to content

Instantly share code, notes, and snippets.

View tux255's full-sized avatar

Andrii Haranin tux255

  • Kyiv
  • 08:15 (UTC -12:00)
View GitHub Profile
@tux255
tux255 / readme.md
Last active August 13, 2017 09:33
Move your wp-content Directory

Starting from WordPress 2.6, you can move your wp-content directory. It helps with site security or cooiless domain in my case. You can do move your wp-content directory by adding the following code in your wp-config.php file.

P.S. We have the plugin directory defined because some plugins might not work if you do not define it specifically.

@tux255
tux255 / .htaccess
Last active August 13, 2017 09:27
Securing Your WP-Config File
# Protect wp-config.php
<Files wp-config.php>
order allow,deny
deny from all
</Files>
@tux255
tux255 / functions.php
Last active October 18, 2019 08:37
Loadspeed theme improvements for Wordpress -> functions.php
// Remove query strings from urls
function remove_query_strings( $src ) {
$src = remove_query_arg( array( 'v', 'ver', 'rev', 'bg_color', 'sensor' ), $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_query_strings', 10, 2 );
add_filter( 'script_loader_src', 'remove_query_strings', 10, 2 );
// Defer parsing of JavaScripts
@tux255
tux255 / ajax_uploadfile.js
Last active August 1, 2021 13:54
AJAX Upload file. Wordpress
jQuery(document).on('click', '.save-support', function (e) {
var supporttitle = jQuery('.support-title').val();
var querytype = jQuery('.support-query').val();
var file_data = jQuery('#sortpicture').prop('files')[0];
var form_data = new FormData();
if (supporttitle == '') {
jQuery('.support-title').css({"border": "1px solid red"})
@tux255
tux255 / gitaddpattern.txt
Created May 12, 2017 08:16
GitAdd files by pattern path
language - и есть паттерн. Будут добавлены все файлы со словом language в адресе.
git status | grep language | awk '{print $2}' | xargs git add
@tux255
tux255 / index.js
Created March 16, 2017 14:37
Display current time with seconds
<div id="time"></div>
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function startTime() {
@tux255
tux255 / functions.php
Created March 5, 2017 09:55
Remove Emoji at Wordpress
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@tux255
tux255 / func.sql
Created February 13, 2017 09:05
SQL update if exists
INSERT INTO <table> (field1, field2, field3, ...)
VALUES ('value1', 'value2','value3', ...)
ON DUPLICATE KEY UPDATE
field1='value1', field2='value2', field3='value3', ...
@tux255
tux255 / serializeObject.js
Created February 7, 2017 09:01
Serialize form data to JSON prototype
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');