Skip to content

Commit

Permalink
(refactor): usage of upl resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike van den Hoek authored and mvdhoek1 committed Aug 21, 2023
1 parent 2ec4a1a commit 5cc5a09
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Version 2.1.1

### Refactor

- Usage of upl resource.

## Version 2.1.0

### Features
Expand Down
4 changes: 2 additions & 2 deletions pdc-samenwerkende-catalogi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: PDC Samenwerkende Catalogi
* Plugin URI: https://www.openwebconcept.nl/
* Description: Plugin to create a XML feed according to the Samenwerkende Catalogi requirements.
* Version: 2.1.0
* Version: 2.1.1
* Author: Yard | Digital Agency
* Author URI: https://www.yard.nl/
* License: GPL-3.0
Expand All @@ -19,7 +19,7 @@
/**
* If this file is called directly, abort.
*/
if (!defined('WPINC')) {
if (! defined('WPINC')) {
die;
}

Expand Down
5 changes: 2 additions & 3 deletions src/SamenwerkendeCatalogi/Foundation/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@
*/
class Plugin extends BasePlugin
{

/**
* Name of the plugin.
*
* @const string NAME
*/
const NAME = 'pdc-samenwerkende-catalogi';
public const NAME = 'pdc-samenwerkende-catalogi';

/**
* Version of the plugin.
* Used for setting versions of enqueue scripts and styles.
*
* @const string VERSION
*/
const VERSION = '2.1.0';
public const VERSION = '2.1.1';

protected function checkForUpdate()
{
Expand Down
30 changes: 16 additions & 14 deletions src/SamenwerkendeCatalogi/Models/ScItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getDoelgroepen(): array
/**
* @param array $doelgroepen
* @param object $doelgroepTerm
*
*
* @return array
*/
private function assignDoelgroepen($doelgroepen = [], $doelgroepTerm): array
Expand All @@ -58,9 +58,6 @@ private function assignDoelgroepen($doelgroepen = [], $doelgroepTerm): array
return $doelgroepen;
}

/**
* @return string
*/
public function getUplName(): string
{
$uplName = get_post_meta($this->getID(), '_owc_pdc_upl_naam', true);
Expand All @@ -69,29 +66,34 @@ public function getUplName(): string
$uplName = $this->getTitle();
}

return $this->stripUpl($uplName);
return $uplName;
}

public function getStrippedUplName(): string
{
return $this->stripUpl($this->getUplName());
}

/**
* @return string
*/
public function getUplResource(): string
{
return 'http://standaarden.overheid.nl/owms/terms/' . $this->getUplName();
$uplResource = get_post_meta($this->getID(), '_owc_pdc_upl_resource', true);

if (empty($uplResource)) {
$uplResource = $this->getStrippedUplName();
}

return 'http://standaarden.overheid.nl/owms/terms/' . $uplResource;
}

/**
* Strip upl to required format.
*
* @param string $string
* @return string
*/
protected function stripUpl(string $string): string
{
// replace all spaces with dashes.
// Replace all spaces with dashes.
$string = str_replace(' ', '-', strtolower($string));

// replace all the characters except lowercase letters and dashes.
// Replace all the characters except lowercase letters and dashes.
return preg_replace("/[^a-z|-]/", "", $string);
}
}

0 comments on commit 5cc5a09

Please sign in to comment.