diff --git a/includes/class-partnerexpo-core-integrations.php b/includes/class-partnerexpo-core-integrations.php new file mode 100644 index 0000000..1518321 --- /dev/null +++ b/includes/class-partnerexpo-core-integrations.php @@ -0,0 +1,15 @@ +add_action( 'comment_post', Partnerexpo_Core_Integration_Comment_Form::class, 'queue_up', 10, 3 ); + $loader->add_action( 'process_comment_data', Partnerexpo_Core_Integration_Comment_Form::class, 'run_process', 10, 1 ); + } +} \ No newline at end of file diff --git a/includes/class-partnerexpo-core-loader.php b/includes/class-partnerexpo-core-loader.php index e94e597..e3c56cb 100644 --- a/includes/class-partnerexpo-core-loader.php +++ b/includes/class-partnerexpo-core-loader.php @@ -117,11 +117,11 @@ class Partnerexpo_Core_Loader { public function run() { foreach ( $this->filters as $hook ) { - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); + add_filter( $hook['hook'], [ $hook['component'], $hook['callback'] ], $hook['priority'], $hook['accepted_args'] ); } foreach ( $this->actions as $hook ) { - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); + add_action( $hook['hook'], [ $hook['component'], $hook['callback'] ], $hook['priority'], $hook['accepted_args'] ); } } diff --git a/includes/class-partnerexpo-core.php b/includes/class-partnerexpo-core.php index f189ff4..bdcb413 100644 --- a/includes/class-partnerexpo-core.php +++ b/includes/class-partnerexpo-core.php @@ -124,15 +124,31 @@ class Partnerexpo_Core { /** * Used to have relevance-based search results. */ - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/dependency/class-query-w-relevance.php'; + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/utils/class-query-w-relevance.php'; + + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/utils/class-logger.php'; + + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-partnerexpo-core-integrations.php'; /** * The class responsible for registering custom user fields. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-partnerexpo-core-user-fields.php'; - + $this->loader = new Partnerexpo_Core_Loader(); + + $this->loader->add_action( 'init', $this, 'setup' ); + } + + public function setup() { + Logger::init("PartnerEXPO Core", __("Megjegyezve, elrejtés", 'partnerexpo-core'), 'partnerexpo-core'); + + + Partnerexpo_Core_Integrations::add_hooks( $this->loader ); + $user_fields = new Partnerexpo_Core_User_Fields( $this->loader ); + + $this->loader->run(); } /** @@ -151,7 +167,6 @@ class Partnerexpo_Core { $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); } - /** * Register all of the hooks related to the admin area functionality * of the plugin. diff --git a/includes/dependency/class-minicrm-logger.php b/includes/dependency/class-minicrm-logger.php deleted file mode 100644 index 8700cb4..0000000 --- a/includes/dependency/class-minicrm-logger.php +++ /dev/null @@ -1,97 +0,0 @@ - $message, - 'context' => $context, - 'time' => self::now_utc_plus_one() - ], - false - ); - } - - if ( class_exists( '\WC_Logger' ) ) { - $logger = wc_get_logger(); - $logger->error($message, array_merge(['source' => 'minicrm-integration'], $context)); - return; - } - - $context_str = ''; - if ( ! empty($context) ) { - $context_str = ' | ' . wp_json_encode($context); - } - error_log('[minicrm-integration] ' . $message . $context_str); - } - - /** - * Current time in UTC+1 (Y-m-d H:i:s) using wp_date(). - */ - private static function now_utc_plus_one() { - return wp_date( 'Y-m-d H:i:s', time() + HOUR_IN_SECONDS, new DateTimeZone( 'UTC' ) ); - } - - /** - * Show latest MiniCRM sync error in the admin UI so someone can act on it. - */ - public static function render_admin_notice() { - if ( ! current_user_can( 'manage_woocommerce' ) ) { - return; - } - - $error = get_option( 'minicrm_integration_last_error' ); - - if ( ! $error || empty( $error['message'] ) ) { - return; - } - - $message = esc_html( $error['message'] ); - $time = ! empty( $error['time'] ) ? esc_html( $error['time'] ) : ''; - $context = ''; - if ( ! empty( $error['context'] ) ) { - $context = '
' . esc_html( wp_json_encode( $error['context'], JSON_PARTIAL_OUTPUT_ON_ERROR ) ) . ''; - } - - $dismiss_url = wp_nonce_url( - add_query_arg( 'minicrm_clear_error', '1' ), - 'minicrm_clear_error', - 'minicrm_nonce' - ); - - printf( - '
MiniCRM integráció hiba: %s%s%s
%s:
', esc_html( self::$source ) ); + echo '' . + esc_html( wp_json_encode( $error['context'], JSON_PARTIAL_OUTPUT_ON_ERROR ) ) . + ''; + } + + printf( + '