From 30f16915d99209dade4d4cde83a527b3dfd991d0 Mon Sep 17 00:00:00 2001 From: Dima Uryvskiy Date: Fri, 16 Jul 2021 12:35:11 +0300 Subject: [PATCH] Add debug mode option in settings and little fix debug info --- resources/pot/retailcrm-es_ES.pot | 10 ++++++++++ resources/pot/retailcrm-ru_RU.pot | 9 +++++++++ src/assets/js/retailcrm-cron-info.js | 2 +- .../class-wc-retailcrm-abstracts-settings.php | 13 +++++++++++-- src/include/class-wc-retailcrm-base.php | 17 +++++++++++++++++ src/include/functions.php | 8 ++++++-- src/languages/retailcrm-es_ES.mo | Bin 8469 -> 8751 bytes src/languages/retailcrm-ru_RU.mo | Bin 10386 -> 10734 bytes 8 files changed, 54 insertions(+), 5 deletions(-) diff --git a/resources/pot/retailcrm-es_ES.pot b/resources/pot/retailcrm-es_ES.pot index 9def175..243f9d5 100644 --- a/resources/pot/retailcrm-es_ES.pot +++ b/resources/pot/retailcrm-es_ES.pot @@ -276,3 +276,13 @@ msgstr "Presionando el botón «Exportar» puedes descargar a todos los pedidos msgid "Debug information" msgstr "Información Debug" + +msgid "Debug mode" +msgstr "Modo de depuración" + +msgid "Enable debug mode in module" +msgstr "Activar el modo de depuración en el módulo" + +msgid "Is required to enable debug mode for advanced logs" +msgstr "Se requiere el modo de depuración para habilitar el registro avanzado de logs" + diff --git a/resources/pot/retailcrm-ru_RU.pot b/resources/pot/retailcrm-ru_RU.pot index db5fc0b..d7708ed 100644 --- a/resources/pot/retailcrm-ru_RU.pot +++ b/resources/pot/retailcrm-ru_RU.pot @@ -286,5 +286,14 @@ msgstr "Вы можете экспортировать все заказы и к msgid "Debug information" msgstr "Отладочная информация" +msgid "Debug mode" +msgstr "Режим отладки" + +msgid "Enable debug mode in module" +msgstr "Активировать режим отладки в модуле" + +msgid "Is required to enable debug mode for advanced logs" +msgstr "Требуется включить режим отладки для расширенного логирования" + diff --git a/src/assets/js/retailcrm-cron-info.js b/src/assets/js/retailcrm-cron-info.js index e13189f..44d10d0 100644 --- a/src/assets/js/retailcrm-cron-info.js +++ b/src/assets/js/retailcrm-cron-info.js @@ -1,7 +1,7 @@ jQuery(function () { function RetailcrmCronInfo() { - this.title = jQuery('h2[id="woocommerce_integration-retailcrm_16"]').get(0); + this.title = jQuery('.debug_info_options').get(0) if (typeof this.title === 'undefined') { return false; diff --git a/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php b/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php index 05dc1a0..ac71d42 100644 --- a/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php +++ b/src/include/abstracts/class-wc-retailcrm-abstracts-settings.php @@ -533,14 +533,21 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration 'type' => 'checkbox' ); + $this->form_fields['debug_mode'] = array( + 'label' => __('Enable debug mode in module', 'retailcrm'), + 'title' => __('Debug mode', 'retailcrm'), + 'description' => __('Is required to enable debug mode for advanced logs', 'retailcrm'), + 'class' => 'checkbox', + 'type' => 'checkbox' + ); + /** * Debug information */ $this->form_fields[] = array( 'title' => __('Debug information', 'retailcrm'), 'type' => 'heading', - 'description' => '', - 'id' => 'cron_info_options' + 'class' => 'debug_info_options' ); } } @@ -760,6 +767,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration 'title' => __('Simla.com', 'retailcrm') ) ); + $wp_admin_bar->add_menu( array( 'id' => 'retailcrm_ajax_generate_icml', @@ -769,6 +777,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration 'class' => 'retailcrm_ajax_generate_icml' ) ); + $wp_admin_bar->add_menu( array( 'id' => 'retailcrm_ajax_generate_setings', diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index d409db6..c24f9c1 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -118,6 +118,7 @@ if (!class_exists('WC_Retailcrm_Base')) { add_action('retailcrm_deactivate', array($this, 'deactivate')); } + /** * Init settings fields */ @@ -127,6 +128,7 @@ if (!class_exists('WC_Retailcrm_Base')) { $this->init_settings(); } + /** * @param $settings * @@ -165,6 +167,7 @@ if (!class_exists('WC_Retailcrm_Base')) { return $settings; } + public function generate_icml() { /* @@ -219,6 +222,7 @@ if (!class_exists('WC_Retailcrm_Base')) { $retailcrm_history->getHistory(); } + /** * @param int $order_id */ @@ -227,6 +231,7 @@ if (!class_exists('WC_Retailcrm_Base')) { $this->orders->orderCreate($order_id); } + /** * Load stock from retailCRM */ @@ -236,6 +241,7 @@ if (!class_exists('WC_Retailcrm_Base')) { $inventories->updateQuantity(); } + /** * Upload selected orders * @@ -246,6 +252,7 @@ if (!class_exists('WC_Retailcrm_Base')) { $this->uploader->uploadSelectedOrders(); } + /** * Upload archive customers and order to retailCRM */ @@ -261,6 +268,7 @@ if (!class_exists('WC_Retailcrm_Base')) { } } + /** * Create customer in retailCRM * @@ -322,6 +330,7 @@ if (!class_exists('WC_Retailcrm_Base')) { } } + /** * Edit customer in retailCRM * @param int $customer_id @@ -339,6 +348,7 @@ if (!class_exists('WC_Retailcrm_Base')) { $this->customers->updateCustomer($customer_id); } + /** * Create order in retailCRM from admin panel * @@ -351,6 +361,7 @@ if (!class_exists('WC_Retailcrm_Base')) { } } + /** * Edit order in retailCRM * @@ -367,6 +378,7 @@ if (!class_exists('WC_Retailcrm_Base')) { $this->orders->updateOrder($order_id); } + /** * Init google analytics code */ @@ -380,6 +392,7 @@ if (!class_exists('WC_Retailcrm_Base')) { } } + /** * Google analytics send code */ @@ -393,6 +406,7 @@ if (!class_exists('WC_Retailcrm_Base')) { } } + /** * Daemon collector */ @@ -406,6 +420,7 @@ if (!class_exists('WC_Retailcrm_Base')) { } } + /** * Initialize online consultant */ @@ -560,6 +575,7 @@ if (!class_exists('WC_Retailcrm_Base')) { return false; } + /** * Deactivate module in marketplace retailCRM * @@ -574,6 +590,7 @@ if (!class_exists('WC_Retailcrm_Base')) { delete_option('retailcrm_active_in_crm'); } + /** * @param $settings * diff --git a/src/include/functions.php b/src/include/functions.php index 21e6495..4127c60 100644 --- a/src/include/functions.php +++ b/src/include/functions.php @@ -105,8 +105,12 @@ function retailcrm_get_wc_product($id, $settings) { * @return bool */ function retailcrm_is_debug() { - return (defined('WP_DEBUG') && WP_DEBUG == true) - || (defined('RCRM_DEBUG') && RCRM_DEBUG == true); + + $options = get_option(WC_Retailcrm_Base::$option_key); + + if (isset($options['debug_mode']) === true && $options['debug_mode'] === WC_Retailcrm_Base::YES) { + return true; + } } /** diff --git a/src/languages/retailcrm-es_ES.mo b/src/languages/retailcrm-es_ES.mo index ddc6e3817ac63b92858a83cd967895b2dd2ab947..0eeef134dba04376086c1680d57f030e1e1aaf61 100644 GIT binary patch delta 2263 zcmZ|PU2GIp7{>9_ZfR-dquti6E*~9=1*Gkk)&-RDzYHX}mC`rUBy(n6QbM7!^emNsNsetwsU8Fldy}3%$XV@PB5fiIRA-XMSg9 zXXm`hBM{lzmUNqHj-?b3RI-auoxp4 z!u6=k#L>buK8Pof*v%!3;P_=*OrTaYjJxn0HsLI~*htjP_$Dgwudxj;qXNl> zDe<)oT5%&f_#~c0t#AgFi6HNsGF6MpP!lR+oBi`R60_++1>oWaoWxfA0X0t*tL(%r zNRqNxF7$)<+zs$;0gbH8dX%kVHXy2;$Syw3qC-- z-czXgroHRz{~rug-Lpv6ObN587;8{(Lp>^mQKSsaLDcIrgetlVxDRjO4%|UrwYRUL ziaUqO)VoM*=2O(4>n|9}GPuS-)qM+rW{A6bBWQB8}1a(s_=z;ucf@+E1nM5xVwXjk54w zL5+#qJWgMu6WRlLyknz3-s!8%swv=ywg1|yXXqAPP4E3~y8bxkS`UNnxf5)svq-O^ zby)?am51o;qF1O7p|(ejo%v7Gc5I>7>HmKhgQxwkmDVTd>-=*Sm|jOU6^-^?MX9E} z+(R$Y35_?(Ybvsp{&>6ZChYLXb3CSj(ygZbRk5jU&f~pyst3J}YFp_l)JJvVHx-;- zFTEKmDivsTZoH(taDMM#pY?n?;fzg|K3kb^=1#3-zb+4^#+u8*xr(x)KuauRxy}oN zN!LkO18K|Yw|i5L^{<~COuLqyIAZr7;Eq(fFO#cUc%(F#PNcbu&*4GWK9Iba>mM5l zC05z4<)k#no!|0g@0*J`rqBHvdM(ho$H`CaxX%Cm=&HKg2 delta 1994 zcmYk-YfMjZ9LMo5UH*zvDbe4hatjGbDVK;!B==%GAeRRiMwkb7W@F-kv9zHUEvqdy z=FiM54@`MrY)ovJF^mUncw*-I{+x4c{r3Nz*Y9_B`dz-i?>SwbS6}43N(iqv$|~v* z>dW3{4mL(`p_~qw@v}2rqOlqK;U(;gH!%)7aWFph?|;E``oAzAhxain$JMCkTQNyf z-JqcXAK+wsjzR1f%FC$*5gejgzq( zwa@^oo`DIdi5KHI+<|#`7MI~;)J8{<>DstcN<*QkLWN`_Dnz^e{y}7JJAqn28|LCO zEWlXaMNL$OY|?6Q03P%EO{k-|hO6)m4#NV%K-00+G!&W|)JhNg{SH*}Jj5mV2{++P zQdpsGLB1_^9W`NxfBz9GiQgi@vCpWai(oKieLO01DVV7Dznq3%ll7?NYQ;+I#uChA zxjMt$s4PB%icljmwzZ=^miJJRdVosecc{n&IFEeHM)qLaa0b?5nnR7Qd9raPG!*e4Lv5$|{00sgBNE zg}kt-Zp#b%0^0g&sZ8>4ujBo8v9Cg_q6HUF7g4LIY~C$;z00YJ;QyjLSmAXXmqM(wQl{|ChNm@~9)I rN-DlLHZar~i0fVVI%-X*Dmp1FbS`F3R9!}Lb?8QNZCL1dusQM{H;AZ~ diff --git a/src/languages/retailcrm-ru_RU.mo b/src/languages/retailcrm-ru_RU.mo index 83db6ec5c35978d2a598122542811b252185fc27..bd1945464dc0be34d3a002647779288b60d8be18 100644 GIT binary patch delta 2378 zcmaLYYfM*l9LMn=AaYYvkhqk31o1|YAYK7UF%U5c@Dd>;avMf4xmD);i?(vpz=5vY z1DVx>wn7B{j0Iw@xkj$-{L^|?tM$YUb3AA+R&BjM=YMiMspJ29Ucd9>cYe3?J;$En z2c@2$BIjH(9F@eA#JnJ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