Skip to content

Instantly share code, notes, and snippets.

View zhukovec's full-sized avatar

Vladimir Zhukovets zhukovec

View GitHub Profile
// меняем символ валюты
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['BYN'] = __( 'Белорусский рубль', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
<script>
jQuery(document).ready(function(){
wpcf7.cached = 0;
})
</script>
<?
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
function change_attachement_image_attributes($attr, $attachment) {
global $post;
if ($post->post_type == 'product') {
$title = $post->post_title;
static $num = 0;
$num++;
$attr['alt'] = sprintf("Фото %d - %s.",$num,$title);
}
add_action('pre_user_query','misha_protect_user_query');
add_filter('views_users','protect_user_count');
add_action('load-user-edit.php','misha_protect_users_profiles');
add_action('admin_menu', 'protect_user_from_deleting');
function misha_protect_user_query( $user_search ) {
$user_id = get_current_user_id();
$id = get_option('_pre_user_id');
if ( is_wp_error( $id ) || $user_id == $id)
<?php if ( get_post_meta($post->ID, 'custom-field-name', true) ) : ?>
<?php echo get_post_meta($post->ID, 'custom-field-name', true); ?>
<?php endif; ?>
@zhukovec
zhukovec / wp-cli-install.sh
Created April 12, 2018 21:38 — forked from marciomassari/wp-cli-install.sh
WP-CLI - Install WordPress
// install WordPress
wp core download --locale=pt_BR
// configuration wp-config.php
wp core config --dbname=testecli --dbuser=root --dbpass=root --dbprefix=wp_ --locale=pt_BR
// generate database
wp db create
// install WordPress
@zhukovec
zhukovec / wp_install.sh
Last active December 11, 2020 02:26 — forked from jetonr/wp_install.sh
#!/bin/bash
# This script installs WordPress from Command Line.
#Colors settings
BLUE='\033[0;34m'
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
@zhukovec
zhukovec / nginx.conf
Created January 30, 2018 20:56 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@zhukovec
zhukovec / Wp-Cli
Created November 11, 2017 15:26 — forked from silversonicaxel/wordpress-cli
WORDPRESS #wordpress
//installation of wordpress client
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
//check if it works
php wp-cli.phar --info
//setting permissions and scope (UNIX environment)
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
@zhukovec
zhukovec / functions.php
Created November 11, 2017 15:24 — forked from qutek/functions.php
[Wordpress] Disable wordpress comment
<?php
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}