Skip to content

Instantly share code, notes, and snippets.

<?php
/** @var $this JDocumentHTML */
defined( '_JEXEC' ) or die( 'Restricted access' );
// TODO: Ошибка генерации ссылки на "все новости"
$doc = JFactory::getDocument();
$config = JFactory::getConfig();
$this->_generator = '';
$baseUrl = JUri::base();
$isHomePage = $baseUrl === JUri::current();
@VicVicos
VicVicos / observeJS.js
Created March 23, 2017 05:38
Observer JavaScript
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutationRecord) {
// My Function
});
});
var target = document.querySelector('.element');
observer.observe(target, {
childList: true,
subtree: true,
http://habrahabr.ru/post/211538/
https://habrahabr.ru/sandbox/91471/ - tabs
// Проверка на подключенный jQuery
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.min.js"><\/script>')</script>
// Плавный скролл к верху
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
// Плавный скрол к якорю.
@VicVicos
VicVicos / xdebug
Last active January 23, 2019 07:52
xdebug.default_enable = 1
xdebug.auto_trace = 0
xdebug.collect_includes = 1
;xdebug.collect_params = 4
;xdebug.collect_return = 1
;xdebug.collect_assignments = 1
;xdebug.collect_vars = 1
xdebug.dump.REQUEST = *
xdebug.dump.SESSION = *
xdebug.dump.SERVER = REMOTE_ADDR,REQUEST_METHOD
@VicVicos
VicVicos / function.php
Last active November 22, 2021 18:57
WP functions
<?php
function get_posts_from_category($idCat) {
// параметры по умолчанию
$args = array(
'numberposts' => -1,
'category' => $idCat,
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
@VicVicos
VicVicos / AJAX_Handler.php
Created May 3, 2017 08:23
Ajax WP OOP habrahabr.ru/company/dataart/blog/271189/
abstract class AJAX_Handler {
function __construct($action_name) {
$this->init_hooks($action_name);
}
public function init_hooks($action_name) {
add_action('wp_ajax_'.$action_name , array($this,'callback'));
add_action('wp_ajax_nopriv_'.$action_name, array($this,'callback_nopriv'));
}
@VicVicos
VicVicos / phone_preg_match
Created May 23, 2017 02:10
preg_match phone
$phone = '+7 (999) 999-99-99';
$pattern = '/^((\+?7|8)[ \-] ?)?((\(\d{3}\))|(\d{3}))?([ \-])?(\d{3}[\- ]?\d{2}[\- ]?\d{2})$/';
preg_match($pattern, $phone)
@VicVicos
VicVicos / init.coffee
Last active May 25, 2017 03:52
Settings for Atom
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@VicVicos
VicVicos / counter.html
Last active September 8, 2018 17:26
Counter
<div class="counter">
<p class="number">
<span class="cminus position-count no-select">-</span>
<span class="value">1</span>
<span class="cplus position-count no-select">+</span>
</p>
<input type="number" min="1" value="1">
</div>
@VicVicos
VicVicos / modules.php
Created July 10, 2017 09:10
modules.php for Joomla
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
// Модуль пустышка
function modChrome_space($module, &$params, $attribs) {
// $module - Параметры модуля
// &$params - Параметры с вкладки "Доп параметры"
// $attribs - (position, style)
//