diff --git a/admin/main.js b/admin/main.js index e04a6f1..6623bf9 100644 --- a/admin/main.js +++ b/admin/main.js @@ -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(); }); diff --git a/admin/styles.css b/admin/styles.css index 58ce7ac..8f62298 100644 --- a/admin/styles.css +++ b/admin/styles.css @@ -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 { diff --git a/app/Helper.php b/app/Helper.php index bb6ce04..87e15e3 100644 --- a/app/Helper.php +++ b/app/Helper.php @@ -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; diff --git a/app/PersonioIntegration/PostTypes/PersonioPosition.php b/app/PersonioIntegration/PostTypes/PersonioPosition.php index e4fac9d..efd5f8e 100644 --- a/app/PersonioIntegration/PostTypes/PersonioPosition.php +++ b/app/PersonioIntegration/PostTypes/PersonioPosition.php @@ -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' ) ); @@ -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; + } } diff --git a/app/Plugin/Admin/Admin.php b/app/Plugin/Admin/Admin.php index 4f27043..ec55276 100644 --- a/app/Plugin/Admin/Admin.php +++ b/app/Plugin/Admin/Admin.php @@ -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'; } diff --git a/changelog.md b/changelog.md index b96735e..d1da33a 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/readme.txt b/readme.txt index 70e08f6..f41af3b 100644 --- a/readme.txt +++ b/readme.txt @@ -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)