Skip to content

Commit

Permalink
Merge pull request #336 from threadi/feature/prepareRelease420
Browse files Browse the repository at this point in the history
prepare release 4.2.0
  • Loading branch information
threadi authored Feb 3, 2025
2 parents 878f6ab + 712bca0 commit 89ab881
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 159 deletions.
13 changes: 5 additions & 8 deletions app/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 0 additions & 14 deletions app/PageBuilder/Gutenberg/Blocks/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 ),
Expand Down
2 changes: 1 addition & 1 deletion app/PersonioIntegration/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
34 changes: 17 additions & 17 deletions app/PersonioIntegration/Extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
),
),
),
Expand All @@ -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' =>
Expand All @@ -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' ),
),
),
),
Expand All @@ -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' );
}

Expand All @@ -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' ),
),
),
);
Expand All @@ -277,21 +277,21 @@ 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,
)
);
}

// send the answer.
wp_send_json_error(
array(
'detail' => $dialog,
'button_title' => $button_title
'detail' => $dialog,
'button_title' => $button_title,
)
);
}
Expand Down
37 changes: 1 addition & 36 deletions app/PersonioIntegration/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Exception;
use PersonioIntegrationLight\Plugin\Languages;
use SimpleXMLElement;
use WP_Post;

/**
* Import-handling for positions from Personio.
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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() );
}

/**
Expand Down
18 changes: 11 additions & 7 deletions app/PersonioIntegration/PostTypes/PersonioPosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,9 @@ public function get_dashboard_widget_content( string $post, array $callback_args
$positions_obj = Positions::get_instance();

// show wrapper.
?><div class="community-events"><?php
?>
<div class="community-events">
<?php

// show results.
if ( 0 === $position_count ) {
Expand Down Expand Up @@ -1670,16 +1672,18 @@ public function get_dashboard_widget_content( string $post, array $callback_args
?>
</ul>
<p><a href="<?php echo esc_url( $this->get_link() ); ?>">
<?php
/* translators: %1$d will be replaced by the count of positions */
printf( esc_html__( 'Show all %1$d positions', 'personio-integration-light' ), absint( $position_count ) );
?>
<?php
/* translators: %1$d will be replaced by the count of positions */
printf( esc_html__( 'Show all %1$d positions', 'personio-integration-light' ), absint( $position_count ) );
?>
</a></p>
<?php
}

// show end of wrapper.
?></div><?php
?>
</div>
<?php
}

/**
Expand Down Expand Up @@ -2303,6 +2307,6 @@ private function get_default_classes(): string {
$css_classes = apply_filters( 'personio_integration_light_default_css_classes', $css_classes );

// return the resulting list.
return implode(' ', $css_classes );
return implode( ' ', $css_classes );
}
}
8 changes: 3 additions & 5 deletions app/Plugin/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function add_styles_and_js(): void {
'txt_deletion_success' => __( '<strong>All positions have been deleted from WordPress.</strong><br>They are still available in Personio.<br>You can re-import the positions at any time.', 'personio-integration-light' ),
'title_error' => __( 'Error', 'personio-integration-light' ),
'txt_error' => __( '<strong>An unexpected error occurred.</strong> 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' ),
)
);

Expand All @@ -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/';
Expand Down Expand Up @@ -239,7 +237,7 @@ public function add_dialog( string $hook ): void {
* @return void
*/
public function show_pro_hint( string $hint ): void {
$text = '<a href="' . esc_url( Helper::get_pro_url() ) . '" target="_blank">Personio Integration Pro (opens new window)</a>';
$text = '<a href="' . esc_url( Helper::get_pro_url() ) . '" target="_blank">' . esc_html__( 'Personio Integration Pro (opens new window)', 'personio-integration-light' ) . '</a>';
/**
* Filter the pro hint text.
*
Expand Down
6 changes: 6 additions & 0 deletions app/Plugin/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down
2 changes: 1 addition & 1 deletion app/Plugin/Intro.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions app/Plugin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion app/Plugin/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function init_setup(): void {
'txt_error_2' => sprintf( __( '<strong>If reason is unclear</strong> please contact our <a href="%1$s" target="_blank">support-forum (opens new window)</a> 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() );
Expand Down
2 changes: 1 addition & 1 deletion app/Plugin/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 0 additions & 12 deletions blocks/list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 0 additions & 27 deletions blocks/list/src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,33 +204,6 @@ export default function Edit( object ) {
/>
</PanelBody>
<Personio_Helper_Panel/>
<PanelBody initialOpen={false} title={ __( 'Filter', 'personio-integration-light' ) }>
<div className="alert"><p>{ __( 'Please use the Filter Block instead of this options.', 'personio-integration-light' ) }</p></div>
<ToggleControl
label={ __('Show filter', 'personio-integration-light') }
checked={ object.attributes.showFilter }
onChange={ value => onChangeShowFilter( value, object ) }
/>
<div className="wp-personio-integration-selectcontrol-multiple">
{
<SelectControl
label={ __('Choose filter', 'personio-integration-light') }
value={ object.attributes.filter }
options={ personioTaxonomies }
multiple={ true }
disabled={ !object.attributes.showFilter }
onChange={ value => onChangeFilter(value, object) }
/>
}
</div>
<SelectControl
label={ __('Type of filter', 'personio-integration-light') }
value={ object.attributes.filtertype }
options={ filter_types }
disabled={ !object.attributes.showFilter }
onChange={ value => onChangeFilterType( value, object ) }
/>
</PanelBody>
</InspectorControls>
<ServerSideRender
block="wp-personio-integration/list"
Expand Down
Loading

0 comments on commit 89ab881

Please sign in to comment.