Skip to content

Instantly share code, notes, and snippets.

@alegut
alegut / replace_parenthesis.php
Last active August 30, 2018 10:47
Replace parenthesis from the phone number in php
<?php
preg_replace('/\D+/', '', $phone_string);
//or
$str = 'In My Cart : 11 items';
$int = abs((int) filter_var($str, FILTER_SANITIZE_NUMBER_INT));
//or
$str = '(111) 111-1111';
$str = preg_replace('/\D/', '', $str);
@alegut
alegut / gmaps_link.js
Created August 30, 2018 10:38
Create Google Maps link from link text
@alegut
alegut / fixTableHeader.css
Last active September 10, 2018 10:10
Fixed table header
.fixclone {
position: fixed;
top: 0;
z-index: 10000;
}
@alegut
alegut / wp-config.php
Created September 8, 2018 16:43
Unable to install plugins and update WordPress on localhost
define('FS_METHOD', 'direct');
@alegut
alegut / autoformatRemove,php
Created September 14, 2018 09:57
Disable autoformatting in WordPress posts and pages
<?php
remove_filter( 'the_content', 'wpautop' ); // Отключаем автоформатирование в полном посте
remove_filter( 'the_excerpt', 'wpautop' ); // Отключаем автоформатирование в кратком(анонсе) посте
remove_filter('comment_text', 'wpautop'); // Отключаем автоформатирование в комментариях
@alegut
alegut / adminbar.php
Created September 27, 2018 13:25
Remove itams from WP Admin Ber
<?php
function remove_toolbar_items($wp_adminbar) {
$wp_adminbar->remove_node('updates');
$wp_adminbar->remove_node('site-name');
$wp_adminbar->remove_node('comments');
$wp_adminbar->remove_node('new-content');
$wp_adminbar->remove_node('edit');
}
@alegut
alegut / detectsafari.js
Created September 27, 2018 13:29
Detect Safari browser
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (isSafari) {
alert("Browser is Safari");
} else {
}
@alegut
alegut / functions.php
Created October 1, 2018 12:08
Wordpress customizer and admin bar
function themeName_customize_register( $wp_customize ) {
$blog_id = get_current_blog_id();
$blog_images_count = [1, 4, 4];
$wp_customize->remove_section('title_tagline');
$wp_customize->remove_section('colors');
$wp_customize->remove_section('header_image');
@alegut
alegut / admin.js
Last active October 16, 2018 09:35
WP media uploader script
jQuery(document).ready(function ($) {
$(document).on('click', '.js-image-upload', function (e) {
e.preventDefault();
var $button = $(this);
var file_frame = wp.media.frames.file_frame = wp.media({
title: 'Select or Upload an Image',
library: {
type: 'image' // mime type
},
@alegut
alegut / readme.txt
Created October 13, 2018 07:57
Change rewrite rules apache2
$ sudo a2enmod rewrite
sudo nano /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
# service apache2 restart