From 712bca0f69e5a195995e0004a0622d38ee965f68 Mon Sep 17 00:00:00 2001 From: threadi Date: Mon, 3 Feb 2025 16:23:49 +0100 Subject: [PATCH] prepare release 4.2.0 --- app/Helper.php | 13 +++---- app/PageBuilder/Gutenberg/Blocks/Archive.php | 14 ------- app/PersonioIntegration/Availability.php | 2 +- app/PersonioIntegration/Extensions.php | 34 ++++++++--------- app/PersonioIntegration/Import.php | 37 +----------------- .../PostTypes/PersonioPosition.php | 18 +++++---- app/Plugin/Admin/Admin.php | 8 ++-- app/Plugin/Init.php | 6 +++ app/Plugin/Intro.php | 2 +- app/Plugin/Settings.php | 4 +- app/Plugin/Setup.php | 2 +- app/Plugin/Templates.php | 2 +- blocks/list/block.json | 12 ------ blocks/list/src/edit.js | 27 ------------- changelog.md | 10 ++++- readme.txt | 38 ++++++------------- 16 files changed, 70 insertions(+), 159 deletions(-) diff --git a/app/Helper.php b/app/Helper.php index f3c0671b..bb6ce045 100644 --- a/app/Helper.php +++ b/app/Helper.php @@ -744,22 +744,19 @@ public static function get_github_documentation_link(): string { */ public static function do_not_load_styles( string $hook ): bool { // bail if function is used in frontend. - if( ! is_admin() ) { + if ( ! is_admin() ) { return false; } // do not load our files outside our own backend pages. - if( in_array( $hook, array( 'post.php', 'edit-tags.php'), true ) && function_exists( 'get_current_screen' ) ) { + if ( in_array( $hook, array( 'post.php', 'edit-tags.php' ), true ) && function_exists( 'get_current_screen' ) ) { $screen = get_current_screen(); - if( ! in_array( $screen->post_type, apply_filters( 'personio_integration_light_do_not_load_on_cpt', array( PersonioPosition::get_instance()->get_name() ) ), true ) ) { + if ( ! in_array( $screen->post_type, apply_filters( 'personio_integration_light_do_not_load_on_cpt', array( PersonioPosition::get_instance()->get_name() ) ), true ) ) { return true; } - } - else { + } elseif ( ! str_contains( $hook, 'personio' ) && ! str_contains( $hook, 'options-permalink.php' ) ) { // bail if no personio page is used. - if ( ! str_contains( $hook, 'personio' ) && ! str_contains( $hook, 'options-permalink.php' ) ) { - return true; - } + return true; } // return false to not prevent the loading of styles in backend. diff --git a/app/PageBuilder/Gutenberg/Blocks/Archive.php b/app/PageBuilder/Gutenberg/Blocks/Archive.php index ef9725ce..83ff0c79 100644 --- a/app/PageBuilder/Gutenberg/Blocks/Archive.php +++ b/app/PageBuilder/Gutenberg/Blocks/Archive.php @@ -43,18 +43,6 @@ class Archive extends Blocks_Basis { 'type' => 'boolean', 'default' => false, ), - 'showFilter' => array( - 'type' => 'boolean', - 'default' => false, - ), - 'filter' => array( - 'type' => 'array', - 'default' => array( 'recruitingCategory', 'schedule', 'office' ), - ), - 'filtertype' => array( - 'type' => 'string', - 'default' => 'linklist', - ), 'limit' => array( 'type' => 'integer', 'default' => 0, @@ -150,8 +138,6 @@ public function render( array $attributes ): string { 'sortby' => $attributes['sortby'], 'groupby' => $attributes['groupby'], 'limit' => absint( $attributes['limit'] ), - 'filter' => implode( ',', $attributes['filter'] ), - 'filtertype' => $attributes['filtertype'], 'showfilter' => false, 'show_back_to_list' => '', 'styles' => implode( PHP_EOL, $styles_array ), diff --git a/app/PersonioIntegration/Availability.php b/app/PersonioIntegration/Availability.php index d0b94228..950e7c85 100644 --- a/app/PersonioIntegration/Availability.php +++ b/app/PersonioIntegration/Availability.php @@ -318,7 +318,7 @@ protected function is_default_enabled(): bool { */ public function add_js( string $hook ): void { // do not load styles depending on used hook. - if( Helper::do_not_load_styles( $hook ) ) { + if ( Helper::do_not_load_styles( $hook ) ) { return; } diff --git a/app/PersonioIntegration/Extensions.php b/app/PersonioIntegration/Extensions.php index bfa6271d..2eb21701 100644 --- a/app/PersonioIntegration/Extensions.php +++ b/app/PersonioIntegration/Extensions.php @@ -209,9 +209,9 @@ public function change_extension_state(): void { ), 'buttons' => array( array( - 'action' => 'closeDialog();', + 'action' => 'closeDialog();', 'variant' => 'primary', - 'text' => __( 'OK', 'personio-integration-light' ), + 'text' => __( 'OK', 'personio-integration-light' ), ), ), ), @@ -223,7 +223,7 @@ public function change_extension_state(): void { $obj = $this->get_extension_by_name( $extension_name ); // bail if extension could not be found. - if( ! $obj instanceof Extensions_Base ) { + if ( ! $obj instanceof Extensions_Base ) { wp_send_json_error( array( 'detail' => @@ -234,9 +234,9 @@ public function change_extension_state(): void { ), 'buttons' => array( array( - 'action' => 'closeDialog();', + 'action' => 'closeDialog();', 'variant' => 'primary', - 'text' => __( 'OK', 'personio-integration-light' ), + 'text' => __( 'OK', 'personio-integration-light' ), ), ), ), @@ -248,12 +248,12 @@ public function change_extension_state(): void { $obj->toggle_state(); // return success-message depending on the new extension state. - $title = __( 'Extension has been disabled', 'personio-integration-light' ); - $text = __( 'The extension has been disabled.', 'personio-integration-light' ); + $title = __( 'Extension has been disabled', 'personio-integration-light' ); + $text = __( 'The extension has been disabled.', 'personio-integration-light' ); $button_title = __( 'Disabled', 'personio-integration-light' ); - if( $obj->is_enabled() ) { - $title = __( 'Extension has been enabled', 'personio-integration-light' ); - $text = __( 'The extension has been successfully enabled.', 'personio-integration-light' ); + if ( $obj->is_enabled() ) { + $title = __( 'Extension has been enabled', 'personio-integration-light' ); + $text = __( 'The extension has been successfully enabled.', 'personio-integration-light' ); $button_title = __( 'Enabled', 'personio-integration-light' ); } @@ -265,9 +265,9 @@ public function change_extension_state(): void { ), 'buttons' => array( array( - 'action' => 'closeDialog();', + 'action' => 'closeDialog();', 'variant' => 'primary', - 'text' => __( 'OK', 'personio-integration-light' ), + 'text' => __( 'OK', 'personio-integration-light' ), ), ), ); @@ -277,12 +277,12 @@ public function change_extension_state(): void { */ $dialog = apply_filters( 'personio_integration_light_extension_state_changed_dialog', $dialog, $obj ); - if( $obj->is_enabled() ) { + if ( $obj->is_enabled() ) { // send the answer. wp_send_json_success( array( - 'detail' => $dialog, - 'button_title' => $button_title + 'detail' => $dialog, + 'button_title' => $button_title, ) ); } @@ -290,8 +290,8 @@ public function change_extension_state(): void { // send the answer. wp_send_json_error( array( - 'detail' => $dialog, - 'button_title' => $button_title + 'detail' => $dialog, + 'button_title' => $button_title, ) ); } diff --git a/app/PersonioIntegration/Import.php b/app/PersonioIntegration/Import.php index e81c2597..d8cbdb68 100644 --- a/app/PersonioIntegration/Import.php +++ b/app/PersonioIntegration/Import.php @@ -15,7 +15,6 @@ use Exception; use PersonioIntegrationLight\Plugin\Languages; use SimpleXMLElement; -use WP_Post; /** * Import-handling for positions from Personio. @@ -366,40 +365,6 @@ public function run(): void { /* translators: %1$s will be replaced by the Personio account URL, %2$s by the language title. */ $this->log->add_log( sprintf( __( 'Import of positions from Personio account %1$s for language %2$s ended.', 'personio-integration-light' ), wp_kses_post( $this->get_link() ), esc_html( $language_title ) ), 'success', 'import' ); } - else { - $true = true; - /** - * Do not delete positions if Personio sends 0 positions. - * - * @since 4.2.0 Available since 4.2.0 - * @param bool $true Must be false to prevent deletion in this case. - * @noinspection PhpConditionAlreadyCheckedInspection - **/ - if( apply_filters( 'personio_integration_import_delete_if_no_positions_returned', $true ) ) { - // remove all positions as we got none from Personio. - foreach ( $positions_obj->get_positions() as $position_obj ) { - if ( ! $position_obj instanceof Position ) { - continue; - } - - // get Personio ID for logging. - $personio_id = $position_obj->get_personio_id(); - - // delete this position from database without using trash. - $result = wp_delete_post( $position_obj->get_id(), true ); - - if ( $result instanceof WP_Post ) { - // log this event. - /* translators: %1$s will be replaced by the PersonioID. */ - $this->log->add_log( sprintf( __( 'Position %1$s has been deleted as it was not updated during the last import run.', 'personio-integration-light' ), esc_html( $personio_id ) ), 'success', 'import' ); - } else { - // log event. - /* translators: %1$s will be replaced by the PersonioID. */ - $this->log->add_log( sprintf( __( 'Removing of not updated position %1$s failed.', 'personio-integration-light' ), esc_html( $personio_id ) ), 'error', 'import' ); - } - } - } - } // log ok. /* translators: %1$d will be replaced by a number, %2$s by the Personio account URL and %3$s by the language title. */ @@ -485,7 +450,7 @@ public function set_xml_positions( SimpleXMLElement $xml_positions ): void { * @return bool */ private function has_xml_positions(): bool { - return count( $this->get_xml_positions() ) > 0; + return ! empty( $this->get_xml_positions() ); } /** diff --git a/app/PersonioIntegration/PostTypes/PersonioPosition.php b/app/PersonioIntegration/PostTypes/PersonioPosition.php index 32fe790b..e4fac9d0 100644 --- a/app/PersonioIntegration/PostTypes/PersonioPosition.php +++ b/app/PersonioIntegration/PostTypes/PersonioPosition.php @@ -1633,7 +1633,9 @@ public function get_dashboard_widget_content( string $post, array $callback_args $positions_obj = Positions::get_instance(); // show wrapper. - ?>
+ +
+ __( 'All positions have been deleted from WordPress.
They are still available in Personio.
You can re-import the positions at any time.', 'personio-integration-light' ), 'title_error' => __( 'Error', 'personio-integration-light' ), 'txt_error' => __( 'An unexpected error occurred. The error was:', 'personio-integration-light' ), - 'generate_error_text' => __( 'Unknown error during AJAX-request', 'personio-integration-light' ) + 'generate_error_text' => __( 'Unknown error during AJAX-request', 'personio-integration-light' ), ) ); @@ -187,11 +187,9 @@ public function add_styles_and_js(): void { /** * Add the dialog-scripts and -styles. * - * @param string $hook The used hook. - * * @return void */ - public function add_dialog( string $hook ): void { + public function add_dialog(): void { // embed necessary scripts for dialog. $path = Helper::get_plugin_path() . 'vendor/threadi/easy-dialog-for-wordpress/'; $url = Helper::get_plugin_url() . 'vendor/threadi/easy-dialog-for-wordpress/'; @@ -239,7 +237,7 @@ public function add_dialog( string $hook ): void { * @return void */ public function show_pro_hint( string $hint ): void { - $text = 'Personio Integration Pro (opens new window)'; + $text = '' . esc_html__( 'Personio Integration Pro (opens new window)', 'personio-integration-light' ) . ''; /** * Filter the pro hint text. * diff --git a/app/Plugin/Init.php b/app/Plugin/Init.php index 77b68443..1381eecb 100644 --- a/app/Plugin/Init.php +++ b/app/Plugin/Init.php @@ -326,6 +326,12 @@ public function check_php(): void { // get transients object. $transients_obj = Transients::get_instance(); + // bail if setup has not been run yet. + if ( ! Setup::get_instance()->is_completed() ) { + $transients_obj->delete_transient( $transients_obj->get_transient_by_name( 'personio_integration_light_php_hint' ) ); + return; + } + // bail if WordPress is in developer mode. if ( function_exists( 'wp_is_development_mode' ) && wp_is_development_mode( 'plugin' ) ) { $transients_obj->delete_transient( $transients_obj->get_transient_by_name( 'personio_integration_light_php_hint' ) ); diff --git a/app/Plugin/Intro.php b/app/Plugin/Intro.php index da19c136..10fe2595 100644 --- a/app/Plugin/Intro.php +++ b/app/Plugin/Intro.php @@ -126,7 +126,7 @@ public function closed(): void { */ public function add_js( string $hook ): void { // do not load styles depending on used hook. - if( Helper::do_not_load_styles( $hook ) ) { + if ( Helper::do_not_load_styles( $hook ) ) { return; } diff --git a/app/Plugin/Settings.php b/app/Plugin/Settings.php index 65393db5..7ea394f9 100644 --- a/app/Plugin/Settings.php +++ b/app/Plugin/Settings.php @@ -317,7 +317,7 @@ public function set_settings(): void { 'personioIntegrationEnableFilter' => 1, ), ), - 'personioIntegrationHideFilterTitle' => array( + 'personioIntegrationHideFilterTitle' => array( 'label' => __( 'Hide filter title', 'personio-integration-light' ), 'field' => array( 'PersonioIntegrationLight\Plugin\Admin\SettingFields\Checkbox', 'get' ), 'options' => Helper::get_filter_types(), @@ -330,7 +330,7 @@ public function set_settings(): void { 'personioIntegrationEnableFilter' => 1, ), ), - 'personioIntegrationHideFilterReset' => array( + 'personioIntegrationHideFilterReset' => array( 'label' => __( 'Hide reset link', 'personio-integration-light' ), 'field' => array( 'PersonioIntegrationLight\Plugin\Admin\SettingFields\Checkbox', 'get' ), 'options' => Helper::get_filter_types(), diff --git a/app/Plugin/Setup.php b/app/Plugin/Setup.php index 45cdb73c..6aea7cd6 100644 --- a/app/Plugin/Setup.php +++ b/app/Plugin/Setup.php @@ -91,7 +91,7 @@ public function init_setup(): void { 'txt_error_2' => sprintf( __( 'If reason is unclear please contact our support-forum (opens new window) with as much detail as possible.', 'personio-integration-light' ), esc_url( Helper::get_plugin_support_url() ) ), ) ); - $setup_obj->set_display_hook( Helper::get_archive_slug() . '_page_personioPositions' ); + $setup_obj->set_display_hook( 'stellen_page_personioPositions' ); // set configuration for setup. $setup_obj->set_config( $this->get_config() ); diff --git a/app/Plugin/Templates.php b/app/Plugin/Templates.php index e0c48bee..c5d4b72c 100644 --- a/app/Plugin/Templates.php +++ b/app/Plugin/Templates.php @@ -1092,7 +1092,7 @@ public function set_link_to_anchor( array $attributes, array $attributes_set_by_ } // bail if no filter is set. - if( empty( $attributes['filter'] ) ) { + if ( empty( $attributes['filter'] ) ) { return $attributes; } diff --git a/blocks/list/block.json b/blocks/list/block.json index 336eb911..c8581cb1 100644 --- a/blocks/list/block.json +++ b/blocks/list/block.json @@ -35,18 +35,6 @@ "type": "boolean", "default": false }, - "showFilter": { - "type": "boolean", - "default": false - }, - "filter": { - "type": "array", - "default": ["recruitingCategory","schedule","office"] - }, - "filtertype": { - "type": "string", - "default": "linklist" - }, "limit": { "type": "integer", "default": 0 diff --git a/blocks/list/src/edit.js b/blocks/list/src/edit.js index 3dc9dc06..af0355af 100644 --- a/blocks/list/src/edit.js +++ b/blocks/list/src/edit.js @@ -204,33 +204,6 @@ export default function Edit( object ) { /> - -

{ __( 'Please use the Filter Block instead of this options.', 'personio-integration-light' ) }

- onChangeShowFilter( value, object ) } - /> -
- { - onChangeFilter(value, object) } - /> - } -
- onChangeFilterType( value, object ) } - /> -