Skip to content

Commit

Permalink
updates 221205 (#467)
Browse files Browse the repository at this point in the history
* add zip for each tag
* readme
* code style
* small fixes
* fix #468
  • Loading branch information
aiiddqd authored Jan 2, 2023
1 parent 8e1d10c commit c559ec3
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 52 deletions.
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## Какие проблемы решаем? Что есть?

Тут ссылки на issue или описание проблемы
- [ ] ...

## Как надо? Как это должно работать?
## Как надо? Как это должно работать? Как это будет?

...
- [ ] ...

## Чек лист

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Create zip

on:
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Zip Folder
run: zip -r ${{ github.event.repository.name }}.zip . -x ".git/*" ".github/*" "phpcs.xml" "composer.json" "composer.lock" ".gitignore"
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ github.event.repository.name }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 3 additions & 4 deletions includes/MenuSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,10 @@ public static function display_settings()
<?php

printf('<p><a href="%s">Управление синхронизацией</a></p>', admin_url('admin.php?page=moysklad'));
printf('<p><a href="%s" target="_blank">Расширенная версия с дополнительными возможностями</a></p>', "https://wpcraft.ru/product/wooms-extra/");
printf('<p><a href="%s" target="_blank">Расширения и дополнения</a></p>', "https://github.com/topics/wooms");
printf('<p><a href="%s" target="_blank">Предложения по улучшению и запросы на доработку</a></p>', "https://github.com/wpcraft-ru/wooms/issues");
printf('<p><a href="%s" target="_blank">Рекомендуемые хостинги</a></p>', "https://wpcraft.ru/wordpress/hosting/");
printf('<p><a href="%s" target="_blank">Сопровождение магазинов и консалтинг</a></p>', "https://wpcraft.ru/wordpress-woocommerce-mentoring/");
printf('<p><a href="%s" target="_blank">Помощь и техическая поддержка</a></p>', "https://wpcraft.ru/contacts/");
printf('<p><a href="%s" target="_blank">Рекомендуемые хостинги</a></p>', "https://wpcraft.ru/hosting-wordpress-woocommerce/");
printf('<p><a href="%s" target="_blank">Контакты</a></p>', "https://wpcraft.ru/contacts/");
}
}

Expand Down
25 changes: 16 additions & 9 deletions includes/MenuTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,32 @@ public static function display_ui()
sprintf('<a href="%s">Настройки</a>', admin_url("admin.php?page=mss-settings") ),
'<a href="https://online.moysklad.ru/app/" target="_blank">Вход в МойСклад</a>',
sprintf('<a href="%s">Диагностика проблем</a>', admin_url("site-health.php") ),
'<a href="https://wpcraft.ru/wordpress/hosting/" target="_blank">Рекомендуемые хостинги</a>',
'<a href="https://wpcraft.ru/wordpress-woocommerce-mentoring/" target="_blank">Сопровождение магазинов и консалтинг</a>',
'<a href="https://wpcraft.ru/hosting-wordpress-woocommerce/" target="_blank">Рекомендуемые хостинги</a>',
'<a href="https://wpcraft.ru/contacts/" target="_blank">Контакты</a>',
];

printf( '<p>%s</p>', implode('<span> | </span>', $items) );

if( empty($_GET['a']) ){
do_action('woomss_tool_actions_btns');
if(empty(get_option('woomss_pass'))){
printf('<p>Укажите логин и пароль на <a href="%s">странице настроек</a></p>', admin_url('admin.php?page=mss-settings'));
} else {
if( empty($_GET['a']) ){

do_action('wooms_tools_sections');
do_action('wooms_tools_sections');

} else {
// deprecated
do_action('woomss_tool_actions_btns');

} else {

printf('<a href="%s">Вернуться...</a>', remove_query_arg( 'a', self::$url));
do_action('woomss_tool_actions');
do_action('woomss_tool_actions_' . $_GET['a']);
printf('<a href="%s">Вернуться...</a>', remove_query_arg( 'a', self::$url));
do_action('woomss_tool_actions');
do_action('woomss_tool_actions_' . $_GET['a']);

}
}


}


Expand Down
2 changes: 1 addition & 1 deletion includes/ProductStocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function init()
add_action('init', array(__CLASS__, 'add_schedule_hook'));

add_action('admin_init', array(__CLASS__, 'add_settings'), 30);
add_action('woomss_tool_actions_btns', array(__CLASS__, 'display_state'), 17);
add_action('wooms_tools_sections', array(__CLASS__, 'display_state'), 17);

