Skip to content

Instantly share code, notes, and snippets.

View muks999's full-sized avatar

Muks999 muks999

View GitHub Profile
@muks999
muks999 / wc-thankyou-page.php
Created October 9, 2018 12:57 — forked from artikus11/wc-thankyou-page.php
Персонализация заголока на странице спасибо после заказа
add_filter( 'the_title', 'kld_title_order_received', 10, 2 );
function kld_title_order_received( $title, $id ) {
if ( is_order_received_page() && get_the_ID() === $id ) {
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
$order_id = isset( $_GET ) ? wc_get_order_id_by_order_key( $_GET ) : '';
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );
if ( ! $order || $order->get_order_key() !== $order_key ) {
$order = false;
}
@muks999
muks999 / shortcode.php
Created October 9, 2018 12:57 — forked from artikus11/shortcode.php
Шорткод вывода постов по ID
add_shortcode( 'art_related_posts', 'related_posts_function' );
function related_posts_function ($atts){
$atts = shortcode_atts( array(
'id' => '',
'count' => 3
), $atts );
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
@muks999
muks999 / functions.php
Created October 9, 2018 12:57 — forked from artikus11/functions.php
Добавление согласия на обработку данных в комментариях
add_filter( 'comment_form_after_fields', 'add_consent_personal_data_comment' );
function add_consent_personal_data_comment(){
?>
<small style="font-size: 12px;line-height: 1.1;margin: 10px 0;display: block;"> Нажимая на кнопку отправить, я принимаю условия <a href="#" target="_blank">пользовательского соглашения</a> , а также ознакомлен и согласен с <a href="#" target="_blank">политикой конфиденциальности</a> и даю согласие на обработку моих персональных данных</small>
<?php
}
@muks999
muks999 / terms.php
Created October 9, 2018 12:56 — forked from artikus11/terms.php
Добавление политики конфиденциальности
<?php
/**
* Checkout terms and conditions checkbox
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 3.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@muks999
muks999 / functions.php
Created October 9, 2018 12:55 — forked from artikus11/functions.php
Сообщение на сайте поверх всех элементов
/*=================================================================================
* Сообщения
*================================================================================= */
add_action( 'wp_head', 'artabr_notice_shop' );
function artabr_notice_shop() {
?>
<style>
.shop-notice {
position: fixed;
@muks999
muks999 / metrika.js
Created October 9, 2018 12:55 — forked from artikus11/metrika.js
Подключение целей из метрики в теме Divi на просто кнопку, кнопку в призыве и кнопку в слайдере
XXXXXXX - номер счетчика
TARGET_NAME - идентификатор цели
<script>
jQuery(document).ready(function ($) {
$('#buy').click(function () {
yaCounterXXXXXXX.reachGoal('TARGET_NAME ');
console.log('цель 1');
});
@muks999
muks999 / functions.php
Created October 9, 2018 12:54 — forked from artikus11/functions.php
Функция подстановики названия соцсетей в зависимости от сслыки на профиль
function art_social_icons($item_url) {
$social_icons = apply_filters( 'art_social_icons', array(
'codepen.io' => 'codepen',
'digg.com' => 'digg',
'dribbble.com' => 'dribbble',
'dropbox.com' => 'dropbox',
'facebook.com' => 'facebook',
'flickr.com' => 'flickr',
'foursquare.com' => 'foursquare',
@muks999
muks999 / .htaccess
Created October 9, 2018 12:52 — forked from artikus11/.htaccess
Редирект с http На https
#Вариант 1
RewriteCond %{HTTP:X-HTTPS} !1
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
#Вариант 2
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@muks999
muks999 / wrapURLs.js
Created July 9, 2018 08:05 — forked from ryasmi/wrapURLs.js
Wraps all URLs in anchor tags with a `href` and `target` inside some given text.
var wrapURLs = function (text, new_window) {
var url_pattern = /(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}\-\x{ffff}0-9]+-?)*[a-z\x{00a1}\-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}\-\x{ffff}0-9]+-?)*[a-z\x{00a1}\-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}\-\x{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?/ig;
var target = (new_window === true || new_window == null) ? '_blank' : '';
return text.replace(url_pattern, function (url) {
var protocol_pattern = /^(?:(?:https?|ftp):\/\/)/i;
var href = protocol_pattern.test(url) ? url : 'http://' + url;
return '<a href="' + href + '" target="' + target + '">' + url + '</a>';
});
};
@muks999
muks999 / mvvm.html
Created June 14, 2018 05:41 — forked from smelukov/mvvm.html
Very simple MVVM (dynamic data binding) on JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>MVVM</h1>