Skip to content

Instantly share code, notes, and snippets.

View Prroffessorr's full-sized avatar
🏡
In search of incredible

Andrey Prroffessorr

🏡
In search of incredible
View GitHub Profile
@benbalter
benbalter / wp-db.tutorial.php
Created January 13, 2012 18:41
WordPress DB Tutorial
<?php
//absolute path to wp-load.php, or relative to this script
//e.g., ../wp-core/wp-load.php
include( 'trunk/wp-load.php' );
//grab the WPDB database object, using WP's database
//more info: http://codex.wordpress.org/Class_Reference/wpdb
global $wpdb;
@hitautodestruct
hitautodestruct / readme.md
Last active September 26, 2022 11:25 — forked from anonymous/gist:4344870
Generate a custom structure for Wordpress menus.

This gist is for showing an example of a custom wordpress menu.

If you want to get more from the menu item simply have a look at the $item object. i.e:

// Will return a large object with lots of props like title, url, description, id etc.
var_dump( $item );

This code works on Wordpress 4.1.1 as of 31st of March 2015

@cristianstan
cristianstan / Simple Ajax Login Form.php
Last active July 3, 2024 01:26
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
?>
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
@abegit
abegit / wc_order_status_changes.php
Created February 2, 2016 20:11
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
const LabMath = {
"маточікування": function avarage(arr) {
return arr.reduce((a, b) => a + b, 0) / arr.length;
},
"медіана": function(arr) {
return arr.sort((a, b) => a - b)[Math.floor(arr.length / 2)];
},
"напівсума «крайніх» спостережень": function(arr) {
return (Math.min(...arr) + Math.max(...arr)) / 2;
},
@onuproy
onuproy / gallery-load-more-or-less-images-on-click.markdown
Created June 28, 2019 12:02
Gallery: Load more (or less) images on click
@Prroffessorr
Prroffessorr / Example(Woocommerce).php
Last active January 18, 2020 17:26
Wordpress(Woocommerce):Пример вывода товаров в сайдбаре, которые принадлежат той же категории что и выбранный
<?php
$product_cat_slugs = array();
foreach (get_the_terms($product->ID, 'product_cat') as $term) {
array_push($product_cat_slugs, $term->slug);
}
$args = array(
'posts_per_page' => carbon_get_theme_option('numbers'),//or carbon_get_the_post_meta('numbers')//or just number
'tax_query' => array(
'relation' => 'OR',
@Prroffessorr
Prroffessorr / 1) Displaying product images and gallery.php
Last active February 7, 2021 10:31
WooCommerce ( Product Handling Cheat Sheet ) ( content-single-product.php )
@Prroffessorr
Prroffessorr / 1) Getting a list of categories and subcategories.php
Last active February 20, 2021 15:40
WooCommerce ( Product Handling Cheat Sheet ) ( archive-product.php )
<?php //Получение категорий
$prod_cat_args = array(
'taxonomy' => 'product_cat',
'orderby' => 'id', // здесь по какому полю сортировать
'hide_empty' => false, // скрывать категории без товаров или нет
'parent' => 0 // id родительской категории
);
?>
<ul>
<?php //Получение всего списка категорий
<?php
//Функция удаления стандартных хлебных крошек
function remove_shop_breadcrumbs(){
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
}