add_filter('wooms_stock_type', array(__CLASS__, 'select_type_stock'));

Expand Down
2 changes: 1 addition & 1 deletion includes/ProductVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function init()
add_action('wooms_main_walker_finish', array(__CLASS__, 'reset_after_main_walker_finish'));
add_action('wooms_main_walker_started', array(__CLASS__, 'set_wait'));

add_action('woomss_tool_actions_btns', array(__CLASS__, 'display_state'), 15);
add_action('wooms_tools_sections', array(__CLASS__, 'display_state'), 15);

add_action('woocommerce_variation_header', array(__CLASS__, 'variation_sync_id'), 10);
}
Expand Down
66 changes: 49 additions & 17 deletions includes/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,26 @@
add_action('wooms_product_data_item', __NAMESPACE__ . '\\load_product');
add_filter('wooms_product_save', __NAMESPACE__ . '\\update_product', 9, 3);

add_action('woomss_tool_actions_btns', __NAMESPACE__ . '\\render_ui', 9);
add_action('wooms_tools_sections', __NAMESPACE__ . '\\render_ui', 9);
add_action('woomss_tool_actions_wooms_products_start_import', __NAMESPACE__ . '\\start_manually');
add_action('woomss_tool_actions_wooms_products_stop_import', __NAMESPACE__ . '\\stop_manually');

