first commit

This commit is contained in:
miroman-afk
2021-04-21 15:44:35 +03:00
commit ecd15535cd
18 changed files with 1884 additions and 0 deletions

724
cpo/default.php Normal file
View File

@@ -0,0 +1,724 @@
<?php
$row_id = getToken(8);
$column_1_id = getToken(8);
$column_2_id = getToken(8);
return [
[
'id' => $row_id,
'order' => 0,
'obj_type' => 'module',
'pid' => NULL,
'settings' => [
'general' => [
'status' => [
'sync' => [
'type' => 'none',
],
],
'main' => [
'width_type' => 'auto',
'width' => [
'value' => '',
'unit' => 'px',
],
],
],
'style' => [
'text' => [
'color' => $text_color,
'text_align' => '',
],
'font' => [
'font_family' => 'inherit',
'font_style' => 'inherit',
'font_weight' => '',
'font_size' => [
'value' => '',
'unit' => 'px',
],
'letter_spacing' => '',
'line_height' => '',
],
'links' => [
'color' => '',
'color_hover' => '',
],
'background' => [
'background_type' => '',
'background_color' => '',
'background_image' => [
'url' => '',
'id' => 0,
'repeat' => '',
'position' => '',
'attachment' => '',
'size' => '',
],
],
'border' => [
'border_unit' => 'px',
'border_top' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_bottom' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_left' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_right' => [
'style' => 'none',
'width' => '',
'color' => '',
],
],
],
'advanced' => [
'layout' => [
'margin' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
'padding' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => '',
],
],
],
'title' => 'Row',
'type' => 'row',
'columns' => [
[
'id' => $column_1_id,
'order' => 0,
'obj_type' => 'module',
'parentRowId' => $row_id,
'pid' => NULL,
'settings' => [
'general' => [
'status' => [
'sync' => [
'type' => 'none',
],
],
'main' => [
'width' => [
'value' => '100',
'unit' => '%',
],
'float' => 'left',
],
],
'style' => [
'background' => [
'background_type' => '',
'background_color' => '',
'background_image' => [
'url' => '',
'repeat' => '',
'position' => '',
'attachment' => '',
'size' => '',
],
],
'border' => [
'border_unit' => 'px',
'border_top' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_bottom' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_left' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_right' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'radius' => [
'value' => '',
'unit' => 'px',
],
],
],
'advanced' => [
'layout' => [
'margin' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
'padding' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => '',
],
],
],
'title' => 'Column',
'type' => 'column',
'modules' => [
[
'id' => getToken(8),
'order' => 0,
'obj_type' => 'module',
'parentColumnId' => $column_1_id,
'parentRowId' => $row_id,
'pid' => NULL,
'settings' => [
'general' => [
'status' => [
'sync' => [
'type' => 'none',
],
],
'main' => [
'content' => $unit_text,
],
],
'style' => [
'text' => [
'color' => '',
'text_align' => '',
],
'font' => [
'font_family' => 'inherit',
'font_style' => 'inherit',
'font_weight' => $unit_text_weight,
'font_size' =>
[
'value' => $unit_text_size,
'unit' => 'px',
],
'letter_spacing' => '',
'line_height' => '',
],
],
'advanced' => [
'layout' => [
'margin' => [
'top' => '0',
'right' => '0',
'bottom' => '0',
'left' => '0',
'unit' => 'px',
],
'padding' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => '',
],
],
],
'title' => 'Paragraph',
'type' => 'text',
],
],
],
[
'id' => $column_2_id,
'order' => 1,
'obj_type' => 'module',
'parentRowId' => $row_id,
'pid' => 0,
'settings' => [
'general' => [
'status' => [
'sync' => [
'type' => 'none',
],
],
'main' => [
'width' =>
[
'value' => '100',
'unit' => '%',
],
'float' => 'left',
],
],
'style' => [
'background' => [
'background_type' => '',
'background_color' => '',
'background_image' =>
[
'url' => '',
'repeat' => '',
'position' => '',
'attachment' => '',
'size' => '',
],
],
'border' => [
'border_unit' => 'px',
'border_top' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_bottom' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_left' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'border_right' => [
'style' => 'none',
'width' => '',
'color' => '',
],
'radius' => [
'value' => '',
'unit' => 'px',
],
],
],
'advanced' => [
'layout' => [
'margin' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
'padding' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => '',
],
],
],
'title' => 'Column',
'type' => 'column',
'modules' => [
[
'id' => getToken(8),
'order' => 0,
'obj_type' => 'option',
'parentColumnId' => $column_2_id,
'parentRowId' => $row_id,
'pid' => $post_unit_dishes_id,
'settings' => [
'general' => [
'status' => [
'sync' => [
'type' => 'none',
'pid' => '0',
],
],
'main' => [
'width_px' => '42',
'height_px' => '',
'content' => '',
],
],
'style' => [
'label' => [
'color' => '',
'text_align_label' => '',
'font_family' => 'inherit',
'font_weight' => '',
'font_size_label' => [
'value' => '',
'unit' => 'px',
],
],
'description' => [
'color' => '',
'font_weight' => '',
'font_size_desc' => [
'value' => '',
'unit' => 'px',
],
],
'font' => [
'color' => $text_color,
'color_hover' => '',
'color_active' => '',
'text_align' => 'center',
'font_family' => 'inherit',
'font_style' => 'inherit',
'font_weight' => '400',
'font_size' => [
'value' => '14',
'unit' => 'px',
],
'letter_spacing' => '',
],
'background' => [
'color' => '',
'color_hover' => '',
'color_active' => '',
],
'border' => [
'color' => $border_color,
'color_hover' => $text_color,
'color_active' => $text_color,
'width_px' => '2',
'offset_px' => '2',
'gap_px' => '',
],
'text_mode_item' => [
'padding' => [
'top' => '',
'right' => '15',
'bottom' => '',
'left' => '15',
'unit' => 'px',
],
],
],
'advanced' => [
'layout' => [
'margin' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => '',
],
],
'cpo_general' => [
'main' => [
'cpo_slug' => $post_unit_dishes_slug,
'cpo_is_required' => 'no',
'cpo_mode_radio' => 'classic',
'cpo_geom_radio' => 'circle',
'cpo_is_changeimage' => 'no',
'cpo_is_imagify' => 'no',
'cpo_is_resetbutton' => 'no',
'cpo_resetbutton_text' => 'Очистить',
'cpo_encoded_image' => '',
'cpo_notice_text' => '',
],
'advanced' => [
'cpo_label' => '',
'cpo_label_tag' => 'label',
'cpo_order_label' => '',
'cpo_is_tooltip' => 'no',
'cpo_tooltip_type' => 'classic',
'cpo_tooltip' => '',
'cpo_tooltip_image' =>
[
'url' => '',
'id' => '0',
'alt' => '',
],
'cpo_tooltip_class' => '',
'cpo_enable_cartedit' => 'no',
'cpo_order_visibility' => 'no',
],
],
'cpo_suboptions' => [
'data' => [
'cpo_radio_options' => $unit_dishes_items,
],
],
'cpo_rules' => [
'main' => [
'cpo_is_sc' => 'no',
'cpo_sc_default' => 'hide',
],
'data' => '',
],
'cpo_conditional' => [
'main' => [
'cpo_is_fc' => 'no',
'cpo_fc_default' => 'hide',
'cpo_fc_scheme' => '',
],
],
'cpo_validation' => [
'main' => [
'cpo_validation_msg' => [
'req' => '',
'custom' => '',
],
],
'logic' => [
'cpo_vc_scheme' => [],
],
],
],
'title' => 'Радио кнопки',
'type' => 'radio',
],
[
'id' => getToken(8),
'order' => 1,
'obj_type' => 'module',
'parentColumnId' => $column_2_id,
'parentRowId' => $row_id,
'pid' => NULL,
'settings' => [
'general' => [
'status' => [
'sync' => [
'type' => 'none',
],
],
'main' => [
'content' => $modificators_text,
],
],
'style' => [
'text' => [
'color' => '',
'text_align' => '',
],
'font' => [
'font_family' => 'inherit',
'font_style' => 'inherit',
'font_weight' => $modificators_text_weight,
'font_size' => [
'value' => $modificators_text_size,
'unit' => 'px',
],
'letter_spacing' => '',
'line_height' => '',
],
],
'advanced' => [
'layout' => [
'margin' => [
'top' => '0',
'right' => '0',
'bottom' => '0',
'left' => '0',
'unit' => 'px',
],
'padding' => [
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => '',
],
],
],
'title' => 'Параграф',
'type' => 'text',
],
[
'id' => getToken(8),
'order' => 2,
'obj_type' => 'option',
'parentColumnId' => $column_2_id,
'parentRowId' => $row_id,
'pid' => $post_modificators_id,
'settings' => [
'general' => [
'status' => [
'sync' => [
'type' => 'none',
'pid' => '0',
],
],
'main' => [
'width_px' => '',
'height_px' => '',
'content' => '',
],
],
'style' => [
'label' => [
'color' => '',
'text_align_label' => '',
'font_family' => 'inherit',
'font_weight' => '',
'font_size_label' => [
'value' => '',
'unit' => 'px',
],
],
'description' => [
'color' => '',
'font_weight' => '',
'font_size_desc' => [
'value' => '',
'unit' => 'px',
],
],
'font' => [
'color' => $text_color,
'color_hover' => '',
'color_active' => '',
'text_align' => 'center',
'font_family' => 'inherit',
'font_style' => 'inherit',
'font_weight' => '400',
'font_size' => [
'value' => '14',
'unit' => 'px',
],
'letter_spacing' => '',
],
'background' => [
'color' => '',
'color_hover' => '',
'color_active' => '',
],
'border' => [
'color' => $border_color,
'color_hover' => $text_color,
'color_active' => $text_color,
'width_px' => '2',
'offset_px' => '',
'gap_px' => '2',
],
'text_mode_item' => [
'padding' => [
'top' => '',
'right' => '15',
'bottom' => '',
'left' => '15',
'unit' => 'px',
],
],
],
'advanced' => [
'layout' => [
'margin' => [
'top' => '10',
'right' => '10',
'bottom' => '10',
'left' => '10',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => 'product-modificator',
],
],
'cpo_general' => [
'main' => [
'cpo_slug' => $post_modificators_slug,
'cpo_is_required' => 'no',
'cpo_mode_checkbox' => 'text',
'cpo_geom_checkbox' => 'square',
'cpo_is_changeimage' => 'no',
'cpo_notice_text' => '',
],
'advanced' => [
'cpo_label' => '',
'cpo_label_tag' => 'label',
'cpo_order_label' => '',
'cpo_is_tooltip' => 'no',
'cpo_tooltip_type' => 'classic',
'cpo_tooltip' => '',
'cpo_tooltip_image' => [
'url' => '',
'id' => '0',
'alt' => '',
],
'cpo_tooltip_class' => '',
'cpo_enable_cartedit' => 'no',
'cpo_order_visibility' => 'no',
],
],
'cpo_suboptions' => [
'data' => [
'cpo_radio_options' => $modificators_items,
],
],
'cpo_rules' => [
'main' => [
'cpo_is_sc' => 'no',
'cpo_sc_default' => 'hide',
],
'data' => '',
],
'cpo_conditional' => [
'main' => [
'cpo_is_fc' => 'no',
'cpo_fc_default' => 'hide',
'cpo_fc_scheme' => '',
],
],
'cpo_validation' => [
'main' => [
'cpo_validation_msg' => [
'req' => '',
'custom' => '',
],
],
'logic' => [
'cpo_vc_extra' => '',
],
],
],
'title' => 'Чекбоксы',
'type' => 'checkbox',
],
],
],
],
],
];

