Skip to content

Instantly share code, notes, and snippets.

View Neolot's full-sized avatar
🏠
Make the web great again

Yurii Pokhylko Neolot

🏠
Make the web great again
View GitHub Profile
<?php
/**
* Dimox Breadcrumbs
* http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
* Since ver 1.0
* Add this to any template file by calling dimox_breadcrumbs()
* Changes: MC added taxonomy support
*/
function dimox_breadcrumbs(){
/* === OPTIONS === */
@Neolot
Neolot / gist:10597184
Created April 13, 2014 18:56
WORDPRESS Remove standard image sizes
<?php
/**
* Remove standard image sizes so that these sizes are not
* created during the Media Upload process
*
* Tested with WP 3.2.1
*
* Hooked to intermediate_image_sizes_advanced filter
* See wp_generate_attachment_metadata( $attachment_id, $file ) in wp-admin/includes/image.php
*
@Neolot
Neolot / gist:9865565
Created March 30, 2014 00:53
MODX REVO SimpleMenu
<?php
if ( $includeDocs ) {
$ids = str_replace(' ','',$includeDocs);
$ids = explode(',', $ids);
$criteria = $modx->newQuery('modResource');
$criteria->sortby('FIELD(modResource.id, '.implode(',',$ids).' )', 'ASC');
$criteria->where(array(
'id:IN' => $ids
));
@Neolot
Neolot / gist:9327241
Last active May 16, 2018 14:31
PHP Export to csv
<?php
function array2csv(array &$array){
if (count($array) == 0) {
return null;
}
ob_start();
$df = fopen("php://output", 'w');
fputcsv($df, array_keys(reset($array)));
foreach ($array as $row) {
fputcsv($df, $row);
@Neolot
Neolot / gist:8553965
Created January 22, 2014 05:41
MODX REVO EmailIt - Сниппет для отправки email
<?php
/*
* Принимаемые параметры:
* $from - email отправителя
* $fromName - имя отправителя
* $to - email получателя
* $replyTo - email Reply To
* $bccTo - email "скрытая копия"
* $template - чанк с шаблоном письма
* $subject - Тема письма
@Neolot
Neolot / gist:7258622
Last active December 27, 2015 03:19
Обновить кнопки Facebook и Twitter после вставки через ajax
$.ajax({
type: "GET",
url: $(this).attr('href'),
dataType: "html",
success: function (result) {
$('.loop').append(result);
FB.XFBML.parse(); // Facebook
twttr.widgets.load(); // Twitter
}
}
@Neolot
Neolot / gist:7189739
Last active February 28, 2023 07:06
WORDPRESS Ajax contact-form
<!-- contactform.php -->
<div class="cf" id="cf">
<form action="javascript:void(0);">
<div><input type="text" name="name" placeholder="Name"/><span class="error"></span></div>
<div><input type="text" name="email" placeholder="Email"/><span class="error"></span></div>
<div><textarea name="message" placeholder="Message"></textarea><span class="error"></span></div>
<div><button type="submit">Submit</button> <span class="loader"></span></div>
</form>
</div>
@Neolot
Neolot / gist:6894146
Created October 9, 2013 00:24
WORDPRESS Change and Update URLS in Database When Site is Moved to new Host
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@Neolot
Neolot / gist:6703439
Created September 25, 2013 17:56
Grayscale to color images on hover
img.grayscale{
filter: grayscale(100%);
-webkit-filter: grayscale(100%); /* For Webkit browsers */
filter: gray; /* For IE 6 - 9 */
-webkit-transition: all .6s ease; /* Fade to color for Chrome and Safari */
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
}
img.grayscale:hover{
filter: grayscale(0%);
@Neolot
Neolot / gist:6078830
Last active December 20, 2015 05:29
Счетчик клиентов за день
<?php
function getCounter() {
$starttime = 9; // Время начала рабочего периода
$endtime = 22; // Время конца рабочего периода
$offset = 0; // Временное смещение или часовой пояс, иногда нужно
$min = 5; // Начальное значение счетчика
$max = 315; // Максимальное значение счетчика
$hour = date('G') + $offset;
if ( $hour < $starttime ) $hour = $hour + 24;