=== Jobbnorge Block === Contributors: PerS, dssweb Tags: block Tested up to: 7.0 Requires at least: 6.5 Requires PHP: 8.2 Stable tag: 2.3.0 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html Retrieve and display job listings from Jobbnorge.no == Description == In 2.0 the new Jobbnorge API is used, and the following features are available ( ~~strikethrough~~ means removed, since it's not in the new API): - In pagination mode (default), set the number of jobs to display per page (10 is default), else set the number of jobs to display. - Sort jobs bye deadline, closest first. - Does not show jobs that are past the deadline. - Set the number of jobs to display. - ~~Set the number of words in the excerpt.~~ - Set the no jobs message. - Show or hide the job excerpt. - Show or hide the job deadline. - Show or hide the job scope. - ~~Show or hide the job duration.~~ - Display the jobs in a grid or list view. - Set the number of columns in the grid view. **New features in 2.0**: - Add more than one employer. - If more than one employer is added, order jobs by employer or deadline. - Define which employers are available in the block, using the `jobbnorge_employers` filter. = Filters = **jobbnorge_employers** The `jobbnorge_employers` filter can be used to define which employers are available in the block: ` add_filter( 'jobbnorge_employers', function( $employers ) { $employers = [ [ 'label' => 'Select employer', 'value' => '', 'disabled' => true, // Optional. ], [ 'label' => 'Employer 1', 'value' => '1234', ], [ 'label' => 'Employer 2', 'value' => '5678', ], ]; return $employers; } ); ` **jobbnorge_cache_path** The `jobbnorge_cache_path` filter can be used to define the cache path. Default is `WP_CONTENT_DIR . '/cache/jobbnorge'`. **jobbnorge_cache_time** The `jobbnorge_cache_time` filter can be used to define the cache time. Default is `30 * MINUTE_IN_SECONDS`. **jobbnorge_autoscroll_threshold** The `jobbnorge_autoscroll_threshold` filter adjusts when automatic scroll engages after pagination. The value is a float representing the fraction of the viewport height the block's top must be within to skip scrolling (default `0.25`). Example: ` add_filter( 'jobbnorge_autoscroll_threshold', function( $threshold ) { return 0.15; // Scroll only if block starts below top 15% of viewport. } ); ` = Block Settings = When pagination is enabled a setting **Disable auto scroll on pagination** becomes available. Enabling it adds a `disableAutoScroll` attribute (and `data-no-autoscroll` in markup) preventing the page from scrolling after changing pages. = GitHub = The plugin is also available on [GitHub](https://github.com/dss-web/jobbnorge-block) == Installation == Either, add the block from the Block Directory: 1. To add a block from the Block Directory, navigate to the post editor. 1. Place your cursor where you would like a new block option. 1. Select the “Add Block” button in the top-left area of the editor screen. 1. Search for “Jobbnorge” and select the “Jobbnorge" block. Or, add the block from the WordPress admin: 1. In the WordPress admin, go to the "Plugins" screen, click "Add New" and search for "Jobbnorge". 1. Click "Install Now" and then "Activate Plugin". 1. Use the Gutenberg editor to add the block to a page or post. == Frequently Asked Questions == = Where to I find the employer ID? = You get it from your Jobbnorge contact. == Screenshots == 1. Install the block from the Block Directory. 2. Add employer ID. 3. Listview with pagination. 4. Gridview with pagination. 5. Custom Select field for employer ID. Ctrl-click (Windows) or Cmd-click (Mac) to select multiple employers. Shift-click to select a range of employers. == Changelog == = 2.3.0 = * Enhancement: Bump all @wordpress dependencies to latest major versions. * Enhancement: Updated @wordpress/scripts from 26.19.0 to 31.6.0. * Fix: Replace removed `edit` icon with `pencil` from @wordpress/icons. * Compatibility: Tested up to WordPress 7.0. = 2.2.7 = * Fix: Correct malformed API URL that was missing query string delimiter, causing "Request error retrieving jobs" (400 Bad Request). = 2.2.6 = * Fix: Wrap render function in try-catch to prevent API/network errors from breaking the page. * Fix: Add error handling in cache handler to gracefully handle file read/write failures. * Fix: Add bounds checking in `parse_date_fallback()` to handle malformed date strings. * Fix: Validate cache directory path before file operations to prevent "Path cannot be empty" errors. * Fix: Add directory writability check in cache handler. * Enhancement: Improved JavaScript error display - shows warning instead of error, re-enables retry buttons. * Enhancement: Added `jobbnorge_block_render_error` action hook for debugging render failures. = 2.2.5 = * Cleanup: Removed temporary diagnostic probe (pre_render_block) and all debug logging. * Cleanup: Eliminated debug HTML marker while retaining safe synthetic AJAX context and wrapper fallback. * Stability: Retained attribute/supports normalization safeguards to prevent core block supports warnings. * Internal: Version bump and asset rebuild prepping for release. = 2.2.4 = * Fix: Normalize block registration to standard pattern to avoid potential core notices when resolving block supports. * Fix: Add defensive guard ensuring `$attributes` is always an array in `render_block_dss_jobbnorge`. * Fix: Move serialized `data-attributes` JSON from wrapper `