View File

@@ -0,0 +1,17 @@
<?php
return [
'layout' => [
'margin' => [
'top' => '10',
'right' => '10',
'bottom' => '10',
'left' => '10',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => 'product-modificator',
]
];

View File

@@ -0,0 +1,9 @@
<?php
return [
'main' => [
'cpo_is_fc' => 'no',
'cpo_fc_default' => 'hide',
'cpo_fc_scheme' => '',
]
];

View File

@@ -0,0 +1,28 @@
<?php
return [
'main' => [
'cpo_slug' => '',
'cpo_is_required' => 'no',
'cpo_mode_checkbox' => 'text',
'cpo_geom_checkbox' => 'square',
'cpo_is_changeimage' => 'no',
'cpo_notice_text' => '',
],
'advanced' => [
'cpo_label' => '',
'cpo_label_tag' => 'label',
'cpo_order_label' => $modificators_text,
'cpo_is_tooltip' => 'no',
'cpo_tooltip_type' => 'classic',
'cpo_tooltip' => '',
'cpo_tooltip_image' => [
'url' => '',
'id' => '0',
'alt' => '',
],
'cpo_tooltip_class' => '',
'cpo_enable_cartedit' => 'no',
'cpo_order_visibility' => 'no',
]
];

View File

@@ -0,0 +1,9 @@
<?php
return [
'main' => [
'width_px' => '42',
'height_px' => '',
'content' => ''
]
];

View File

@@ -0,0 +1,9 @@
<?php
return [
'main' => [
'cpo_is_sc' => 'no',
'cpo_sc_default' => 'hide',
],
'data' => ''
];

View File

@@ -0,0 +1,58 @@
<?php
return [
'label' => [
'color' => '',
'text_align_label' => '',
'font_family' => 'inherit',
'font_weight' => '',
'font_size_label' => [
'value' => '',
'unit' => 'px',
],
],
'description' => [
'color' => '',
'font_weight' => '',
'font_size_desc' => [
'value' => '',
'unit' => 'px',
],
],
'font' => [
'color' => $text_color,
'color_hover' => '',
'color_active' => '',
'text_align' => 'center',
'font_family' => 'inherit',
'font_style' => 'inherit',
'font_weight' => $modificators_text_weight,
'font_size' => [
'value' => $modificators_text_size,
'unit' => 'px',
],
'letter_spacing' => '',
],
'background' => [
'color' => '',
'color_hover' => '',
'color_active' => '',
],
'border' => [
'color' => $border_color,
'color_hover' => $text_color,
'color_active' => $text_color,
'width_px' => '1',
'offset_px' => '1',
'gap_px' => '',
],
'text_mode_item' => [
'padding' => [
'top' => '',
'right' => '15',
'bottom' => '',
'left' => '15',
'unit' => 'px',
]
]
];

View File

@@ -0,0 +1,13 @@
<?php
return [
'main' => [
'cpo_validation_msg' => [
'req' => '',
'custom' => '',
],
],
'logic' => [
'cpo_vc_extra' => '',
],
];

17
cpo/units-advanced.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
return [
'layout' => [
'margin' => [
'top' => '10',
'right' => '10',
'bottom' => '10',
'left' => '10',
'unit' => 'px',
],
],
'selectors' => [
'id_name' => '',
'class_name' => 'product-unit',
],
];

View File

@@ -0,0 +1,9 @@
<?php
return [
'main' => [
'cpo_is_fc' => 'no',
'cpo_fc_default' => 'hide',
'cpo_fc_scheme' => ''
]
];

View File

@@ -0,0 +1,28 @@
<?php
return [
'main' => [
'cpo_slug' => '',
'cpo_is_required' => 'no',
'cpo_mode_checkbox' => 'text',
'cpo_geom_checkbox' => 'square',
'cpo_is_changeimage' => 'no',
'cpo_notice_text' => '',
],
'advanced' => [
'cpo_label' => '',
'cpo_label_tag' => 'label',
'cpo_order_label' => $unit_text,
'cpo_is_tooltip' => 'no',
'cpo_tooltip_type' => 'classic',
'cpo_tooltip' => '',
'cpo_tooltip_image' => [
'url' => '',
'id' => '0',
'alt' => '',
],
'cpo_tooltip_class' => '',
'cpo_enable_cartedit' => 'no',
'cpo_order_visibility' => 'no',
]
];

9
cpo/units-general.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
return [
'main' => [
'width_px' => '42',
'height_px' => '',
'content' => ''
]
];

9
cpo/units-rules.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
return [
'main' => [
'cpo_is_sc' => 'no',
'cpo_sc_default' => 'hide',
],
'data' => ''
];

58
cpo/units-style.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
return [
'label' => [
'color' => '',
'text_align_label' => '',
'font_family' => 'inherit',
'font_weight' => '',
'font_size_label' => [
'value' => '',
'unit' => 'px',
],
],
'description' => [
'color' => '',
'font_weight' => '',
'font_size_desc' => [
'value' => '',
'unit' => 'px',
],
],
'font' => [
'color' => $text_color,
'color_hover' => '',
'color_active' => '',
'text_align' => 'center',
'font_family' => 'inherit',
'font_style' => 'inherit',
'font_weight' => $unit_text_weight,
'font_size' => [
'value' => $unit_text_size,
'unit' => 'px',
],
'letter_spacing' => '',
],
'background' => [
'color' => '',
'color_hover' => '',
'color_active' => '',
],
'border' => [
'color' => $border_color,
'color_hover' => $text_color,
'color_active' => $text_color,
'width_px' => '2',
'offset_px' => '2',
'gap_px' => '',
],
'text_mode_item' => [
'padding' => [
'top' => '',
'right' => '15',
'bottom' => '',
'left' => '15',
'unit' => 'px',
],
]
];

13
cpo/units-validation.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
return [
'main' => [
'cpo_validation_msg' => [
'req' => '',
'custom' => '',
],
],
'logic' => [
'cpo_vc_extra' => '',
],
];

681
hrc-webcommerce.php Normal file
View File

@@ -0,0 +1,681 @@
<?php
/**
* Plugin Name: HRC WebCommerce
* Plugin URI: https://hrc.by/
* Description: Integrate HRC system into HRC WebCommerce
* Version: 1.0.0
* Author: HRC Team
* Author URI: https://hrc.by
* Requires at least: 5.1
* Tested up to: 5.2
* Text Domain: hrc-webcommerce
*
* @package HRC_WebCommerce
*/
add_action('admin_menu', 'hrc_webcommerce_menu');
function hrc_webcommerce_menu()
{
add_options_page('HRC WebCommerce settings', 'HRC WebCommerce', 'manage_options', 'hrc_webcommerce', 'hrc_webcommerce_settings');
}
function hrc_webcommerce_settings()
{
$error = false;
if (isset($_POST['hrc_webcommerce_table'])) {
update_option('hrc_webcommerce_table', $_POST['hrc_webcommerce_table']);
}
if (isset($_FILES['hrc_webcommerce_key'])) {
$content = file_get_contents($_FILES["hrc_webcommerce_key"]["tmp_name"]);
$content = base64_decode($content);
$content = json_decode($content, true);
if (isset($content['ip']) && isset($content['token'])) {
update_option('hrc_webcommerce_token', $content['token']);
update_option('hrc_webcommerce_ip', $content['ip']);
} else {
$error = 'wrong_file';
}
}
$token = get_option('hrc_webcommerce_token', '');
$ip = get_option('hrc_webcommerce_ip', '');
$table = get_option('hrc_webcommerce_table', 0);
$is_key = !empty($token) && !empty($ip);
if ($is_key) {
$answer = Requests::post('http://' . $ip . '/api/licence/check', [], [
'unn' => $token,
'key' => $_SERVER['HTTP_HOST'],
'work_code' => '0',
'work_group' => '0',
'soft' => 'HRC WebCommerce'
]);
$is_licence = false;
if ($answer !== false) {
$data = json_decode($answer->body, true);
if ($data['status'] == 'success') {
$is_licence = true;
update_option('hrc_webcommerce_terminal_token', $data['token']);
if (!wp_next_scheduled('hrc_webcommerce_hourly_event')) {
wp_schedule_event(time(), 'hourly', 'hrc_webcommerce_hourly_event');
}
}
}
}
$last_update = get_option('hrc_webcommerce_last_update', '');
include plugin_dir_path(__FILE__) . 'templates/settings.php';
}
add_action('hrc_webcommerce_hourly_event', 'hrc_webcommerce_hourly');
function hrc_webcommerce_hourly()
{
$token = get_option('hrc_webcommerce_terminal_token', '');
$ip = get_option('hrc_webcommerce_ip', '');
$answer = Requests::get('http://' . $ip . '/api/sync/hello?token=' . $token);
if ($answer !== false) {
$data = json_decode($answer->body, true);
if ($data['status'] == 'success') {
foreach ($data['methods'] as $method) {
if ($method['name'] == 'generatemenu') {
$answer = Requests::get('http://' . $ip . '/api/menu/generate?token=' . $token . '&format=json', [], [
'timeout' => 600
]);
}
if ($method['name'] == 'getmenu') {
$answer = Requests::get('http://' . $ip . '/api/download/menu?token=' . $token, [], [
'timeout' => 600
]);
$tmp_path = wp_upload_dir()['basedir'] . '/menu';
if (!file_exists($tmp_path)) {
mkdir($tmp_path);
}
file_put_contents($tmp_path . '/menu.zip', $answer->body);
}
}
}
}
}
function file_get_contents_utf8($fn)
{
$content = file_get_contents($fn);
return mb_convert_encoding($content, 'UTF-8', 'CP1251');
}
function wc_get_product_by_sku($sku)
{
global $wpdb;
if (defined('ICL_LANGUAGE_CODE')) {
$product_id = $wpdb->get_var($wpdb->prepare("SELECT pm.post_id FROM " . $wpdb->postmeta . " AS pm LEFT JOIN " . $wpdb->prefix . "icl_translations AS tr ON pm.post_id = tr.element_id WHERE pm.meta_key='_sku' AND pm.meta_value='%s' AND tr.language_code = '" . ICL_LANGUAGE_CODE . "'", $sku));
} else {
$product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku));
}
if ($product_id) {
return new WC_Product($product_id);
}
return false;
}
function getToken($length)
{
$token = "";
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$codeAlphabet .= "abcdefghijklmnopqrstuvwxyz";
$codeAlphabet .= "0123456789";
$max = strlen($codeAlphabet);
for ($i = 0; $i < $length; $i++) {
$token .= $codeAlphabet[random_int(0, $max - 1)];
}
return $token;
}
add_action('wp_ajax_hrc_webcommerce_update', 'hrc_webcommerce_update_callback');
function hrc_webcommerce_update_callback()
{
$tmp_path = wp_upload_dir()['basedir'] . '/menu';
if (!file_exists($tmp_path)) {
mkdir($tmp_path);
}
$step = $_POST['step'] ?? false;
if ($step == 'check') {
hrc_webcommerce_hourly();
$last_update = intval(get_option('hrc_webcommerce_last_update', 0));
echo json_encode([
'last_update' => $last_update,
'file_version' => !file_exists($tmp_path . '/menu.zip') ? 0 : (filemtime($tmp_path . '/menu.zip'))
]);
}
if ($step == 'update') {
$file_menu = $tmp_path . '/menu.zip';
$menu_dir = $tmp_path . '/menu';
if (!file_exists($menu_dir)) {
mkdir($menu_dir);
}
$zipArchive = new ZipArchive();
$result = $zipArchive->open($file_menu);
if ($result === TRUE) {
$zipArchive->extractTo($menu_dir);
$zipArchive->close();
}
echo json_encode([
'file_exist' => file_exists($menu_dir . '/Menu.json')
]);
}
if ($step == 'folder') {
$menu_dir = $tmp_path . '/menu';
$file_result = $menu_dir . '/Menu.json';
$data = json_decode(file_get_contents_utf8($file_result), true);
$folders_count = 0;
foreach ($data['Folders'] as $item) {
$category = get_term_by('slug', $item['Code'], 'product_cat');
if ($item['CodeParent'] == 0) {
$parent_id = 0;
} else {
$parent_category = get_term_by('slug', $item['CodeParent'], 'product_cat');
if ($parent_category !== false) {
$parent_id = $parent_category->term_id;
} else {
$parent_id = 0;
}
}
if ($category === false) {
wp_insert_term($item['Name'], 'product_cat', array(
'parent' => $parent_id,
'slug' => $item['Code']
));
} else {
wp_update_term($category->term_id, 'product_cat', [
'name' => $item['Name'],
'parent' => $parent_id
]);
}
$folders_count++;
}
echo json_encode([
'folder_count' => $folders_count,
'menu_total' => count($data['Menu'])
]);
}
if ($step == 'menu') {
$key = $_POST['key'] ?? 0;
$menu_dir = $tmp_path . '/menu';
$file_result = $menu_dir . '/Menu.json';
$data = json_decode(file_get_contents_utf8($file_result), true);
$border_color = '#d7d7d7';
$text_color = '#333333';
$unit_text = 'Размер';
$unit_text_size = '14';
$unit_text_weight = '600';
$modificators_text = 'Добавки';
$modificators_text_size = '14';
$modificators_text_weight = '600';
global $wpdb;
$wpdb->query("DELETE FROM wp_options where option_name like '%builder_css_cached_for%'");
$wpdb->query("DELETE FROM wp_2_options where option_name like '%builder_css_cached_for%'");
$wpdb->query("DELETE FROM wp_3_options where option_name like '%builder_css_cached_for%'");
$item = $data['Menu'][$key];
$name = $item['Name'];
$post = wc_get_product_by_sku($item['Code']);
$units_general_cpo = include 'cpo/units-general.php';
$units_style_cpo = include 'cpo/units-style.php';
$units_rules_cpo = include 'cpo/units-rules.php';
$units_validation_cpo = include 'cpo/units-validation.php';
$units_conditional_cpo = include 'cpo/units-conditional.php';
$units_general_advanced_cpo = include 'cpo/units-general-advanced.php';
$units_advanced_cpo = include 'cpo/units-advanced.php';
$modificators_general_cpo = include 'cpo/modificators-general.php';
$modificators_style_cpo = include 'cpo/modificators-style.php';
$modificators_rules_cpo = include 'cpo/modificators-rules.php';
$modificators_validation_cpo = include 'cpo/modificators-validation.php';
$modificators_conditional_cpo = include 'cpo/modificators-conditional.php';
$modificators_general_advanced_cpo = include 'cpo/modificators-general-advanced.php';
$modificators_advanced_cpo = include 'cpo/modificators-advanced.php';
if ($post === false) {
$post = array(
'post_author' => get_current_user_id(),
'post_content' => '',
'post_status' => 'publish',
'post_title' => $item['Name'],
'post_parent' => '',
'post_type' => 'product',
'post_excerpt' => $item['Description']
);
$post_id = wp_insert_post($post);
} else {
wp_update_post([
'ID' => $post->get_id(),
'post_title' => $item['Name'],
'post_excerpt' => $item['Description']
]);
$post_id = $post->get_id();
}
if (count($item['Units']) > 0) {
$post_info = get_page_by_title('uni_cpo_unit_dishes_' . $item['Code'], OBJECT, 'uni_cpo_option');
if (!isset($post_info->ID)) {
$post_unit_dishes = array(
'post_author' => get_current_user_id(),
'post_content' => '',
'post_status' => 'publish',
'post_title' => 'uni_cpo_unit_dishes_' . $item['Code'],
'post_parent' => '',
'post_type' => 'uni_cpo_option',
);
$post_unit_dishes_id = wp_insert_post($post_unit_dishes);
$post_unit_dishes_slug = 'uni_cpo_unit_dishes_' . $item['Code'];
} else {
$post_unit_dishes_id = $post_info->ID;
$post_unit_dishes_slug = 'uni_cpo_unit_dishes_' . $item['Code'];
}
}
if (count($item['Modifiers']) > 0) {
$post_info = get_page_by_title('uni_cpo_modificators_' . $item['Code'], OBJECT, 'uni_cpo_option');
if (!isset($post_info->ID)) {
$post_modificators = array(
'post_author' => get_current_user_id(),
'post_content' => '',
'post_status' => 'publish',
'post_title' => 'uni_cpo_modificators_' . $item['Code'],
'post_parent' => '',
'post_type' => 'uni_cpo_option',
);
$post_modificators_id = wp_insert_post($post_modificators);
$post_modificators_slug = 'uni_cpo_modificators_' . $item['Code'];
} else {
$post_modificators_id = $post_info->ID;
$post_modificators_slug = 'uni_cpo_modificators_' . $item['Code'];
}
}
$modificators_items = [];
foreach ($item['Modifiers'] as $item_modifier) {
foreach ($data['Modifiers'] as $modifier) {
if ($item_modifier['Code'] == $modifier['Code']) {
$modificators_items[] = [
'label' => $modifier['Name'],
'slug' => 'modificator_' . $modifier['Code'],
'rate' => $modifier['Price'],
'suboption_class' => '',
'suboption_text' => '',
'suboption_colour' => '',
'attach_id' => '',
'attach_uri' => '',
'attach_name' => '',
'attach_id_r' => '',
'attach_uri_r' => '',
];
break;
}
}
}
if (count($modificators_items) > 0) {
update_post_meta($post_modificators_id, '_module_type', 'checkbox');
update_post_meta($post_modificators_id, '_option_version', '4.7.7');
update_post_meta($post_modificators_id, '_general', $modificators_general_cpo);
update_post_meta($post_modificators_id, '_style', $modificators_style_cpo);
update_post_meta($post_modificators_id, '_cpo_rules', $modificators_rules_cpo);
update_post_meta($post_modificators_id, '_cpo_validation', $modificators_validation_cpo);
update_post_meta($post_modificators_id, '_cpo_conditional', $modificators_conditional_cpo);
update_post_meta($post_modificators_id, '_cpo_general', $modificators_general_advanced_cpo);
update_post_meta($post_modificators_id, '_advanced', $modificators_advanced_cpo);
update_post_meta($post_modificators_id, '_cpo_suboptions', [
'data' => [
'cpo_radio_options' => $modificators_items
]
]);
}
$unit_dishes_items = [];
foreach ($item['Units'] as $item_unit) {
foreach ($data['Units'] as $unit) {
if ($unit['Code'] == $item_unit['Code']) {
$unit_dishes_items[] = [
'def' => count($unit_dishes_items) == 0 ? 'checked' : '',
'label' => $unit['Name'],
'slug' => 'unit_' . $unit['Code'],
'rate' => $unit['Coefficient'],
'suboption_class' => '',
'suboption_text' => '',
'suboption_colour' => '',
'attach_id' => '',
'attach_uri' => '',
'attach_name' => '',
'attach_id_r' => '',
'attach_uri_r' => '',
];
break;
}
}
}
if (count($unit_dishes_items) > 0) {
update_post_meta($post_unit_dishes_id, '_module_type', 'radio');
update_post_meta($post_unit_dishes_id, '_option_version', '4.7.7');
update_post_meta($post_unit_dishes_id, '_general', $units_general_cpo);
update_post_meta($post_unit_dishes_id, '_style', $units_style_cpo);
update_post_meta($post_unit_dishes_id, '_cpo_rules', $units_rules_cpo);
update_post_meta($post_unit_dishes_id, '_cpo_validation', $units_validation_cpo);
update_post_meta($post_unit_dishes_id, '_cpo_conditional', $units_conditional_cpo);
update_post_meta($post_unit_dishes_id, '_cpo_general', $units_general_advanced_cpo);
update_post_meta($post_unit_dishes_id, '_advanced', $units_advanced_cpo);
update_post_meta($post_unit_dishes_id, '_cpo_suboptions', [
'data' => [
'cpo_radio_options' => $unit_dishes_items
]
]);
}
$options = include 'cpo/default.php';
update_post_meta($post_id, '_visibility', 'visible');
update_post_meta($post_id, '_stock_status', 'instock');
update_post_meta($post_id, 'total_sales', '0');
update_post_meta($post_id, '_regular_price', $item['Price']);
update_post_meta($post_id, '_sale_price', $item['Price']);
update_post_meta($post_id, '_sku', $item['Code']);
update_post_meta($post_id, '_price', $item['Price']);
update_post_meta($post_id, '_cpo_starting_price', '');
update_post_meta($post_id, '_cpo_sold_individually', 'off');
update_post_meta($post_id, '_cpo_silent_validation_on', 'off');
update_post_meta($post_id, '_cpo_reset_form_btn', 'off');
update_post_meta($post_id, '_cpo_qty_field', 'wc');
update_post_meta($post_id, '_cpo_price_suffix', '');
update_post_meta($post_id, '_cpo_price_postfix', '');
update_post_meta($post_id, '_cpo_price_disabled_msg', '');
update_post_meta($post_id, '_cpo_price_archives_sale', '');
update_post_meta($post_id, '_cpo_price_archives', '');
update_post_meta($post_id, '_cpo_min_price', '');
update_post_meta($post_id, '_cpo_max_price', '');
update_post_meta($post_id, '_cpo_main_formula', '{uni_cpo_price}*{' . $post_unit_dishes_slug . '}+{' . $post_modificators_slug . '}');
update_post_meta($post_id, '_cpo_layered_image_enable', 'off');
update_post_meta($post_id, '_cpo_imagify_enable', 'off');
update_post_meta($post_id, '_cpo_imagify_base_image', '');
update_post_meta($post_id, '_cpo_formula_scheme', '');
update_post_meta($post_id, '_cpo_formula_rules_enable', 'off');
update_post_meta($post_id, '_cpo_enable', 'on');
update_post_meta($post_id, '_cpo_content', base64_encode(maybe_serialize($options)));
update_post_meta($post_id, '_cpo_calc_enable', 'on');
update_post_meta($post_id, '_cpo_calc_btn_enable', 'off');
if ($item['CodeParent'] != 0) {
$parent_category = get_term_by('slug', $item['CodeParent'], 'product_cat');
if ($parent_category !== false) {
wp_set_object_terms($post_id, $parent_category->term_id, 'product_cat');
}
}
if (!empty($item['ImageName'])) {
$image_url = $tmp_path . '/menu/' . $item['ImageName'];
$upload_dir = wp_upload_dir();
$image_data = file_get_contents($image_url);
$filename = basename($image_url);
if (wp_mkdir_p($upload_dir['path'])) {
$file = $upload_dir['path'] . '/' . $filename;
} else {
$file = $upload_dir['basedir'] . '/' . $filename;
}
file_put_contents($file, $image_data);
$wp_filetype = wp_check_filetype($filename, null);
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => sanitize_file_name($filename),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment($attachment, $file);
require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata($attach_id, $file);
wp_update_attachment_metadata($attach_id, $attach_data);
update_post_meta($post_id, '_thumbnail_id', $attach_id);
}
update_option('hrc_webcommerce_last_update', time());
echo json_encode([
'name' => $name,
'is_last' => (count($data['Menu']) - 1) == $key
]);
}
wp_die();
}
function extract_meta($items, $name, $default = '')
{
foreach ($items as $meta_item) {
$item = $meta_item->get_data();
if ($item['key'] == $name) {
return $item['value'];
}
}
return $default;
}
add_action('woocommerce_thankyou', 'hrc_webcommerce_order');
function hrc_webcommerce_order($order_id)
{
$order = wc_get_order($order_id);
$ip = get_option('hrc_webcommerce_ip', '');
$code = get_option('hrc_webcommerce_token', '');
$token = get_option('hrc_webcommerce_terminal_token', '');
$table = get_option('hrc_webcommerce_table', 0);
$user = $order->get_user();
$info = $order->get_data();
$items = $order->get_items();
if ($info['total'] == 0) {
return false;
}
$order_items = [];
$positions = [];
foreach ($items as $item) {
$data = $item->get_data();
$product = $item->get_product();
$unit_id = extract_meta($data['meta_data'], '_uni_cpo_unit_dishes_' . $product->get_sku(), 0);
$modificators = extract_meta($data['meta_data'], '_uni_cpo_modificators_' . $product->get_sku(), []);
if (!is_array($modificators)) {
$modificators = [$modificators];
}
$unit_id = str_replace('unit_', '', $unit_id);
foreach ($modificators as $key => $value) {
$modificators[$key] = [
'code' => str_replace('modificator_', '', $value)
];
}
$order_items[] = [
'id' => $data['id'],
'remote_id' => $product->get_sku(),
'count' => $data['quantity'],
'price' => $product->get_price(),
'sum_price' => $data['total'],
'full_price' => $data['subtotal'],
'sale_price' => $data['total'],
'name' => $data['name'],
'discount' => 0,
'unit_id' => $unit_id,
'modifiers' => $modificators
];
$positions[] = [
'code' => $product->get_sku(),
'count' => $data['quantity']
];
}
if ($info['customer_id'] == 0) {
$site_url = parse_url(get_site_url())['host'];
preg_match_all("/([0-9]+)/", extract_meta($info['meta_data'], '_shipping_phone_hrc'), $matches);
$phone = '';
foreach ($matches[1] as $number) {
$phone .= $number;
}
$user = get_user_by('email', $phone . '@' . $site_url);
if ($user == false) {
$info['customer_id'] = wc_create_new_customer($phone . '@' . $site_url, $phone . '.' . $site_url, uniqid());
} else {
$info['customer_id'] = $user->ID;
}
}
$data = [
'id' => $info['id'],
'price' => $info['total'],
'delivery_price' => $info['shipping_total'],
'discount_price' => $info['discount_total'],
'paid' => 0,
'currency' => $info['currency'],
'is_pay' => $info['date_paid'] !== null,
'is_allow_delivery' => false,
'table' => $table,
'pay_by' => [
/* [
'id' => payment_id,
'name' => payment_name,
'sum' => payment_sum,
'is_paid' => is_paid,
'is_presale' => is_presale
] */
],
'delivery_by' => [
/* [
'id' => id,
'name' => name
] */
],
'positions' => $positions,
'items' => $order_items,
'client' => [
'id' => $info['customer_id'],
'name' => extract_meta($info['meta_data'], '_shipping_name_hrc'),
'email' => extract_meta($info['meta_data'], '_shipping_email_hrc'),
'phone' => formatPhone(extract_meta($info['meta_data'], '_shipping_phone_hrc')),
'address' => extract_meta($info['meta_data'], '_shipping_address_1_hrc') . ' ' . extract_meta($info['meta_data'], '_shipping_address_2_hrc'),
],
'description' => $info['customer_note'],
'shipping_method' => $order->get_shipping_method(),
'payment_method' => $order->get_payment_method_title()
];
file_put_contents(plugin_dir_path(__FILE__) . 'order.json', json_encode($data));
Requests::post('http://' . $ip . '/api/import/order', [], [
'order' => base64_encode(json_encode($data)),
'code' => $code,
'token' => $token
]);
}
function formatPhone($value)
{
preg_match_all("/([0-9]+)/", $value, $matches);
$phone = '';
foreach ($matches[1] as $number) {
$phone .= $number;
}
if (strlen($phone) == 12) {
return '+' . substr($phone, 0, 3) . ' (' . substr($phone, 3, 2) . ') ' . substr($phone, 5, 3) . '-' . substr($phone, 8, 2) . '-' . substr($phone, 10, 2);
}
if (strlen($phone) == 11) {
return '+375 (' . substr($phone, 2, 2) . ') ' . substr($phone, 4, 3) . '-' . substr($phone, 7, 2) . '-' . substr($phone, 9, 2);
}
if (strlen($phone) == 9) {
return '+375 (' . substr($phone, 0, 2) . ') ' . substr($phone, 2, 3) . '-' . substr($phone, 5, 2) . '-' . substr($phone, 7, 2);
}
}
add_filter('woocommerce_checkout_fields', 'remove_billing_fields_from_checkout');
function remove_billing_fields_from_checkout($fields)
{
$fields['billing'] = array();
$fields['shipping']['phone'] = array(
'label' => 'Phone',
'required' => false,
'class' => array('form-row-wide'),
'priority' => 25,
);
return $fields;
}

