response ) { return true; } // Bail if we do not have any updates available. return false; } /** * Checks if the plugin run on the new SiteGround interface. * * @since 1.0.0 * * @return boolean True/False. */ public static function is_siteground() { // Bail if open_basedir restrictions are set, and we are not able to check certain directories. if ( ! empty( ini_get( 'open_basedir' ) ) ) { return 0; } return (int) ( @file_exists( '/etc/yum.repos.d/baseos.repo' ) || @file_exists( '/Z' ) ); } /** * Create a file. * * @since 1.1.0 * * @param string $path Full path to the file. * * @return bool True if the file exists or if it was successfully created, false otherwise. */ public static function create_file( $path ) { // Setup wp_filesystem. $wp_filesystem = self::setup_wp_filesystem(); // Bail if the file already exists. if ( $wp_filesystem->exists( $path ) ) { return true; } // Create the file. return $wp_filesystem->touch( $path ); } /** * Update a file. * * @param string $path Full path to the file. * @param string $content File content. * * @since 1.1.0 */ public static function update_file( $path, $content ) { // Setup wp_filesystem. $wp_filesystem = self::setup_wp_filesystem(); // Bail if we are unable to create the file. if ( false === self::create_file( $path ) ) { return; } // Add the new content into the file. $wp_filesystem->put_contents( $path, json_encode( $content ) ); } /** * Build config file content using the option values from database. * * @since 1.1.0 * * @param array $config_options Config options. * * @return array The config content. */ public static function build_config_content( $config_options ) { // Init the data array. $data = array(); // Loop through all options and add the value to the data array. foreach ( $config_options as $key => $option ) { // Get the option value. $value = get_option( $option, 0 ); // Add the value to database. Only the plugin version needs to be a string. $data[ $key ] = 'version' === $key ? $value : intval( $value ); } // Return the data. return $data; } /** * Returns the assets URL. * * @return string The URL to the uploads assets. */ public static function get_assets_url() { // Get the uploads data. $uploads = wp_upload_dir(); // Get the baseurl. $baseurl = rtrim( $uploads['baseurl'], '/' ); // Add the necessary protocol. if ( is_ssl() && 0 === strpos( $baseurl, 'http://' ) ) { return str_replace( 'http://', 'https://', $baseurl ); } return $baseurl; } }