'',
'zapnute' => 1,
'identita' => 0,
'vylucene' => '',
'feed' => 1,
);
}
function otto_chat_nastavenia() {
$ulozene = get_option( OTTO_CHAT_VOLBA, array() );
if ( ! is_array( $ulozene ) ) {
$ulozene = array();
}
return wp_parse_args( $ulozene, otto_chat_predvolby() );
}
function otto_chat_woo() {
return function_exists( 'wc_get_products' );
}
function otto_chat_kluc_ok( $kluc ) {
return (bool) preg_match( '/^pk_[0-9a-f]{16,64}$/', (string) $kluc );
}
function otto_chat_vylucene_id( $zoznam ) {
$id = array();
foreach ( preg_split( '/[\s,]+/', (string) $zoznam, -1, PREG_SPLIT_NO_EMPTY ) as $kus ) {
if ( ctype_digit( $kus ) ) {
$id[] = (int) $kus;
}
}
return array_values( array_unique( $id ) );
}
function otto_chat_zobrazit() {
$n = otto_chat_nastavenia();
if ( empty( $n['zapnute'] ) || ! otto_chat_kluc_ok( $n['kluc'] ) ) {
return false;
}
if ( is_admin() || is_feed() || is_robots() || is_trackback() || is_preview() ) {
return false;
}
if ( function_exists( 'is_customize_preview' ) && is_customize_preview() ) {
return false;
}
if ( function_exists( 'wp_is_json_request' ) && wp_is_json_request() ) {
return false;
}
$vylucene = otto_chat_vylucene_id( $n['vylucene'] );
if ( $vylucene && is_singular() ) {
$aktualne = get_queried_object_id();
if ( $aktualne && in_array( (int) $aktualne, $vylucene, true ) ) {
return false;
}
}
return (bool) apply_filters( 'otto_chat_zobrazit', true );
}
function otto_chat_identita() {
$n = otto_chat_nastavenia();
if ( empty( $n['identita'] ) || ! is_user_logged_in() ) {
return array();
}
$u = wp_get_current_user();
if ( ! $u || ! $u->exists() ) {
return array();
}
$udaje = array();
$meno = trim( $u->display_name ? $u->display_name : ( $u->first_name . ' ' . $u->last_name ) );
if ( $meno ) {
$udaje['data-otto-name'] = $meno;
}
if ( is_email( $u->user_email ) ) {
$udaje['data-otto-email'] = $u->user_email;
}
$telefon = get_user_meta( $u->ID, 'billing_phone', true );
if ( is_string( $telefon ) && '' !== trim( $telefon ) ) {
$udaje['data-otto-phone'] = trim( $telefon );
}
return apply_filters( 'otto_chat_identita', $udaje, $u );
}
function otto_chat_footer() {
if ( ! otto_chat_zobrazit() ) {
return;
}
$n = otto_chat_nastavenia();
$identita = otto_chat_identita();
$atributy = array(
'src' => otto_chat_api() . '/widget.js',
'async' => true,
'data-otto-key' => $n['kluc'],
);
if ( $identita ) {
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', true );
}
$atributy = array_merge( $atributy, $identita );
}
if ( otto_chat_feed_zapnuty() && class_exists( 'WC_AJAX' ) && function_exists( 'wc_get_cart_url' ) ) {
$atributy['data-otto-kosik'] = WC_AJAX::get_endpoint( 'add_to_cart' );
$atributy['data-otto-kosik-url'] = wc_get_cart_url();
}
wp_print_script_tag( $atributy );
}
function otto_chat_menu() {
add_options_page(
__( 'Otto - Turns visitors into customers', 'otto-chat' ),
__( 'Otto', 'otto-chat' ),
'manage_options',
'otto-chat',
'otto_chat_stranka'
);
}
function otto_chat_registruj() {
register_setting(
'otto_chat_skupina',
OTTO_CHAT_VOLBA,
array(
'type' => 'array',
'sanitize_callback' => 'otto_chat_ocisti',
'default' => otto_chat_predvolby(),
)
);
}
function otto_chat_ocisti( $vstup ) {
$stare = otto_chat_nastavenia();
$vstup = is_array( $vstup ) ? $vstup : array();
$kluc = isset( $vstup['kluc'] ) ? strtolower( trim( sanitize_text_field( $vstup['kluc'] ) ) ) : '';
if ( '' !== $kluc && ! otto_chat_kluc_ok( $kluc ) ) {
add_settings_error(
OTTO_CHAT_VOLBA,
'otto_kluc',
__( 'The key is not in the right format. It starts with pk_ and you will find it in your Otto panel under Settings, Keys.', 'otto-chat' ),
'error'
);
$kluc = $stare['kluc'];
}
return array(
'kluc' => $kluc,
'zapnute' => empty( $vstup['zapnute'] ) ? 0 : 1,
'identita' => empty( $vstup['identita'] ) ? 0 : 1,
'vylucene' => implode( ', ', otto_chat_vylucene_id( isset( $vstup['vylucene'] ) ? $vstup['vylucene'] : '' ) ),
'feed' => otto_chat_woo() ? ( empty( $vstup['feed'] ) ? 0 : 1 ) : ( empty( $stare['feed'] ) ? 0 : 1 ),
);
}
function otto_chat_over_kluc( $kluc ) {
if ( ! otto_chat_kluc_ok( $kluc ) ) {
return new WP_Error( 'tvar', __( 'The key is not in the right format.', 'otto-chat' ) );
}
$odpoved = wp_remote_get(
otto_chat_api() . '/api/config?key=' . rawurlencode( $kluc ),
array( 'timeout' => 10 )
);
if ( is_wp_error( $odpoved ) ) {
return new WP_Error(
'siet',
sprintf(
/* translators: %s: error message from WordPress */
__( 'Could not connect to Otto: %s', 'otto-chat' ),
$odpoved->get_error_message()
)
);
}
$kod = (int) wp_remote_retrieve_response_code( $odpoved );
if ( 429 === $kod ) {
return new WP_Error( 'pokusy', __( 'Too many attempts. Try again in a minute.', 'otto-chat' ) );
}
if ( 200 !== $kod ) {
return new WP_Error( 'kluc', __( 'Otto does not know this key. Check that you copied all of it.', 'otto-chat' ) );
}
$telo = json_decode( wp_remote_retrieve_body( $odpoved ), true );
if ( ! is_array( $telo ) ) {
return new WP_Error( 'odpoved', __( 'We could not understand the answer from Otto. Try again in a moment.', 'otto-chat' ) );
}
return array(
'meno' => isset( $telo['botName'] ) ? (string) $telo['botName'] : 'Otto',
'jazyk' => isset( $telo['language'] ) ? (string) $telo['language'] : '',
);
}
function otto_chat_spojenie_funguje( $meno, $jazyk ) {
if ( 'sk' === $jazyk ) {
/* translators: %s: name of the assistant */
return sprintf( __( 'The connection works. The assistant is called %s and replies in Slovak.', 'otto-chat' ), $meno );
}
if ( 'cs' === $jazyk ) {
/* translators: %s: name of the assistant */
return sprintf( __( 'The connection works. The assistant is called %s and replies in Czech.', 'otto-chat' ), $meno );
}
if ( 'en' === $jazyk ) {
/* translators: %s: name of the assistant */
return sprintf( __( 'The connection works. The assistant is called %s and replies in English.', 'otto-chat' ), $meno );
}
/* translators: %s: name of the assistant */
return sprintf( __( 'The connection works. The assistant is called %s.', 'otto-chat' ), $meno );
}
function otto_chat_test() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You are not allowed to do this.', 'otto-chat' ) );
}
check_admin_referer( 'otto_chat_test' );
$n = otto_chat_nastavenia();
$stav = otto_chat_over_kluc( $n['kluc'] );
$adresa = admin_url( 'options-general.php?page=otto-chat' );
if ( is_wp_error( $stav ) ) {
set_transient( 'otto_chat_test', array( 'ok' => 0, 'sprava' => $stav->get_error_message() ), 60 );
} else {
set_transient( 'otto_chat_test', array( 'ok' => 1, 'sprava' => otto_chat_spojenie_funguje( $stav['meno'], $stav['jazyk'] ) ), 60 );
}
wp_safe_redirect( $adresa );
exit;
}
function otto_chat_jazyk() {
$jazyk = substr( (string) get_user_locale(), 0, 2 );
return in_array( $jazyk, array( 'sk', 'cs', 'en' ), true ) ? $jazyk : 'en';
}
function otto_chat_hosty( $hosty ) {
$host = wp_parse_url( otto_chat_api(), PHP_URL_HOST );
if ( $host ) {
$hosty[] = $host;
}
return $hosty;
}
function otto_chat_pripojit() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You are not allowed to do this.', 'otto-chat' ) );
}
check_admin_referer( 'otto_chat_pripojit' );
$stav = wp_generate_password( 32, false, false );
set_transient( 'otto_chat_stav_' . get_current_user_id(), $stav, 15 * MINUTE_IN_SECONDS );
$parametre = array(
'web' => home_url( '/' ),
'navrat' => add_query_arg(
array(
'action' => 'otto_chat_pripojene',
'_wpnonce' => wp_create_nonce( 'otto_chat_pripojene' ),
),
admin_url( 'admin-post.php' )
),
'stav' => $stav,
'jazyk' => otto_chat_jazyk(),
);
if ( otto_chat_feed_zapnuty() ) {
$parametre['feed'] = rest_url( 'otto-chat/v1/feed' );
}
add_filter( 'allowed_redirect_hosts', 'otto_chat_hosty' );
wp_safe_redirect( otto_chat_api() . '/wordpress-pripojenie?' . http_build_query( $parametre, '', '&', PHP_QUERY_RFC3986 ) );
exit;
}
function otto_chat_pripojene() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You are not allowed to do this.', 'otto-chat' ) );
}
check_admin_referer( 'otto_chat_pripojene' );
$kluc_stavu = 'otto_chat_stav_' . get_current_user_id();
$cakany = get_transient( $kluc_stavu );
delete_transient( $kluc_stavu );
$stav = isset( $_GET['otto_stav'] ) ? sanitize_text_field( wp_unslash( $_GET['otto_stav'] ) ) : '';
$kluc = isset( $_GET['otto_kluc'] ) ? strtolower( sanitize_text_field( wp_unslash( $_GET['otto_kluc'] ) ) ) : '';
if ( ! is_string( $cakany ) || '' === $cakany || ! hash_equals( $cakany, $stav ) ) {
$vysledok = array( 'ok' => 0, 'sprava' => __( 'The connection has expired. Click Connect to Otto again.', 'otto-chat' ) );
} elseif ( isset( $_GET['otto_chyba'] ) ) {
$vysledok = array( 'ok' => 0, 'sprava' => __( 'You cancelled the connection. Nothing has changed.', 'otto-chat' ) );
} elseif ( ! otto_chat_kluc_ok( $kluc ) ) {
$vysledok = array( 'ok' => 0, 'sprava' => __( 'Otto did not send a valid key. Click Connect to Otto again.', 'otto-chat' ) );
} else {
$n = otto_chat_nastavenia();
$n['kluc'] = $kluc;
$n['zapnute'] = 1;
update_option( OTTO_CHAT_VOLBA, $n );
$sprava = __( 'Connected. Otto now shows on your website.', 'otto-chat' );
if ( ! empty( $_GET['otto_feed'] ) ) {
$sprava .= ' ' . __( 'It will load your products from WooCommerce within a few minutes.', 'otto-chat' );
}
$vysledok = array( 'ok' => 1, 'sprava' => $sprava );
}
set_transient( 'otto_chat_test', $vysledok, 60 );
wp_safe_redirect( admin_url( 'options-general.php?page=otto-chat' ) );
exit;
}
function otto_chat_stranka() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$n = otto_chat_nastavenia();
$test = get_transient( 'otto_chat_test' );
if ( $test ) {
delete_transient( 'otto_chat_test' );
}
?>
' . esc_html__( 'Create one', 'otto-chat' ) . ''
);
?>
'
. esc_html__( 'Settings', 'otto-chat' ) . '';
array_unshift( $odkazy, $nas );
return $odkazy;
}
function otto_chat_upozornenie() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$obrazovka = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
if ( $obrazovka && 'settings_page_otto-chat' === $obrazovka->id ) {
return;
}
$n = otto_chat_nastavenia();
if ( otto_chat_kluc_ok( $n['kluc'] ) ) {
return;
}
?>
'
. esc_html__( 'Connect to Otto', 'otto-chat' ) . ''
);
?>
]*>.*?\1\s*>@si', ' ', $text );
$text = (string) preg_replace( '/<[^<>]*>/', ' ', $text );
$text = otto_chat_feed_platne( html_entity_decode( $text, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) );
return trim( (string) preg_replace( '/[\s\x{00A0}]+/u', ' ', $text ) );
}
function otto_chat_feed_cena( $kus, $cena, $mena ) {
$suma = wc_get_price_to_display( $kus, array( 'price' => $cena ) );
return number_format( (float) $suma, 2, '.', '' ) . ' ' . $mena;
}
function otto_chat_feed_dostupnost( $kus ) {
$stavy = array(
'instock' => 'in_stock',
'outofstock' => 'out_of_stock',
'onbackorder' => 'backorder',
);
$stav = (string) $kus->get_stock_status();
return isset( $stavy[ $stav ] ) ? $stavy[ $stav ] : 'in_stock';
}
function otto_chat_feed_popis( $kus, $rodic ) {
$zaklad = $rodic ? $rodic : $kus;
$zdroje = array( $rodic ? $kus->get_description() : '', $zaklad->get_short_description(), $zaklad->get_description() );
$casti = array();
foreach ( $zdroje as $zdroj ) {
$text = otto_chat_feed_cisty( $zdroj );
if ( '' !== $text && ! in_array( $text, $casti, true ) ) {
$casti[] = $text;
}
}
$popis = implode( ' ', $casti );
return mb_strlen( $popis, 'UTF-8' ) > 5000 ? rtrim( mb_substr( $popis, 0, 5000, 'UTF-8' ) ) : $popis;
}
function otto_chat_feed_kategoria( $produkt ) {
$cesta = array();
foreach ( (array) $produkt->get_category_ids() as $id ) {
$predkovia = array_map( 'intval', (array) get_ancestors( (int) $id, 'product_cat', 'taxonomy' ) );
$kandidat = array_merge( array_reverse( $predkovia ), array( (int) $id ) );
if ( count( $kandidat ) > count( $cesta ) ) {
$cesta = $kandidat;
}
}
$mena = array();
foreach ( $cesta as $id ) {
$kategoria = get_term( $id, 'product_cat' );
$meno = $kategoria && ! is_wp_error( $kategoria ) ? otto_chat_feed_cisty( $kategoria->name ) : '';
if ( '' !== $meno ) {
$mena[] = $meno;
}
}
return implode( ' > ', $mena );
}
function otto_chat_feed_znacka( $produkt ) {
foreach ( array( 'product_brand', 'pwb-brand', 'yith_product_brand' ) as $taxonomia ) {
$znacky = taxonomy_exists( $taxonomia ) ? get_the_terms( $produkt->get_id(), $taxonomia ) : false;
if ( is_array( $znacky ) && $znacky ) {
$znacka = otto_chat_feed_cisty( reset( $znacky )->name );
if ( '' !== $znacka ) {
return $znacka;
}
}
}
foreach ( array( 'pa_brand', 'pa_znacka', 'brand', 'znacka' ) as $atribut ) {
$znacka = otto_chat_feed_cisty( $produkt->get_attribute( $atribut ) );
if ( '' !== $znacka ) {
return $znacka;
}
}
return '';
}
function otto_chat_feed_hodnoty( $varianta ) {
$hodnoty = array();
foreach ( (array) $varianta->get_attributes() as $nazov => $hodnota ) {
$hodnota = is_scalar( $hodnota ) ? (string) $hodnota : '';
if ( '' !== $hodnota && taxonomy_exists( (string) $nazov ) ) {
$termin = get_term_by( 'slug', $hodnota, (string) $nazov );
$hodnota = $termin && ! is_wp_error( $termin ) ? $termin->name : $hodnota;
}
$hodnota = otto_chat_feed_cisty( $hodnota );
if ( '' !== $hodnota ) {
$hodnoty[] = $hodnota;
}
}
return $hodnoty;
}
function otto_chat_feed_varianty( $produkt ) {
$varianty = array();
foreach ( (array) $produkt->get_children() as $id ) {
$varianta = wc_get_product( $id );
if ( is_object( $varianta ) && 'publish' === $varianta->get_status() && '' !== (string) $varianta->get_price() ) {
$varianty[] = $varianta;
}
}
return $varianty;
}
function otto_chat_feed_polozka( $kus, $rodic, $mena ) {
$zaklad = $rodic ? $rodic : $kus;
$hodnoty = $rodic ? otto_chat_feed_hodnoty( $kus ) : array();
$obrazok = $kus->get_image_id() ? $kus->get_image_id() : $zaklad->get_image_id();
$polozka = array(
'g:id' => (string) $kus->get_id(),
'title' => trim( otto_chat_feed_cisty( $zaklad->get_name() ) . ' ' . implode( ', ', $hodnoty ) ),
'description' => otto_chat_feed_popis( $kus, $rodic ),
'link' => (string) $kus->get_permalink(),
'g:image_link' => $obrazok ? (string) wp_get_attachment_url( $obrazok ) : '',
'g:price' => '',
'g:sale_price' => '',
'g:sale_price_effective_date' => '',
'g:availability' => otto_chat_feed_dostupnost( $kus ),
'g:product_type' => otto_chat_feed_kategoria( $zaklad ),
'g:brand' => otto_chat_feed_znacka( $zaklad ),
'g:item_group_id' => $rodic ? (string) $rodic->get_id() : '',
);
$bezna = (string) $kus->get_regular_price();
$bezna = '' === $bezna ? (string) $kus->get_price() : $bezna;
if ( '' === $bezna ) {
return $polozka;
}
$polozka['g:price'] = otto_chat_feed_cena( $kus, $bezna, $mena );
$akciova = (string) $kus->get_sale_price();
if ( '' === $akciova || ! $kus->is_on_sale() ) {
return $polozka;
}
$polozka['g:sale_price'] = otto_chat_feed_cena( $kus, $akciova, $mena );
$od = $kus->get_date_on_sale_from();
$do = $kus->get_date_on_sale_to();
if ( $do instanceof DateTimeInterface ) {
$polozka['g:sale_price_effective_date'] = ( $od instanceof DateTimeInterface ? $od->format( 'c' ) : gmdate( 'c' ) ) . '/' . $do->format( 'c' );
}
return $polozka;
}
function otto_chat_feed_polozky() {
$polozky = array();
$mena = get_woocommerce_currency();
$strana = 1;
do {
$davka = wc_get_products(
array(
'status' => 'publish',
'limit' => 200,
'page' => $strana,
'orderby' => 'ID',
'order' => 'ASC',
'has_password' => false,
)
);
$davka = is_array( $davka ) ? $davka : array();
foreach ( $davka as $produkt ) {
if ( ! is_object( $produkt ) || 'hidden' === $produkt->get_catalog_visibility() || $produkt->is_type( 'grouped' ) ) {
continue;
}
$kusy = is_a( $produkt, 'WC_Product_Variable' ) ? otto_chat_feed_varianty( $produkt ) : array( $produkt );
foreach ( $kusy as $kus ) {
$polozka = otto_chat_feed_polozka( $kus, $kus === $produkt ? null : $produkt, $mena );
$polozka = apply_filters( 'otto_chat_feed_polozka', $polozka, $kus, $produkt );
if ( is_array( $polozka ) && ! empty( $polozka['g:id'] ) && ! empty( $polozka['title'] ) ) {
$polozky[] = otto_chat_feed_prvky( $polozka );
}
if ( count( $polozky ) >= 5000 ) {
return $polozky;
}
}
}
$strana++;
} while ( count( $davka ) >= 200 );
return $polozky;
}
function otto_chat_feed_prvky( $polozka ) {
$prvky = array();
foreach ( $polozka as $nazov => $hodnota ) {
if ( is_scalar( $hodnota ) && '' !== (string) $hodnota && preg_match( '/^(g:)?[a-z][a-z_]*$/', (string) $nazov ) ) {
$prvky[ (string) $nazov ] = otto_chat_feed_platne( (string) $hodnota );
}
}
return $prvky;
}
function otto_chat_feed_zbieraj() {
if ( function_exists( 'wc_set_time_limit' ) ) {
wc_set_time_limit( 120 );
}
$feed = array(
'kanal' => otto_chat_feed_prvky(
array(
'title' => otto_chat_feed_cisty( get_bloginfo( 'name' ) ),
'link' => home_url( '/' ),
'description' => otto_chat_feed_cisty( get_bloginfo( 'description' ) ),
'generator' => 'otto-chat ' . OTTO_CHAT_VERZIA,
)
),
'polozky' => otto_chat_feed_polozky(),
);
$feed['etag'] = '"' . md5( (string) wp_json_encode( array( $feed['kanal'], $feed['polozky'] ) ) ) . '"';
return $feed;
}
function otto_chat_feed() {
$feed = get_transient( OTTO_CHAT_FEED );
if ( is_array( $feed ) && isset( $feed['kanal'], $feed['polozky'], $feed['etag'] ) ) {
return $feed;
}
$feed = otto_chat_feed_zbieraj();
set_transient( OTTO_CHAT_FEED, $feed, HOUR_IN_SECONDS );
return $feed;
}
function otto_chat_feed_prvok( $nazov, $hodnota ) {
echo '<' . esc_xml( $nazov ) . '>' . esc_xml( $hodnota ) . '' . esc_xml( $nazov ) . ">\n";
}
function otto_chat_feed_vypis( $feed ) {
echo '' . "\n";
echo '' . "\n";
echo "\n";
foreach ( $feed['kanal'] as $nazov => $hodnota ) {
otto_chat_feed_prvok( $nazov, $hodnota );
}
foreach ( $feed['polozky'] as $polozka ) {
echo "- \n";
foreach ( $polozka as $nazov => $hodnota ) {
echo "\t";
otto_chat_feed_prvok( $nazov, $hodnota );
}
echo "
\n";
}
echo "\n";
echo "\n";
}
function otto_chat_feed_zostav() {
ob_start();
otto_chat_feed_vypis( otto_chat_feed() );
return (string) ob_get_clean();
}
function otto_chat_feed_zmaz() {
delete_transient( OTTO_CHAT_FEED );
}
function otto_chat_feed_trasa() {
if ( ! otto_chat_feed_zapnuty() ) {
return;
}
register_rest_route(
'otto-chat/v1',
'/feed',
array(
'methods' => 'GET',
'callback' => 'otto_chat_feed_odpoved',
'permission_callback' => '__return_true',
)
);
}
function otto_chat_feed_odpoved( $poziadavka ) {
$feed = otto_chat_feed();
$zhoda = false;
foreach ( explode( ',', (string) $poziadavka->get_header( 'if_none_match' ) ) as $kus ) {
$zhoda = $zhoda || preg_replace( '/^W\//i', '', trim( $kus ) ) === $feed['etag'];
}
$odpoved = new WP_REST_Response( $zhoda ? null : $feed, $zhoda ? 304 : 200 );
$odpoved->header( 'Content-Type', 'application/xml; charset=UTF-8' );
$odpoved->header( 'ETag', $feed['etag'] );
$odpoved->header( 'X-Robots-Tag', 'noindex' );
return $odpoved;
}
function otto_chat_feed_posli( $poslane, $vysledok, $poziadavka ) {
if ( $poslane || ! ( $vysledok instanceof WP_REST_Response ) || ! ( $poziadavka instanceof WP_REST_Request ) ) {
return $poslane;
}
if ( '/otto-chat/v1/feed' !== $vysledok->get_matched_route() ) {
return $poslane;
}
$feed = $vysledok->get_data();
$cely = is_array( $feed ) && isset( $feed['kanal'], $feed['polozky'] );
if ( ! $cely && 304 !== (int) $vysledok->get_status() ) {
return $poslane;
}
if ( $cely && 'HEAD' !== $poziadavka->get_method() ) {
otto_chat_feed_vypis( $feed );
}
return true;
}
add_action( 'init', 'otto_chat_preklady' );
add_action( 'wp_footer', 'otto_chat_footer', 20 );
add_action( 'admin_menu', 'otto_chat_menu' );
add_action( 'admin_init', 'otto_chat_registruj' );
add_action( 'admin_post_otto_chat_test', 'otto_chat_test' );
add_action( 'admin_post_otto_chat_pripojit', 'otto_chat_pripojit' );
add_action( 'admin_post_otto_chat_pripojene', 'otto_chat_pripojene' );
add_action( 'admin_post_nopriv_otto_chat_pripojene', 'auth_redirect' );
add_action( 'admin_notices', 'otto_chat_upozornenie' );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'otto_chat_odkazy' );
add_action( 'rest_api_init', 'otto_chat_feed_trasa' );
add_filter( 'rest_pre_serve_request', 'otto_chat_feed_posli', 10, 3 );
add_action( 'save_post_product', 'otto_chat_feed_zmaz' );
add_action( 'woocommerce_update_product', 'otto_chat_feed_zmaz' );
add_action( 'woocommerce_update_product_variation', 'otto_chat_feed_zmaz' );
add_action( 'woocommerce_product_set_stock', 'otto_chat_feed_zmaz' );
add_action( 'woocommerce_variation_set_stock', 'otto_chat_feed_zmaz' );
add_action( 'woocommerce_product_set_stock_status', 'otto_chat_feed_zmaz' );
add_action( 'woocommerce_variation_set_stock_status', 'otto_chat_feed_zmaz' );
add_action( 'deleted_post', 'otto_chat_feed_zmaz' );
add_action( 'trashed_post', 'otto_chat_feed_zmaz' );
add_action( 'add_option_' . OTTO_CHAT_VOLBA, 'otto_chat_feed_zmaz' );
add_action( 'update_option_' . OTTO_CHAT_VOLBA, 'otto_chat_feed_zmaz' );