From 0b62bf39be28d0123b07b0c94bb9f9bfd9efc109 Mon Sep 17 00:00:00 2001 From: Rolf Date: Tue, 21 Jun 2022 16:10:44 +0200 Subject: [PATCH 1/3] Delete I18n.php --- src/I18n.php | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/I18n.php diff --git a/src/I18n.php b/src/I18n.php deleted file mode 100644 index 2026946..0000000 --- a/src/I18n.php +++ /dev/null @@ -1,15 +0,0 @@ - Date: Tue, 21 Jun 2022 16:10:49 +0200 Subject: [PATCH 2/3] Delete rrze-wp.pot --- src/languages/rrze-wp.pot | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/languages/rrze-wp.pot diff --git a/src/languages/rrze-wp.pot b/src/languages/rrze-wp.pot deleted file mode 100644 index 88edb65..0000000 --- a/src/languages/rrze-wp.pot +++ /dev/null @@ -1,33 +0,0 @@ -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: RRZE WP\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-01-18 " -"09:24+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME " -"\n" -"Language-Team: \n" -"Plural-Forms: nplurals=INTEGER; " -"plural=EXPRESSION;\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.4.2\n" -"X-Poedit-KeywordsList: __;_e;_x:1,2c;" -"_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" -"_nx_noop:1,2,3c;esc_attr__;esc_html__;" -"esc_attr_e;esc_html_e;esc_attr_x:1,2c;" -"esc_html_x:1,2c\n" -"Plural-Forms: nplurals=2; plural=(n != " -"1);\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-Basepath: ..\n" -"X-Textdomain-Support: yes\n" -"X-Poedit-SearchPath-0: .\n" - -#: Plugin.php:189 -#, php-format -msgid "Call to undefined method %1$s::%2$s" -msgstr "" From 4f92b52fba6c828cb4562d9bf5d666c8e24d87dd Mon Sep 17 00:00:00 2001 From: Rolf Date: Tue, 21 Jun 2022 16:10:59 +0200 Subject: [PATCH 3/3] Update Plugin.php --- src/Plugin.php | 88 +++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index dfff323..80db0cb 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -8,49 +8,45 @@ class Plugin { /** * The full path and filename of the plugin. - * * @var string */ - protected $plugin_file; + protected $pluginFile; /** * The basename of the plugin. - * * @var string */ protected $basename; /** * The filesystem directory path (with trailing slash) for the plugin. - * * @var string */ protected $directory; /** * The URL directory path (with trailing slash) for the plugin. - * * @var string */ protected $url; /** * The version of the plugin. - * * @var string */ protected $version; /** - * @param string $plugin_file The full path and filename of the plugin. + * __construct method + * @param string $pluginFile The full path and filename of the plugin. */ - public function __construct(string $plugin_file) + public function __construct(string $pluginFile) { - $this->plugin_file = $plugin_file; + $this->pluginFile = $pluginFile; } /** - * Execute on loaded hook. + * loaded method */ public function loaded() { @@ -61,142 +57,146 @@ public function loaded() } /** + * getFile method * Get the full path and filename of the plugin. - * * @return string The full path and filename. */ - public function getFile() + public function getFile(): string { - return $this->plugin_file; + return $this->pluginFile; } /** + * getBasename method * Get the basename of the plugin. - * * @return string The basename. */ - public function getBasename() + public function getBasename(): string { return $this->basename; } /** + * setBasename method * Set the basename of the plugin. - * * @return object This Plugin object. */ - public function setBasename() + public function setBasename(): object { - $this->basename = plugin_basename($this->plugin_file); + $this->basename = plugin_basename($this->pluginFile); return $this; } /** + * getDirectory method * Get the filesystem directory path (with trailing slash) for the plugin. - * * @return string The filesystem directory path. */ - public function getDirectory() + public function getDirectory(): string { return $this->directory; } /** + * setDirectory method * Set the filesystem directory path (with trailing slash) for the plugin. - * * @return object This Plugin object. */ - public function setDirectory() + public function setDirectory(): object { - $this->directory = rtrim(plugin_dir_path($this->plugin_file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + $this->directory = rtrim(plugin_dir_path($this->pluginFile), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; return $this; } /** + * getPath method * Get the filesystem directory path (with trailing slash) for the plugin. - * * @param string $path The path name. * @return string The filesystem directory path. */ - public function getPath(string $path = '') + public function getPath(string $path = ''): string { return $this->directory . ltrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; } /** + * getUrl method * Get the URL directory path (with trailing slash) for the plugin. - * * @param string $path The path name. * @return string The URL directory path. */ - public function getUrl(string $path = '') + public function getUrl(string $path = ''): string { return $this->url . ltrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; } /** + * setUrl method * Set the URL directory path (with trailing slash) for the plugin. - * * @return object This Plugin object. */ - public function setUrl() + public function setUrl(): object { - $this->url = rtrim(plugin_dir_url($this->plugin_file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + $this->url = rtrim(plugin_dir_url($this->pluginFile), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; return $this; } /** + * getSlug method * Get the slug of the plugin. - * * @return string The slug. */ - public function getSlug() + public function getSlug(): string { return sanitize_title(dirname($this->basename)); } /** + * getVersion method * Get the version of the plugin. - * * @return string The version. */ - public function getVersion() + public function getVersion(): string { + if (defined('WP_DEBUG') && WP_DEBUG) { + return bin2hex(random_bytes(4)); + } return $this->version; } /** + * getVersion method * Set the version of the plugin. - * * @return object This Plugin object. */ - public function setVersion() + public function setVersion(): object { - $headers = array('Version' => 'Version'); - $file_data = get_file_data($this->plugin_file, $headers, 'plugin'); - if (isset($file_data['Version'])) { - $this->version = $file_data['Version']; + $headers = ['Version' => 'Version']; + $fileData = get_file_data($this->pluginFile, $headers, 'plugin'); + if (isset($fileData['Version'])) { + $this->version = $fileData['Version']; }; return $this; } /** + * __call method * Method overloading. */ public function __call(string $name, array $arguments) { if (!method_exists($this, $name)) { - $message = sprintf(__('Call to undefined method %1$s::%2$s', 'rrze-wp'), __CLASS__, $name); + $message = sprintf('Call to undefined method %1$s::%2$s', __CLASS__, $name); do_action( 'rrze.log.error', $message, - array( + [ 'class' => __CLASS__, 'method' => $name, 'arguments' => $arguments - ) + ] ); - if (WP_DEBUG) { + if (defined('WP_DEBUG') && WP_DEBUG) { throw new \Exception($message); } }