This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Пример использования | |
*/ | |
$counts = [ 1, 2, 7 ]; | |
foreach ( $counts as $count ) { | |
echo $count . ' - ' . get_num_ending( $count, [ 'машина', 'машины', 'машин' ] ) . '<br>'; | |
} | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Collection Products | |
* | |
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/related.php. | |
* | |
* HOWEVER, on occasion WooCommerce will need to update template files and you | |
* (the theme developer) will need to copy the new files to your theme to | |
* maintain compatibility. We try to do this as little as possible, but it does | |
* happen. When this occurs the version of the template file will be bumped and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Вывод скидки по купону в подытогах каждого товара | |
* | |
* @param $product_subtotal | |
* @param $product | |
* @param $quantity | |
* @param $cart | |
* | |
* @return string | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( | |
'woocommerce_settings_pages', | |
function ( $setting ) { | |
unset( $setting[1]['args'] ); | |
unset( $setting[2]['args'] ); | |
return $setting; | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_variable_product_bulk_edit_actions', 'set_image_by_attributes', 10 ); | |
function set_image_by_attributes() { | |
global $post, $woocommerce; | |
$attributes = maybe_unserialize( get_post_meta( $post->ID, '_product_attributes', true ) ); | |
$out = ""; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recipe_time( $field_name = '', $field_desc = '', $iso = false ) { | |
$time = get_field( $field_name ) ? get_field( $field_name ) : 1; | |
$hours = floor( $time / 60 ); | |
$minutes = ( $time % 60 ) <= 0 ? '' : $time % 60; | |
$hours_out = ( $hours ) ? $hours . ' ' . get_num_ending( $hours, array( 'час', 'часа', 'часов' ) ) . ' ' : ''; | |
$minutes_out = ( $minutes ) ? $minutes . ' мин' : ''; | |
$hours_iso = ( $hours ) ? $hours . 'H' : ''; | |
$minutes_iso = ( $minutes ) ? $minutes . 'M' : ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function preload_fonts() { | |
$preload = "<link rel='preconnect' href='https://fonts.gstatic.com' crossorigin />\n"; | |
$preload .= sprintf( | |
'<link rel="preload" as="style" href="%1$s" />%2$s', | |
$this->get_add_query_arg( $this->font_args, $this->font_url ), | |
"\n" | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CNWS_Schema { | |
public function __construct() { | |
$this->hooks(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wpcf7_before_send_mail', 'created_post_in_cf7' ); | |
function created_post_in_cf7( $contact_form ) { | |
$title = $_POST['text-title-post'] && ! empty( $_POST['text-title-post'] ) ? sanitize_text_field( $_POST['text-title-post'] ) : ''; | |
$content = $_POST['text-contant-post'] && ! empty( $_POST['text-contant-post'] ) ? wp_strip_all_tags( $_POST['text-contant-post'] ) : ''; | |
$field = $_POST['text-field-post'] && ! empty( $_POST['text-field-post'] ) ? sanitize_text_field( $_POST['text-field-post'] ) : ''; | |
$ars = [ | |
'post_type' => 'post', | |
'post_title' => $title, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Load a template part into a template | |
* | |
* @param string $slug The slug name for the generic template. | |
* @param string $name The name of the specialised template. | |
* @param array $params Any extra params to be passed to the template part. | |
*/ | |
function get_template_part_extended( $slug, $name = null, $params = array() ) { | |
if ( ! empty( $params ) ) { |