Skip to content

Instantly share code, notes, and snippets.

@eto4detak
eto4detak / comment
Created October 7, 2018 15:33
comment //
///////////////////////////////////////////////////////////////////////////////////////////
/////// Show advanced search fields
///////////////////////////////////////////////////////////////////////////////////////////
@eto4detak
eto4detak / update_price.php
Created October 3, 2018 16:55
wp php woo update price
<?php
function divie_all_products_woo_edit(){
$euro_rate = get_option('divie_euro_rate') ? get_option('divie_euro_rate') : '';
$euro_rate = floatval($euro_rate);
if(!empty($euro_rate) && is_float($euro_rate) && $euro_rate > 0){
$args = array(
'post_type' => array( 'product',),
@eto4detak
eto4detak / sort.php
Last active May 30, 2019 14:34
php sort
<?php
function sort_nested_arrays( $array, $args = array('votes' => 'desc') ){
usort( $array, function( $a, $b ) use ( $args ){
$res = 0;
$a = (object) $a;
$b = (object) $b;
foreach( $args as $k => $v ){
@eto4detak
eto4detak / feed.php
Created September 26, 2018 11:31
wp php feed
<?php
add_filter( 'pre_get_posts', 'how_many_posts_display_in_feed' );
function how_many_posts_display_in_feed($query) {
if( ! $query->is_feed || ! $query->is_main_query() )
return;
// этот вариант не работает
// $query->set( 'posts_per_page', 11 );
@eto4detak
eto4detak / youtybe.php
Created September 8, 2018 11:35
youtybe php
<?php
// $YoutubeCode = get_the_content();
$YoutubeCode = 'https://youtu.be/COwlqqErDbY';
$YoutubeCode = 'https://youtu.be/COwlqqErDbY';
preg_match('#(\.be/|/embed/|/v/|/watch\?v=)([A-Za-z0-9_-]{5,11})#', $YoutubeCode, $matches);
if (isset($matches[2]) && $matches[2] != '') {
$YoutubeCode = $matches[2];
}
echo '<img src="http://img.youtube.com/vi/' . $YoutubeCode . '/0.jpg" />';
@eto4detak
eto4detak / wp.media.js
Last active July 14, 2019 10:18
wp js wp.media
// php --- wp_enqueue_media();
jQuery(document).ready(function($) {
frame = wp.media({
title: 'Select Image',
button: {
text: 'Select image',
},
@eto4detak
eto4detak / autozone.php
Last active September 6, 2018 17:24
wp php autozone
<?php
add_action( 'wp_enqueue_scripts', 'my_styles_method35325235' );
add_action('wp_print_footer_scripts', 'autozone_print_footer_color', 99 );
function autozone_print_footer_color() {
global $autozone_opt_val;
?>
<style scoped>
@eto4detak
eto4detak / diviecom.php
Created August 31, 2018 17:32
diviecom
<?php
//добавить для мобилы вывод продуктов
array( "name" => esc_html__( "Number of Products displayed on WooCommerce archive pages", $themename ),
"id" => $shortname . "_woocommerce_archive_num_posts",
"std" => "9",
"type" => "text",
"desc" => esc_html__( "Here you can designate how many WooCommerce products are displayed on the archive page. This option works independently from the Settings > Reading options in wp-admin.", $themename),
"validation_type" => "number"
),
@eto4detak
eto4detak / envato
Created August 30, 2018 08:44
data teme envato
object(stdClass)#234 (6) { ["item_name"]=> string(32) "Autozone - Automotive Car Dealer" ["item_id"]=> string(8) "15911085" ["created_at"]=> string(30) "Mon May 28 05:45:35 +1000 2018" ["buyer"]=> string(11) "RSGDynamics" ["licence"]=> string(15) "Regular License" ["supported_until"]=> string(30) "Mon Nov 26 21:45:35 +1100 2018" }
@eto4detak
eto4detak / sqltable.php
Last active June 12, 2019 21:30
wp php sql table
<?php
// create table
if( !$wpdb->query( $wpdb->prepare("SHOW TABLES LIKE '%s'", $AUTO_license['table_name'] ) ) ){
create_table_key_activate();
}
$table_name = $wpdb->get_blog_prefix() . 'test_table331234';
if($wpdb->query("SHOW TABLES LIKE '$table_name'")){