. */ use WSAL\Helpers\WP_Helper; if ( ! defined( 'ABSPATH' ) ) { exit; } // Require Composer autoloader if it exists. if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) { require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; } if ( ! defined( 'WSAL_PREFIX' ) ) { define( 'WSAL_VERSION', '5.1.0' ); define( 'WSAL_PREFIX', 'wsal_' ); define( 'WSAL_PREFIX_PAGE', 'wsal-' ); } // Plugin file. if ( ! defined( 'WSAL_BASE_FILE_NAME' ) ) { define( 'WSAL_BASE_FILE_NAME', __FILE__ ); } // Plugin Name. if ( ! defined( 'WSAL_BASE_NAME' ) ) { define( 'WSAL_BASE_NAME', plugin_basename( __FILE__ ) ); } // Plugin Directory URL. if ( ! defined( 'WSAL_BASE_URL' ) ) { define( 'WSAL_BASE_URL', plugin_dir_url( __FILE__ ) ); } // Plugin Directory Path. if ( ! defined( 'WSAL_BASE_DIR' ) ) { define( 'WSAL_BASE_DIR', plugin_dir_path( __FILE__ ) ); } // Plugin Docs URL. if ( ! defined( 'WSAL_DOCS_URL' ) ) { define( 'WSAL_DOCS_URL', 'https://mellapress.com/support/' ); } // Plugin Issue Reporting URL. if ( ! defined( 'WSAL_ISSUE_URL' ) ) { define( 'WSAL_ISSUE_URL', 'https://wordpress.org/support/plugin/wp-security-audit-log' ); } // Plugin Classes Prefix. if ( ! defined( 'WSAL_CLASS_PREFIX' ) ) { define( 'WSAL_CLASS_PREFIX', 'WSAL_' ); } /** * Connections Prefix. */ if ( ! defined( 'WSAL_CONN_PREFIX' ) ) { define( 'WSAL_CONN_PREFIX', 'connection-' ); } if ( ! defined( 'WSAL_MIRROR_PREFIX' ) ) { define( 'WSAL_MIRROR_PREFIX', 'mirror-' ); } // phpcs:disable /* @free:start */ // phpcs:enable if ( ! function_exists( 'wsal_disable_freemius_on_free' ) ) { /** * Disables the freemius * * @return WSAL_Freemius * * @since 4.5.0 */ function wsal_disable_freemius_on_free() { require_once __DIR__ . '/nofs/lib/class-wsal-freemius.php'; return WSAL_Freemius::get_instance(); } } add_filter( 'wsal_freemius_sdk_object', 'wsal_disable_freemius_on_free' ); add_filter( 'wsal_disable_freemius_sdk', '__return_true' ); // phpcs:disable /* @free:end */ // phpcs:enable if ( ! function_exists( 'wsal_freemius' ) ) { // phpcs:disable // phpcs:enable $prefixed_autoloader_file_path = WSAL_BASE_DIR . implode( DIRECTORY_SEPARATOR, array( 'third-party', 'vendor', 'autoload.php', ) ); if ( file_exists( $prefixed_autoloader_file_path ) ) { require_once $prefixed_autoloader_file_path; // phpcs:disable // phpcs:enable } // Begin load sequence. WpSecurityAuditLog::get_instance(); if ( is_admin() && ! WP_Helper::is_plugin_active( WSAL_BASE_NAME ) ) { WpSecurityAuditLog::load_freemius(); if ( ! apply_filters( 'wsal_disable_freemius_sdk', false ) ) { wsal_freemius()->add_action( 'after_uninstall', array( '\WSAL\Helpers\Uninstall_Helper', 'uninstall' ) ); } } } elseif ( ! method_exists( 'WSAL_Freemius', 'set_basename' ) ) { global $wsal_freemius; $wsal_freemius = null; unset( $wsal_freemius ); } else { wsal_freemius()->set_basename( true, __FILE__ ); } // phpcs:disable /* @free:start */ // phpcs:enable if ( ! function_exists( 'wsal_free_on_plugin_activation' ) ) { /** * Takes care of deactivation of the premium plugin when the free plugin is activated. The opposite direction is handled * by Freemius SDK. * * Note: This code MUST NOT be present in the premium version an is removed automatically during the build process. * * @since 4.3.2 */ function wsal_free_on_plugin_activation() { $premium_version_slug = 'wp-security-audit-log-premium/wp-security-audit-log.php'; if ( WP_Helper::is_plugin_active( $premium_version_slug ) ) { deactivate_plugins( $premium_version_slug, true ); } $premium_version_slug = 'wp-security-audit-log-nofs/wp-security-audit-log.php'; if ( WP_Helper::is_plugin_active( $premium_version_slug ) ) { deactivate_plugins( $premium_version_slug, true ); } } register_activation_hook( __FILE__, 'wsal_free_on_plugin_activation' ); } // phpcs:disable /* @free:end */ // phpcs:enable if ( ! function_exists( 'str_ends_with' ) ) { /** * Substitute function if the PHP version is lower than PHP 8 * * @param string $haystack - The search in string. * @param string $needle - The search for string. * * @return boolean * * @since 5.0.0 */ function str_ends_with( string $haystack, string $needle ): bool { $needle_len = strlen( $needle ); return ( 0 === $needle_len || 0 === substr_compare( $haystack, $needle, - $needle_len ) ); } } if ( ! function_exists( 'str_starts_with' ) ) { /** * PHP lower than 8 is missing that function but it required in the newer versions of our plugin. * * @param string $haystack - The string to search in. * @param string $needle - The needle to search for. * * @return bool * * @since 5.0.0 */ function str_starts_with( $haystack, $needle ): bool { if ( '' === $needle ) { return true; } return 0 === strpos( $haystack, $needle ); } }