Skip to content

Instantly share code, notes, and snippets.

@zaurmag
zaurmag / redirect-http-https.txt
Created September 15, 2016 13:07
Редирект с http на https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://zaurmag.ru/$1 [R=301,L]
@zaurmag
zaurmag / breadcumbs-wordpress
Last active July 5, 2017 10:36
Хлебные крошки Wordpress
<?php
/*** Функция хлебных крошек ***/
function breadcrumbs_new() {
$mayak_home = 'Главная'; // текст ссылки "Главная"
$mayak_last_crumb = 1; // 1 - показывать название текущей статьи/страницы/рубрики, 0 - не показывать
$mayak_between = ' <span class="crumb_separator">&raquo;</span> ';
$mayak_from = '<span class="current-crumbs">';
$mayak_to = '</span>';
global $post;
$mayak_link_to_home = home_url('/');
@zaurmag
zaurmag / feedback-form
Last active November 30, 2017 08:58
Простая форма обратной связи на ajax
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Простая форма связи на ajax</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
// ======= Ajax Submit Form Plugin =======
(function($) {
@zaurmag
zaurmag / humburger
Created September 28, 2017 09:52
Иконка humburger
/** ===== Humburger ===== **/
.hamburger {
display: block;
text-decoration: none;
position: relative;
outline: none;
transition: transform .3s ease;
height: 20px;
width: 30px;
z-index: 10;
@zaurmag
zaurmag / insert-ad.php
Last active May 15, 2022 15:53
Функция добавления кода в статью
<?php
//отрисовка рекламы в статьях
function addContent($addTo, $add, $cntRep, $after = '</p>', $openTag = '<div align="center">', $closeTag = '</div>'){
$posAfter = 0;
for ($i=0; $i < $cntRep; $i++) {
$pos = stripos($addTo, $after, $posAfter);
$posAfter = $pos+strlen($after);
if($pos===FALSE){
return $addTo;
}
@zaurmag
zaurmag / adition-fields-template-joomla.php
Last active December 1, 2017 09:12
Вывод дополнительных полей Joomla в шаблоне
<?php
// GET CUSTOM FIELDS
$myCustomFields = array();
foreach($this->item->jcfields as $field) {
$myCustomFields[$field->name] = $field->value;
}
// RECOVER CUSTOM FILED NAME
if (isset($myCustomFields['url']) and !empty($myCustomFields['url'])) : ?>
<div class="field">
<?php echo $myCustomFields['url']; ?>
@zaurmag
zaurmag / first-abzac-rehularka-php.php
Last active December 20, 2017 10:04
pervyi abzatc - reguliarka php
<?php
$text = $this->item->text;
$patern="#<[\s]*p[\s]*>([^<]*)<[\s]*/p[\s]*>#i";
if(preg_match($patern, $text, $matches)) echo "<p>".$matches[1]."</p>";
?>
@zaurmag
zaurmag / responsive-gride
Created December 20, 2017 18:36
responsive gride
/** ------------------------------------------------------------
==================== RESPONSIVE ========================
------------------------------------------------------------------------------ **/
/** -----------------------------------------
========= MIN-WIDTH ==========
-------------------------------------------- **/
@media (min-width: 1201px) {}
@media (min-width: 992px) {}
@zaurmag
zaurmag / init.js
Created January 9, 2018 08:47
Wrap image figure tag
// ================ Wrap img in content HTML5 tags ================
var imgContent = $('.page__body.textblock a.popup-video img');
imgContent.each(function() {
$this = $(this);
var imgTitle = $this.attr('title');
if (imgTitle) {
$this.parent('.popup-video').wrap('<figure class="content-image"></figure>');
$this.parent('.popup-video').append('<figcaption class="content-image__title">' + imgTitle + '</figcaption>');
}
});
@zaurmag
zaurmag / posts-wordpress-by-module.php
Created May 17, 2018 20:46
Деление постов Wordpress по модулю
<?php
$args = array(
'posts_per_page' => 15,
'cat' => 12
);
$postsArr = get_posts( $args );
$chunkPosts = array_chunk($postsArr ,9);
foreach($chunkPosts as $posts){
echo '<div class="klients-logos__item">';