diff --git a/svn/trunk/ActionsFilters.php b/svn/trunk/ActionsFilters.php index 1519128..77773a2 100644 --- a/svn/trunk/ActionsFilters.php +++ b/svn/trunk/ActionsFilters.php @@ -4,8 +4,8 @@ namespace Slickstream; -require_once 'LifeCycle.php'; -require_once 'Plugin.php'; +require_once PLUGIN_DIR_PATH(__FILE__) . 'LifeCycle.php'; +require_once PLUGIN_DIR_PATH(__FILE__) . 'Plugin.php'; const GENESIS_AFTER_HEADER_POSTS = 'After header on posts (for Genesis themes)'; const GENESIS_BEFORE_CONTENT_POSTS = 'Before content on posts (for Genesis themes)'; @@ -45,7 +45,9 @@ public function getOptionMetaData(): array ]; if (function_exists('genesis')) { - $options = array_merge($options, [ + $options = array_merge( + $options, + [ 'InsertFilmstrip' => [ (string)__('Insert filmstrip', $domain), 'None', @@ -58,7 +60,8 @@ public function getOptionMetaData(): array GENESIS_AFTER_CONTENT, GENESIS_BEFORE_FOOTER, ], - ]); + ] + ); } return $options; @@ -105,7 +108,7 @@ public function upgrade(): void // Exclude slickstream scripts from JS delay in WP-Rocket /** - * @param array $excludedStrings + * @param array $excludedStrings * @return array */ public function addWpRocketExclusions(array $excludedStrings = []): array @@ -139,13 +142,15 @@ public function addActionsAndFilters(): void add_action('wp_head', [$plugin, 'addSlickPageHeader']); add_action('init', [$this, 'addTaxonomiesToPages']); - $this->addShortcodes([ + $this->addShortcodes( + [ 'slick-film-strip' => 'getFilmStripShortcode', 'slick-grid' => 'getSlickGridShortcode', 'slick-story' => 'getSlickStoryShortcode', 'slick-story-carousel' => 'getSlickStoryCarouselShortcode', 'slick-story-explorer' => 'getSlickStoryExplorerShortcode', - ]); + ] + ); $prefix = is_network_admin() ? 'network_admin_' : ''; $pluginFile = plugin_basename($this->getPluginDir() . DIRECTORY_SEPARATOR . $this->getMainPluginFileName()); diff --git a/svn/trunk/Init.php b/svn/trunk/Init.php index 9063d97..c3d10bc 100644 --- a/svn/trunk/Init.php +++ b/svn/trunk/Init.php @@ -2,12 +2,13 @@ declare(strict_types=1); +// Note: do not rename or this function or add a namespace to this file +// This is needed for compatibility with other plugins that check for this function function SlickEngagement_init(): void { - - require_once 'PluginInit.php'; - require_once 'ActionsFilters.php'; - $slickActionsFilters = new Slickstream\ActionsFilters(); + require_once PLUGIN_DIR_PATH(__FILE__) . 'PluginInit.php'; + require_once PLUGIN_DIR_PATH(__FILE__) . 'ActionsFilters.php'; + $slickActionsFilters = new \Slickstream\ActionsFilters(); // NOTE: this file gets run each time you *activate* the plugin. // So in WP when you "install" the plugin, all that does it dump its files in the plugin-templates directory @@ -17,7 +18,6 @@ function SlickEngagement_init(): void if (!$slickActionsFilters->isInstalled()) { $slickActionsFilters->install(); } else { - // Perform any version-upgrade activities prior to activation (e.g. database changes) $slickActionsFilters->upgrade(); } diff --git a/svn/trunk/InstallIndicator.php b/svn/trunk/InstallIndicator.php index a69d350..d8dcb77 100644 --- a/svn/trunk/InstallIndicator.php +++ b/svn/trunk/InstallIndicator.php @@ -4,7 +4,7 @@ namespace Slickstream; -require_once 'OptionsManager.php'; +require_once PLUGIN_DIR_PATH(__FILE__) . 'OptionsManager.php'; class InstallIndicator extends OptionsManager { @@ -26,6 +26,7 @@ public function isInstalled(): bool /** * Note in DB that the plugin is installed + * * @return null */ protected function markAsInstalled(): ?bool @@ -35,6 +36,7 @@ protected function markAsInstalled(): ?bool /** * Note in DB that the plugin is uninstalled + * * @return bool returned form delete_option. * true implies the plugin was installed at the time of this call, * false implies it was not. @@ -56,8 +58,9 @@ protected function getVersionSaved(): ?string /** * Set a version string in the options. - * @param $version string best practice: use a dot-delimited string like '1.2.3' so version strings can be easily - * compared using version_compare (http://php.net/manual/en/function.version-compare.php) + * + * @param $version string best practice: use a dot-delimited string like '1.2.3' so version strings can be easily + * compared using version_compare (http://php.net/manual/en/function.version-compare.php) */ protected function setVersionSaved(string $version): ?bool { @@ -70,13 +73,14 @@ protected function setVersionSaved(string $version): ?bool */ protected function getMainPluginFileName(): string { - return basename(dirname(__FILE__)) . 'php'; + return basename(__DIR__) . 'php'; } /** * Get a value for input key in the header section of main plugin file. * E.g. "Plugin Name", "Version", "Description", "Text Domain", etc. - * @param $key string plugin header key + * + * @param $key string plugin header key * @return string | null if found, otherwise null */ /** @@ -103,6 +107,7 @@ public function getPluginHeaderValue(string $key): ?string * If your subclass of this class lives in a different directory, * override this method with the exact same code. Since __FILE__ will * be different, you will then get the right dir returned. + * * @return string */ protected function getPluginDir(): string @@ -114,6 +119,7 @@ protected function getPluginDir(): string * Version of this code. * Best practice: define version strings to be easily compared using version_compare() * NOTE: You should manually make this match the SVN tag for your main plugin file 'Version' release and 'Stable tag' in readme.txt + * * @return string */ public function getVersion(): string @@ -127,6 +133,7 @@ public function getVersion(): string * Useful when checking for upgrades, can tell if the currently installed version is earlier than the * newly installed code. This case indicates that an upgrade has been installed and this is the first time it * has been activated, so any upgrade actions should be taken. + * * @return bool true if the version saved in the options is earlier than the version declared in getVersion(). * true indicates that new code is installed and this is the first time it is activated, so upgrade actions * should be taken. Assumes that version string comparable by version_compare, examples: '1', '1.1', '1.1.1', '2.0', etc. @@ -138,6 +145,7 @@ public function isInstalledCodeAnUpgrade(): bool /** * Used to see if the installed code is an earlier version than the input version + * * @param $aVersion string * @return bool true if the saved version is earlier (by natural order) than the input version */ @@ -152,6 +160,7 @@ public function isSavedVersionLessThan(string $aVersion): bool * but the last version (installed) was 2.3 (for example) you could check if * For example, $this->isSavedVersionLessThanEqual('2.3') == true indicates that the saved version is not upgraded * past 2.3 yet and therefore you would perform some appropriate upgrade action. + * * @param $aVersion string * @return bool true if the saved version is earlier (by natural order) than the input version */ @@ -184,6 +193,7 @@ public function isVersionLessThan(string $version1, string $version2): bool * Record the installed version to options. * This helps track was version is installed so when an upgrade is installed, it should call this when finished * upgrading to record the new current version + * * @return void */ protected function saveInstalledVersion(): void diff --git a/svn/trunk/LifeCycle.php b/svn/trunk/LifeCycle.php index 9f8b17a..15375b0 100644 --- a/svn/trunk/LifeCycle.php +++ b/svn/trunk/LifeCycle.php @@ -4,7 +4,7 @@ namespace Slickstream; -require_once 'InstallIndicator.php'; +require_once PLUGIN_DIR_PATH(__FILE__) . 'InstallIndicator.php'; class PluginLifecycle extends InstallIndicator { @@ -42,6 +42,7 @@ public function uninstall(): void /** * Perform any version-upgrade activities prior to activation (e.g. database changes) + * * @return void */ public function upgrade(): void @@ -78,6 +79,7 @@ public function addActionsAndFilters(): void * Best Practice: * (1) Prefix all table names with $wpdb->prefix * (2) make table names lower case only + * * @return void */ protected function installDatabaseTables(): void @@ -86,6 +88,7 @@ protected function installDatabaseTables(): void /** * Drop plugin-created tables on uninstall. + * * @return void */ protected function unInstallDatabaseTables(): void @@ -94,6 +97,7 @@ protected function unInstallDatabaseTables(): void /** * Override to add any additional actions to be done at install time + * * @return void */ protected function otherInstall(): void @@ -102,6 +106,7 @@ protected function otherInstall(): void /** * Override to add any additional actions to be done at uninstall time + * * @return void */ protected function otherUninstall(): void diff --git a/svn/trunk/PageBootData.php b/svn/trunk/PageBootData.php index cdc9723..3519ec5 100644 --- a/svn/trunk/PageBootData.php +++ b/svn/trunk/PageBootData.php @@ -4,7 +4,7 @@ namespace Slickstream; -require_once 'Utils.php'; +require_once PLUGIN_DIR_PATH(__FILE__) . 'Utils.php'; class PageBootData extends OptionsManager { @@ -37,7 +37,7 @@ public function __construct(string $serverUrlBase, string $siteCode, string $scr private function getPageBootDataForDevice(): object { if (isset($this->pageBootData->v2)) { - if ($this->utils->isMobile() && isset($this->pageBootData->v2->phone)) { + if ($this->utils->isPhone() && isset($this->pageBootData->v2->phone)) { return $this->pageBootData->v2->phone ?? $this->pageBootData; } return $this->pageBootData->v2->desktop ?? $this->pageBootData; @@ -67,8 +67,8 @@ private function echoClsContainerScript(): void // NOTE: The source of the minified JavaScript below is: slickstream-client/blob/main/src/plugin/cls-inject.ts // This script will insert the filmstrip, DCM, and email container elements into the page to eliminate CLS on those widgets. // TODO: This should be pulled in over HTTP and cached in Wordpress, not embedded directly like this. - echo "\n