Skip to content

Instantly share code, notes, and snippets.

@zaurmag
zaurmag / dop-wp-config
Created January 28, 2020 07:33
Dop const Wordpress in wp-config
<?php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define('WP_HOME','');
define('WP_SITEURL','');
define('FORCE_SSL_LOGIN', true);
@zaurmag
zaurmag / fixed-block.js
Created May 21, 2018 19:49
Fixed блок
// ======= Fixed block =======
(function($) {
$.fn.addFixClass = function(options) {
options = $.extend({
offset: 200,
destroy: false
}, options);
var fixClass = $(this);
$(window).bind('scroll', function() {
if ($(window).scrollTop() >= options.offset && !options.destroy) {
@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">';
@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 / responsive-gride
Created December 20, 2017 18:36
responsive gride
/** ------------------------------------------------------------
==================== RESPONSIVE ========================
------------------------------------------------------------------------------ **/
/** -----------------------------------------
========= MIN-WIDTH ==========
-------------------------------------------- **/
@media (min-width: 1201px) {}
@media (min-width: 992px) {}
@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 / 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 / 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 / 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 / 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($) {