add_action('init', function(){
add_action('add_meta_boxes', function () {
add_meta_box('wooms_product', 'МойСклад', __NAMESPACE__ . '\\display_metabox_for_product', 'product', 'side', 'low');
});

add_action('init', function () {
if (!wp_next_scheduled('wooms_monitoring')) {
wp_schedule_event( time(), 'every_minute', 'wooms_monitoring' );
wp_schedule_event(time(), 'every_minute', 'wooms_monitoring');
}
});
add_action('wooms_monitoring', __NAMESPACE__ . '\\check_and_restart_job_queue');

/**
* main walker for start sync
*/
function walker($args = [])
{
if(empty($args)){
if (empty($args)) {
walker_started();
$state = get_state();
} else {
Expand Down Expand Up @@ -63,7 +66,7 @@ function walker($args = [])

$data = wooms_request($url);

if(isset($data['errors'])){
if (isset($data['errors'])) {
throw new \Exception(print_r($data['errors'], true));
}

Expand Down Expand Up @@ -104,7 +107,7 @@ function walker($args = [])

function process_rows($rows = [])
{
if(empty($rows)){
if (empty($rows)) {
return false;
}

Expand Down Expand Up @@ -165,7 +168,8 @@ function stop_manually()
exit;
}

function get_session_id(){
function get_session_id()
{
return get_state('session_id');
}

Expand Down Expand Up @@ -232,7 +236,7 @@ function update_product($product, $data_api, $data = 'deprecated')
// issue https://github.com/wpcraft-ru/wooms/issues/302
$product->set_catalog_visibility('visible');

if ( apply_filters('wooms_reset_state_products', true) ) {
if (apply_filters('wooms_reset_state_products', true)) {
$product->set_stock_status('instock');
$product->set_manage_stock('no');
$product->set_status('publish');
Expand Down Expand Up @@ -291,7 +295,7 @@ function load_product($value)

$product_id = get_product_id_by_uuid($value['id']);

if(empty($product_id) && !empty($value['article'])){
if (empty($product_id) && !empty($value['article'])) {
$product_id = wc_get_product_id_by_sku($value['article']);
}

Expand Down Expand Up @@ -461,7 +465,7 @@ function walker_started()
$batch_size = get_option('wooms_batch_size', 20);
$query_arg_default = [
'offset' => 0,
'limit' => apply_filters('wooms_iteration_size', $batch_size),
'limit' => apply_filters('wooms_iteration_size', $batch_size),
];
// set_state('query_arg', );

Expand Down Expand Up @@ -505,7 +509,7 @@ function is_wait()
}

//if no password
if(empty(get_option('woomss_pass'))){
if (empty(get_option('woomss_pass'))) {
return true;
}

Expand Down Expand Up @@ -541,20 +545,21 @@ function render_ui()
}


function check_and_restart_job_queue(){
function check_and_restart_job_queue()
{
$end_timestamp = get_state('end_timestamp');
$is_enable_cron = get_option('woomss_walker_cron_enabled', false);
if(empty($end_timestamp)){
if (empty($end_timestamp)) {
return false;
}
if(empty($is_enable_cron)){
if (empty($is_enable_cron)) {
return false;
}

$timer = 60 * 60 * intval(get_option('woomss_walker_cron_timer', 24));
$time_has_passed = time() - $end_timestamp;

if($time_has_passed < $timer){
if ($time_has_passed < $timer) {
return false;
}

Expand All @@ -580,7 +585,7 @@ function get_state($key = '')
function set_state($key, $value = null)
{
$option_key = HOOK_NAME . '_state';
if(empty($value) && is_array($key)){
if (empty($value) && is_array($key)) {
return update_option($option_key, $key);
}

Expand All @@ -591,3 +596,30 @@ function set_state($key, $value = null)
$state[$key] = $value;
return update_option($option_key, $state);
}

/**
* Meta box in product
*/
function display_metabox_for_product()
{
$post = get_post();
$box_data = '';
$data_id = get_post_meta($post->ID, 'wooms_id', true);
$data_meta = get_post_meta($post->ID, 'wooms_meta', true);
$data_updated = get_post_meta($post->ID, 'wooms_updated', true);
if ($data_id) {
printf('<div>ID товара в МойСклад: <div><strong>%s</strong></div></div>', $data_id);
} else {
echo '<p>Товар еще не синхронизирован с МойСклад.</p> <p>Ссылка на товар отсутствует</p>';
}

if ($data_meta) {
printf('<p><a href="%s" target="_blank">Посмотреть товар в МойСклад</a></p>', $data_meta['uuidHref']);
}

if ($data_updated) {
printf('<div>Дата последнего обновления товара в МойСклад: <strong>%s</strong></div>', $data_updated);
}

do_action('wooms_display_product_metabox', $post->ID);
}
16 changes: 2 additions & 14 deletions includes/ProductsCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace WooMS;

if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
defined('ABSPATH') || exit;

/**
* Import Product Categories from MoySklad
Expand All @@ -18,16 +16,6 @@ class ProductsCategories
public static function init()
{

// add_action('init', function () {
// if (!isset($_GET['dd'])) {
// return;
// }

// dd(get_option());

// dd(0);
// });

add_filter('wooms_product_save', array(__CLASS__, 'product_save'), 10, 3);
add_filter('wooms_product_save', array(__CLASS__, 'add_ancestors'), 15, 2);

Expand Down Expand Up @@ -332,7 +320,7 @@ public static function display_data_category($term)
public static function add_settings()
{

add_settings_section('wooms_product_cat', 'Категории продуктов', null, 'mss-settings');
add_settings_section('wooms_product_cat', 'Категории продуктов', __return_empty_string(), 'mss-settings');

self::add_setting_categories_sync_enabled();
self::add_setting_include_children();
Expand Down
2 changes: 1 addition & 1 deletion includes/ProductsHiding.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
add_action('wooms_main_walker_finish', __NAMESPACE__ . '\\add_task_for_hide');
add_action('wooms_main_walker_started', __NAMESPACE__ . '\\remove_task_for_hide');
add_action('admin_init', __NAMESPACE__ . '\\add_settings');
add_action('woomss_tool_actions_btns', __NAMESPACE__ . '\\display_state', 22);
add_action('wooms_tools_sections', __NAMESPACE__ . '\\display_state', 22);
});

function walker($state = [])
Expand Down
2 changes: 1 addition & 1 deletion includes/ProductsImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
add_action('init', function () {
add_action('wooms_product_image_sync', __NAMESPACE__ . '\\walker');
add_filter('wooms_product_save', __NAMESPACE__ . '\\add_image_task_to_product', 35, 2);
add_action('woomss_tool_actions_btns', __NAMESPACE__ . '\\render_ui', 15);
add_action('wooms_tools_sections', __NAMESPACE__ . '\\render_ui', 15);
add_action('admin_init', __NAMESPACE__ . '\\add_settings', 50);
add_action('wooms_main_walker_finish', __NAMESPACE__ . '\\restart');
});
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ PHP 7.0

== Changelog ==

= 9.0.1 =
= 9.1 =
- возврат опции про пропуск продуктов без артикула https://github.com/wpcraft-ru/wooms/issues/461
- из карточки товара в WP пропал блок с ссылкой на этот же товар в МС https://github.com/wpcraft-ru/wooms/issues/468
- тест WooCommerce 7.2.2
- исправлена ошибка синхронизации вариаций
- мелкие исправления и рефакторинг

= 9.0 =
- Плагин стал бесплатным - изменения 2022 https://github.com/wpcraft-ru/wooms/wiki/2022
Expand Down

0 comments on commit c559ec3

Please sign in to comment.