Skip to content

Instantly share code, notes, and snippets.

@eto4detak
eto4detak / sticky-sidebar.js
Created February 4, 2019 14:10
js sticky sidebar
/* sticky sidebar cart */
(function(){
var a = document.querySelector('.cart-collaterals'), b = null, P = 0;
window.addEventListener('scroll', Ascroll, false);
document.body.addEventListener('scroll', Ascroll, false);
function Ascroll() {
if (b == null) {
var Sa = getComputedStyle(a, ''), s = '';
for (var i = 0; i < Sa.length; i++) {
if (Sa[i].indexOf('overflow') == 0 || Sa[i].indexOf('padding') == 0
@eto4detak
eto4detak / plugins.php
Last active February 4, 2019 20:47
wp php plugins
<?php
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
function your_shipping_method_init() {
if ( ! class_exists( 'WC_Your_Shipping_Method' ) ) {
class WC_Your_Shipping_Method extends WC_Shipping_Method {
/**
* Constructor for your shipping class
@eto4detak
eto4detak / carbon.php
Created February 18, 2019 18:32
wp php carbon
<?php
<?php
use Carbon_Fields\Container;
use Carbon_Fields\Field;
if ( ! function_exists( 'carbon_get_post_meta' ) ) {
function carbon_get_post_meta( $id, $name, $type = null ) {
return false;
}
@eto4detak
eto4detak / shortcode.php
Last active June 22, 2019 06:12
wp php shortcode
<?php
// shortcode ценовой диапозон
add_shortcode( 'divi_price_cat', 'divi_price_cat_shortcode' );
function divi_price_cat_shortcode( $atts ){
$cur_queried_object = get_queried_object();
echo '<pre class="aaa" style="display:none">';
var_dump( $cur_queried_object );
echo '</pre>';
@eto4detak
eto4detak / max_min_price_cat_woo.php
Created February 18, 2019 20:44
woo php min max price category
<?php
// мвкс и мин
function wpp_get_extremes_price_in_product_cat( $term_id ) {
global $wpdb;
$results = $wpdb->get_col( "
SELECT pm.meta_value
FROM {$wpdb->prefix}term_relationships as tr
INNER JOIN {$wpdb->prefix}term_taxonomy as tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
@eto4detak
eto4detak / OAuthClient.php
Created February 25, 2019 08:31
wp OAuth 2.0 Client
<?php
session_start();
// error_reporting(0);
require get_template_directory() . '/inc/vendor/autoload.php';
require get_template_directory() . '/inc/Provider/response.php';
require get_template_directory() . '/inc/Provider/EnvatoUser.php';
require get_template_directory() . '/inc/Provider/Envato.php';
@eto4detak
eto4detak / apply_filters.php
Last active June 22, 2019 06:38
wp php apply_filters
<?php
$text_html = apply_filters( 'the_content', carbon_get_term_meta( $category->term_id, 'crb_mini_text_cat' ) );
// для всех страниц администратора.
add_action('admin_head', 'yamaps_shortcode_tmpl');
// срабатывают условные тэги
@eto4detak
eto4detak / sublimetext.json
Last active May 6, 2019 16:13
sublimetext
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
"font_size": 8,
"ignored_packages":
[
"phpfmt",
"Vintage"
],
"material_theme_compact_sidebar": true,
"preview_on_click": false,
@eto4detak
eto4detak / console.txt
Last active January 31, 2020 00:08
console
////////////////////////////////(window)////////////////////////////////
cd /d d:/
IPconfig
find . -type d | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/" -- tree
////////////////////////////////(mysql)////////////////////////////////
mysql -u root -p wp_online3 < D:\Pro\database.sql
@eto4detak
eto4detak / add_meta_box2.php
Last active August 24, 2019 18:03
wp php add_meta_box
<?php
add_action('add_meta_boxes', 'divie_desc_down_add_custom_box');
function divie_desc_down_add_custom_box(){
$screens = array( 'product' );
add_meta_box( 'divie_desc_down_sectionid', 'Описание под кнопкой', 'divie_desc_down_meta_box_callback', $screens, 'side', 'low' );
}
// HTML код блока 222