Skip to content

Commit

Permalink
Corrects directory path when customizing base file (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocmonavtik authored Sep 2, 2024
1 parent 8b01b98 commit 78fd206
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2024-08-26 4.8.2
* Fixed base file customization issue
* Added a hook to update the list of meta fields

## 2024-08-06 4.8.1
* Fix filtering of api query results

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.8.1
4.8.2
2 changes: 2 additions & 0 deletions doc/3. Customization/Filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
> retailcrm_order_update_after - позволяет проверить изменение заказа и произвести дополнительные действия
> retailcrm_change_default_meta_fields - позволяет изменить список получаемых по умолчанию мета-полей
**Пример использования:**
```php
<?php
Expand Down
16 changes: 10 additions & 6 deletions src/include/class-wc-retailcrm-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class WC_Retailcrm_Base extends WC_Retailcrm_Abstracts_Settings
{
const ASSETS_DIR = '/woo-retailcrm/assets';

/** @var WC_Retailcrm_Proxy|WC_Retailcrm_Client_V5|bool */
protected $apiClient;

Expand Down Expand Up @@ -808,7 +810,7 @@ public function reviewCreditBonus()
*/
private function include_css_files_for_admin()
{
$path = plugins_url() . '/woo-retailcrm/assets/css/';
$path = plugins_url() . self::ASSETS_DIR . '/css/';

// Include style for export
wp_register_style('retailcrm-export-style', $path . 'progress-bar.min.css', false, '0.1');
Expand Down Expand Up @@ -841,7 +843,7 @@ private function include_js_scripts_for_admin()
];

$wpAdminUrl = ['url' => get_admin_url()];
$jsScriptsPath = plugins_url() . '/woo-retailcrm/assets/js/';
$jsScriptsPath = plugins_url() . self::ASSETS_DIR . '/js/';

foreach ($jsScripts as $scriptName) {
wp_register_script($scriptName, $jsScriptsPath . $scriptName . '.js', false, '0.1');
Expand All @@ -861,7 +863,7 @@ private function include_js_scripts_for_admin()
*/
public function include_whatsapp_icon_style()
{
wp_register_style('whatsapp_icon_style', plugins_url() . '/woo-retailcrm/assets/css/whatsapp-icon.min.css', false, '0.1');
wp_register_style('whatsapp_icon_style', plugins_url() . self::ASSETS_DIR . '/css/whatsapp-icon.min.css', false, '0.1');
wp_enqueue_style('whatsapp_icon_style');
}

Expand Down Expand Up @@ -1018,8 +1020,8 @@ public function show_loyalty()

$jsScript = 'retailcrm-loyalty-actions';
$loyaltyUrl = ['url' => get_admin_url()];
$jsScriptsPath = plugins_url() . '/woo-retailcrm/assets/js/';
$cssPath = plugins_url() . '/woo-retailcrm/assets/css/';
$jsScriptsPath = plugins_url() . self::ASSETS_DIR . '/js/';
$cssPath = plugins_url() . self::ASSETS_DIR . '/css/';
$messagePhone = __('Enter the correct phone number', 'retailcrm');

wp_register_script($jsScript, $jsScriptsPath . $jsScript . '.js', false, '0.1');
Expand Down Expand Up @@ -1082,14 +1084,16 @@ private function getMetaData($entity)
$metaData = ['default_retailcrm' => __('Select value', 'retailcrm')];
$sqlQuery = "SELECT DISTINCT `meta_key` FROM $table ORDER BY `meta_key`";
$defaultMetaFields = file(
__DIR__ . '/../assets/default/default_meta_fields.txt',
WP_PLUGIN_DIR . self::ASSETS_DIR . '/default/default_meta_fields.txt',
FILE_IGNORE_NEW_LINES
);

foreach ($wpdb->get_results($sqlQuery) as $metaValue) {
$metaData[$metaValue->meta_key] = $metaValue->meta_key;
}

$defaultMetaFields = apply_filters('retailcrm_change_default_meta_fields', $defaultMetaFields);

return array_diff($metaData, $defaultMetaFields);
}

Expand Down
6 changes: 5 additions & 1 deletion src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
Requires PHP: 7.0
Requires at least: 5.3
Tested up to: 6.5
Stable tag: 4.8.1
Stable tag: 4.8.2
License: GPLv1 or later
License URI: http://www.gnu.org/licenses/gpl-1.0.html

Expand Down Expand Up @@ -82,6 +82,10 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i


== Changelog ==
= 4.8.2 =
* Fixed base file customization issue
* Added a hook to update the list of meta fields

= 4.8.1 =
* Fix filtering of api query results

Expand Down
2 changes: 1 addition & 1 deletion src/retailcrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/
* Version: 4.8.1
* Version: 4.8.2
* Tested up to: 6.5
* Requires Plugins: woocommerce
* WC requires at least: 5.4
Expand Down
2 changes: 1 addition & 1 deletion src/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @link https://wordpress.org/plugins/woo-retailcrm/
*
* @version 4.8.1
* @version 4.8.2
*
* @package RetailCRM
*/
Expand Down
6 changes: 5 additions & 1 deletion tests/bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ download() {

install_wp() {
if [ -d $WP_CORE_DIR ]; then
mkdir -p $WP_CORE_DIR/wp-content/plugins/woo-retailcrm/assets/default
cp -n $PWD/src/assets/default/default_meta_fields.txt $WP_CORE_DIR/wp-content/plugins/woo-retailcrm/assets/default/
return;
fi

Expand All @@ -47,6 +49,8 @@ install_wp() {
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
mkdir -p $WP_CORE_DIR/wp-content/plugins/woo-retailcrm/assets/default
cp -n $PWD/src/assets/default/default_meta_fields.txt $WP_CORE_DIR/wp-content/plugins/woo-retailcrm/assets/default/
}

install_woocommerce() {
Expand Down Expand Up @@ -105,4 +109,4 @@ install_db() {
install_wp
install_test_suite
install_woocommerce
install_db
install_db

0 comments on commit 78fd206

Please sign in to comment.