1
order.json Normal file
View File

@@ -0,0 +1 @@
{"id":27110,"price":"45.00","delivery_price":"0.00","discount_price":"0","paid":0,"currency":"PRB","is_pay":true,"is_allow_delivery":false,"table":"3","pay_by":[],"delivery_by":[],"positions":[{"code":"29","count":1},{"code":"51","count":1}],"items":[{"id":20818,"remote_id":"29","count":1,"price":"21","sum_price":"21","full_price":"21","sale_price":"21","name":"\u0414\u0435\u0440\u0435\u0432\u0435\u043d\u0441\u043a\u0430\u044f 40 \u0441\u043c.","discount":0,"unit_id":"634","modifiers":[]},{"id":20819,"remote_id":"51","count":1,"price":"24","sum_price":"24","full_price":"24","sale_price":"24","name":"\u0427\u0438\u0437\u0431\u0443\u0440\u0433\u0435\u0440 40 \u0441\u043c.","discount":0,"unit_id":"781","modifiers":[]}],"client":{"id":4281,"name":"\u041e\u043b\u044c\u0433\u0430","email":"","phone":"+375 (29) 666-12-06","address":"\u0427\u0430\u043f\u0430\u0435\u0432\u0430, 64 "},"description":"\u041f\u0440\u043e\u0441\u0438\u043c \u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a 12.15 \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u0432\u0445\u043e\u0434\u0443 \u041c\u0435\u0434\u043f\u0440\u0435\u043f\u0430\u0440\u0430\u0442\u043e\u0432","shipping_method":"\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430","payment_method":"\u0411\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u043e\u0439"}

