Skip to content

Commit

Permalink
Merge pull request #338 from threadi/feature/prepareRelease422
Browse files Browse the repository at this point in the history
Feature/prepare release422
  • Loading branch information
threadi authored Feb 17, 2025
2 parents e69ae4b + 5034ecd commit fa0f3a4
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 18 deletions.
2 changes: 1 addition & 1 deletion admin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ jQuery(document).ready(function($) {
}
]
} ).onexit( function() {
location.href=window.location.href.replace( /template_intro=2/, '' )
location.href=window.location.href.replace( /template_intro=1/, '' ).replace( /template_intro=2/, '' )
} ).start();
});

Expand Down
5 changes: 4 additions & 1 deletion admin/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,15 @@ body.easy-dialog-for-wordpress.wp-core-ui .easy-dialog-for-wordpress-text:last-o

body form.personio-integration-settings input.button { margin-right: 1em }

body .review-hint-button:after {
body.post-type-personioposition a.review-hint-button:after {
color: #d4af37;
content: "\f155 \f155 \f155 \f155 \f155";
display: inline-block;
font-family: "dashicons", sans-serif;
margin-left: 8px;
position: relative;
top: -2px;
z-index: 1;
}

.personio-integration-applications-hint button.is-primary:after {
Expand Down
2 changes: 1 addition & 1 deletion app/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public static function do_not_load_styles( string $hook ): bool {
}

// 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( 'edit.php', '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 ) ) {
return true;
Expand Down
56 changes: 56 additions & 0 deletions app/PersonioIntegration/PostTypes/PersonioPosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function init(): void {
add_filter( 'parse_query', array( $this, 'use_filter' ) );
add_filter( 'views_edit-' . $this->get_name(), array( $this, 'hide_cpt_filter' ), 10, 0 );
add_filter( 'pre_get_posts', array( $this, 'ignore_author' ) );
add_filter( 'posts_search', array( $this, 'search_also_in_meta_fields' ), 10, 2 );

// edit positions.
add_action( 'admin_init', array( $this, 'remove_cpt_supports' ) );
Expand Down Expand Up @@ -2309,4 +2310,59 @@ private function get_default_classes(): string {
// return the resulting list.
return implode( ' ', $css_classes );
}

/**
* Search in backend also in every postmeta for our positions.
*
* @param string $search The searched keywords.
* @param WP_Query $wp_query The WP_Query-object.
*
* @return string
*/
public function search_also_in_meta_fields( string $search, WP_Query $wp_query ): string {
// bail if we are not in admin.
if ( ! is_admin() ) {
return $search;
}

// bail if search string is empty.
if ( empty( $search ) ) {
return $search;
}

// bail if no keywords are available.
if ( empty( $wp_query->get( 's' ) ) ) {
return $search;
}

// bail if this is not our cpt.
if ( $this->get_name() !== $wp_query->get( 'post_type' ) ) {
return $search;
}

// get db object.
global $wpdb;

// get the search term from the query.
$search_term = $wp_query->query['s'];
$search = '';

// build SQL to search post title and content.
$search .= "($wpdb->posts.post_title LIKE '%" . $wpdb->esc_like( $search_term ) . "%') OR ($wpdb->posts.post_content LIKE '%" . $wpdb->esc_like( $search_term ) . "%')";

// add SQL to also search postmeta table for matching custom field values.
$search .= " OR EXISTS (
SELECT * FROM $wpdb->postmeta
WHERE post_id = $wpdb->posts.ID
AND meta_value LIKE '%" . $wpdb->esc_like( $search_term ) . "%'
)";

// wrap the search conditions in parentheses and add AND.
if ( ! empty( $search ) ) {
$search = ' AND (' . $search . ') ';
}

// return resulting search SQL string.
return $search;
}
}
6 changes: 4 additions & 2 deletions app/Plugin/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,15 @@ public function add_body_classes( string $classes ): string {
// enable intros if set as parameter.
$import_intro = filter_input( INPUT_GET, 'import_intro', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( ! empty( $import_intro ) ) {
Intro::get_instance()->add_js();
global $pagenow;
Intro::get_instance()->add_js( $pagenow );
$classes .= ' personio-integration-import-intro';
}
// enable intros if set as parameter.
$template_intro = filter_input( INPUT_GET, 'template_intro', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( ! empty( $template_intro ) ) {
Intro::get_instance()->add_js();
global $pagenow;
Intro::get_instance()->add_js( $pagenow );
$classes .= ' personio-integration-template-intro';
}

Expand Down
9 changes: 8 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Changelog

## [Unreleased]
## [4.2.2] - 17.02.2025

### Optimized

- Search for post meta fields of our own cpt in backend (e.g. search for Position ID is now possible)
- Optimized button styles for options in backend

### Fixed

- Fixed missing hook on Block Detail
- Fixed error on intro usage
- Fixed canceling of intro on first intro page

## [4.2.1] - 03.02.2025

Expand Down
17 changes: 5 additions & 12 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,10 @@ Complete revision of the plugin. Please create a backup before installing versio
== Changelog ==

= @@VersionNumber@@ =
- Added default options to hide title and reset link on filter
- Optimized loading of JS in backend to in order not to influence the loading times there too much
- Optimized output of positions in WordPress dashboard
- Changed dialog and handling of extension state changes
- All external links are now marked with an icon
- Clearer error text for AJAX errors
- Show PHP-version-hint only after setup has been run
- Removed support for filter on archive-widget (please use the filter-widget for this)
- Removed support for all since version 3.0.0 as deprecated marked functions and attributes
- Fixed potential PHP-warning regarding filter in templates
- Fixed missing usage of colon and line break settings for details template
- Fixed missing translations
- Search for post meta fields of our own cpt in backend (e.g. search for Position ID is now possible)
- Optimized button styles for options in backend
- Fixed missing hook on Block Detail
- Fixed error on intro usage
- Fixed canceling of intro on first intro page

[older changes](https://github.com/threadi/wp-personio-integration-light/blob/master/changelog.md)

0 comments on commit fa0f3a4

Please sign in to comment.