HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux vmi1674223.contaboserver.net 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: root (0)
PHP: 7.4.3-4ubuntu2.22
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/onlineshop/wp-content/plugins/pinterest-for-woocommerce/src/PluginHelper.php
<?php
/**
 * Helper functions that are useful throughout the plugin.
 *
 * @package Automattic\WooCommerce\Pinterest
 */

declare( strict_types=1 );

namespace Automattic\WooCommerce\Pinterest;

/**
 * Trait PluginHelper
 */
trait PluginHelper {

	/**
	 * Get the plugin slug.
	 *
	 * @return string
	 */
	protected function get_slug(): string {
		return 'pinterest';
	}

	/**
	 * Get the prefix used for plugin's metadata keys in the database.
	 *
	 * @return string
	 */
	protected function get_meta_key_prefix(): string {
		return "_wc_{$this->get_slug()}";
	}

	/**
	 * Prefix a meta data key with the plugin prefix.
	 *
	 * @param string $key Meta key name.
	 *
	 * @return string
	 */
	protected function prefix_meta_key( string $key ): string {
		$prefix = $this->get_meta_key_prefix();

		return "{$prefix}_{$key}";
	}

	/**
	 * Check whether debugging mode is enabled.
	 *
	 * @return bool Whether debugging mode is enabled.
	 */
	protected function is_debug_mode(): bool {
		return defined( 'WP_DEBUG' ) && WP_DEBUG;
	}

	/**
	 * Helper method to return the onboarding page parameters.
	 *
	 * @return array The onboarding page parameters.
	 */
	protected function onboarding_page_parameters(): array {

		return array(
			'page' => 'wc-admin',
			'path' => '/pinterest/onboarding',
		);
	}

	/**
	 * Check wether if the current page is the Get Started page.
	 *
	 * @return bool Wether the current page is the Get Started page.
	 */
	protected function is_onboarding_page(): bool {

		$page_parameters = $this->onboarding_page_parameters();

		return count( $page_parameters ) === count( array_intersect_assoc( $_GET, $page_parameters ) ); // phpcs:disable WordPress.Security.NonceVerification.Recommended
	}

	/**
	 * Strip HTML tags from the given string.
	 * This is intended to be used with the description field on the feed and the Rich Pins.
	 *
	 * @since 1.2.3
	 *
	 * @param string $string           String with HTML tags.
	 * @param bool   $apply_shortcodes Whether to apply shortcodes or not.
	 *
	 * @return string
	 */
	protected static function strip_tags_from_string( $string, $apply_shortcodes = false ) {

		if ( $apply_shortcodes ) {
			// Apply active shortcodes.
			$string = do_shortcode( $string );
		} else {
			// Strip out active shortcodes.
			$string = strip_shortcodes( $string );
		}

		// Strip HTML tags from description.
		$string = wp_strip_all_tags( $string );

		// Strip [&hellip] character from description.
		$string = str_replace( '[&hellip;]', '...', $string );

		return $string;
	}
}