Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / esc.php
Last active December 23, 2018 22:01
wp php esc
<input type="hidden" name="redirect_to" value="<?php echo esc_url($redirect_to); ?>">
<?php
update_user_meta($current_user->ID, '_psyho_date', sanitize_text_field($form->date));
@eto4detak
eto4detak / timer.js
Created December 14, 2018 23:06
js timer
<h1>Countdown Clock</h1>
<div id="clockdiv">
<div>
<span class="days"></span>
<div class="smalltext">Days</div>
</div>
<div>
<span class="hours"></span>
<div class="smalltext">Hours</div>
</div>
@eto4detak
eto4detak / sql-create-column.php
Last active June 25, 2019 18:40
wp php sql create column
<?php
// $code = 11;
// $department = 2;
// $subdivision = 3;
// $address =4;
// $title =5 ;
// $full_title = 6;
// $short_title =7 ;
@eto4detak
eto4detak / parse-xml.php
Created December 8, 2018 08:53
php parse xml
<?php
public function RecurseXML2($xml = '')
{
function RecurseXML($xml, &$vals, $parent = "")
{
$childs = 0;
$child_count = -1; # Not realy needed.
$arr = array();