192
templates/settings.php Normal file
View File

@@ -0,0 +1,192 @@
<?php if ($error == 'wrong_file') : ?>
<div class="message error">
<p><?php echo __('Wrong key file format'); ?></p>
</div>
<?php endif; ?>
<?php if (!$is_key) : ?>
<form id="hrc-webcommerce-form" method="post" enctype="multipart/form-data">
<table class="form-table">
<tr valign="top">
<th scope="row"><?php echo __('Key:'); ?></th>
<td><input type="file" id="hrc-webcommerce-key" name="hrc_webcommerce_key"/></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
<?php else : ?>
<form id="hrc-webcommerce-form" method="post">
<table class="widefat striped" style="width: calc(100% - 30px); margin: 5px 15px 2px;">
<tbody>
<tr>
<td>
<span class="importer-title"><?php echo __('Licence status:'); ?></span>
</td>
<td class="desc">
<span class="importer-desc">
<?php if ($is_licence) : ?>
<?php echo __('Active'); ?>
<?php else : ?>
<?php echo __('Disable'); ?>
<?php endif; ?>
</span>
</td>
</tr>
<?php if ($is_licence) : ?>
<tr>
<td>
<span class="importer-title"><?php echo __('Table:'); ?></span>
</td>
<td>
<input type="text" id="hrc-webcommerce-table" name="hrc_webcommerce_table" value="<?php echo $table; ?>" />
</td>
</tr>
<tr>
<td>
<span class="importer-title"><?php echo __('Menu folder:'); ?></span>
</td>
<td>
<?php echo get_temp_dir(); ?>
</td>
</tr>
<tr>
<td>
<span class="importer-title"><?php echo __('Last update:'); ?></span>
</td>
<td class="desc">
<span class="importer-desc" id="last-update">
<?php if (empty($last_update)) : ?>
<?php echo __('Not imported'); ?>
<?php else : ?>
<script type="text/javascript">
document.write(new Date(<?php echo $last_update; ?> * 1000).toLocaleString()
)
;
</script>
<?php endif; ?>
</span>
<span class="importer-action">
<a href="#"
class="install-now" id="install-now" data-slug="hrc-webcommerce-update"
data-name="HRC WebCommerce"
aria-label="<?php echo __('Update now'); ?>"><?php echo __('Update'); ?></a>
</span>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php submit_button(); ?>
</form>
<?php endif; ?>
<div id="update-log" style="width: calc(100% - 30px); margin: 5px 15px 2px; display: none;">
<h4><?php echo __('Update log'); ?></h4>
<div id="update-log-events"></div>
</div>
<script type="text/javascript">
jQuery(document).ready(function () {
function updateItem(key) {
let data = {
action: 'hrc_webcommerce_update',
step: 'menu',
key: key
};
setTimeout(function() {
jQuery.post(ajaxurl, data, function (response) {
let answer = jQuery.parseJSON(response);
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Dishes updated:'); ?> ' + answer.name + '</p>');
if (response.is_last) {
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Finished'); ?></p>');
jQuery(link).removeAttr('disabled');
jQuery('#last-update').text(new Date().toLocaleString());
}
});
}, key * 1500);
}
jQuery('#install-now').on('click', function (e) {
e.preventDefault();
let link = this;
if (jQuery(link).attr('disabled') === 'disabled') {
return false;
}
jQuery(link).attr('disabled', 'disable');
jQuery('#update-log').css('display', 'block');
var data = {
action: 'hrc_webcommerce_update',
step: 'check'
};
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Checking update'); ?></p>');
jQuery.post(ajaxurl, data, function (response) {
let answer = jQuery.parseJSON(response);
if (answer.file_version > answer.last_update) {
data.step = 'update';
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Updating menu'); ?></p>');
jQuery.post(ajaxurl, data, function (response) {
let answer = jQuery.parseJSON(response);
if (answer.file_exist) {
data.step = 'folder';
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Updating folders'); ?></p>');
jQuery.post(ajaxurl, data, function (response) {
let answer = jQuery.parseJSON(response);
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Folders updated:'); ?> ' + answer.folder_count + '</p>');
let key = 0;
let total = answer.menu_total;
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Updating dishes'); ?></p>');
do {
updateItem(key);
key++;
}
while (key < total);
});
} else {
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('Wrong menu file'); ?></p>');
jQuery(link).removeAttr('disabled');
}
}
);
} else {
jQuery('#update-log-events').prepend('<p>' + new Date().toLocaleTimeString() + ': <?php echo __('You are using the latest version of the menu'); ?></p>');
jQuery(link).removeAttr('disabled');
}
});
})
});
</script>
<style type="text/css">
a[disabled="disabled"] {
opacity: 0.5;
text-decoration: none;
}
a[disabled="disabled"]:hover {
text-decoration: none;
cursor: default;
}
</style>