├── includes ├── class-aspirecloud-api.php ├── autoload.php ├── class-utilities.php ├── views │ ├── page-admin-settings.php │ └── voltron.txt ├── class-plugins-screens.php ├── class-api-rewrite.php ├── class-themes-screens.php ├── class-controller.php ├── class-branding.php ├── class-debug.php └── class-admin-settings.php ├── assets ├── images │ ├── icon-key.svg │ └── aspirepress-logo-icon.svg ├── playground │ └── blueprint.json ├── css │ └── aspire-update.css └── js │ └── aspire-update.js ├── vendor └── afragen │ ├── autoloader │ ├── CHANGES.md │ ├── composer.json │ ├── README.md │ ├── LICENSE │ └── Autoloader.php │ └── translations-updater │ ├── LICENSE │ ├── CHANGES.md │ ├── composer.json │ ├── src │ └── Translations_Updater │ │ ├── Init.php │ │ ├── Language_Pack.php │ │ ├── Base.php │ │ ├── Language_Pack_API.php │ │ └── API.php │ └── README.md ├── composer.json ├── readme.txt ├── aspire-update.php ├── languages └── aspireupdate.pot ├── README.md └── LICENSE.md /includes/class-aspirecloud-api.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vendor/afragen/autoloader/CHANGES.md: -------------------------------------------------------------------------------- 1 | #### 3.0.0 2 | * refactor as composer library, though likely better to just use composer's autoloader 3 | 4 | #### 2.0.0 5 | * use proper namespacing 6 | * show proper loading of TEC/ECP compatibility classes 7 | 8 | #### 1.1.1 9 | * change directory spacer to double underscore per PSR 4 10 | * change directory/file naming for PSR 4 11 | 12 | #### 1.1.0 13 | * redesign to load classes like PSR 0 and add `_` as directory spacer 14 | * rename TEC/ECP alias directory and files for PSR 0 style loading 15 | 16 | #### 1.0.0 17 | * initial commit 18 | -------------------------------------------------------------------------------- /includes/autoload.php: -------------------------------------------------------------------------------- 1 | =5.6" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/afragen/autoloader/README.md: -------------------------------------------------------------------------------- 1 | ## Autoloader 2 | 3 | This repository contains a generic class autoloader that will load classes from a PSR-4 namespace root directory and an alternate directory/location for vendor or classmap of classes necessary for your plugin. 4 | 5 | PRs welcome, especially for additional class aliases as you find needing them. Please refer to the readme in that folder for additional information on how to create these. 6 | 7 | This is an alternative to composer's autoload creator. 8 | 9 | ```php 10 | $root = [ 'My_Namespace' => 'path/to/my-namespace' ]; 11 | $classmap = [ 12 | 'Extra_Class' => 'path/to/extra-class.php', 13 | 'AnotherClass' => 'path/to/class-another.php', 14 | ]; 15 | 16 | require_once 'Autoloader.php'; 17 | new \Fragen\Autoloader( $root, $classmap ); 18 | ``` 19 | 20 | ## Changelog 21 | [CHANGES.md](CHANGES.md) 22 | 23 | ## Credits 24 | Built by [Andy Fragen](https://thefragens.com/) 25 | -------------------------------------------------------------------------------- /vendor/afragen/autoloader/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Andy Fragen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /includes/class-utilities.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aspirepress/aspire-update", 3 | "description": "Update plugins and themes for WordPress.", 4 | "type": "wordpress-plugin", 5 | "license": "GPLv2", 6 | "authors": [ 7 | { 8 | "name": "AspirePress" 9 | } 10 | ], 11 | "require": { 12 | "php": ">=7.4.0", 13 | "afragen/autoloader": "dev-master", 14 | "afragen/translations-updater": "^1" 15 | }, 16 | "require-dev": { 17 | "squizlabs/php_codesniffer": "3.10.3", 18 | "wp-coding-standards/wpcs": "~3.1.0", 19 | "yoast/phpunit-polyfills": "^1.1.0" 20 | }, 21 | "config": { 22 | "allow-plugins": { 23 | "dealerdirect/phpcodesniffer-composer-installer": true 24 | } 25 | }, 26 | "scripts": { 27 | "format": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source", 28 | "lint": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source", 29 | "test": [ 30 | "Composer\\Config::disableProcessTimeout", 31 | "@php ./vendor/phpunit/phpunit/phpunit" 32 | ], 33 | "test:multisite": [ 34 | "Composer\\Config::disableProcessTimeout", 35 | "@php ./vendor/phpunit/phpunit/phpunit -c tests/multisite.xml" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /includes/views/page-admin-settings.php: -------------------------------------------------------------------------------- 1 | 7 |
8 |

9 |
10 | 14 |

15 | 16 | 17 | 18 | 19 | 20 |

21 |
22 |
23 |
24 | 25 |
26 |
27 |
28 |
29 | 30 |
31 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/CHANGES.md: -------------------------------------------------------------------------------- 1 | #### [unreleased] 2 | 3 | #### 1.2.0 / 2024-11-19 4 | * return `WP_Error` in `Language_Pack_API::get_language_pack()` with validation error 5 | * exit gracefully if `Language_Pack_API::get_language_pack()` returns `WP_Error` 6 | * updated error logging for GitHub API rate limits 7 | 8 | #### 1.1.0 / 2024-11-16 9 | * add API error caching/logging 10 | * always return `$this->repo` in `Language_Pack_API::get_language_pack()` 11 | 12 | #### 1.0.1 / 2024-11-12 13 | * fixed a hard-coded 'master' branch in `Language_Pack_API::process_language_pack_package()` 14 | 15 | #### 1.0.0 / 2024-11-12 16 | * added WPCS-style linting 17 | * return empty array in `API::get_repo_data()` as appropriate 18 | * lowercase slugs for GlotPress compatibility 19 | * more checks to correctly update appropriate transient 20 | * update to select repository branch 21 | * make work with self-hosted installs of git hosts 22 | * update `Init::can_update()` for parity with GitHub Updater 23 | * update for possible universal EDD SL Updater plugin 24 | * switch to `site_transient_update_{plugins|themes}` filter 25 | * convert to composer dependency from [EDD Translations Updater](https://github.com/afragen/edd-translations-updater) and make more generic for any WordPress plugin or theme 26 | * support EDD Software Licensing `post_edd_sl_{plugin|theme}_updater_setup` action hooks 27 | * update for Bitbucket API 2.0 28 | * initial commit 29 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "afragen/translations-updater", 3 | "description": "This framework provides automatic decoupled languate pack updates from a public repository for your WordPress plugin or theme.", 4 | "type": "library", 5 | "license": "MIT", 6 | "version": "1.2.0", 7 | "keywords": [ 8 | "wordpress", 9 | "plugin", 10 | "theme", 11 | "updater", 12 | "language pack", 13 | "translations" 14 | ], 15 | "authors": [ 16 | { 17 | "name": "Andy Fragen", 18 | "email": "andy@thefragens.com", 19 | "homepage": "https://thefragens.com", 20 | "role": "Developer" 21 | } 22 | ], 23 | "support": { 24 | "issues": "https://github.com/afragen/translations-updater/issues", 25 | "source": "https://github.com/afragen/translations-updater" 26 | }, 27 | "repositories": [ 28 | { 29 | "type": "vcs", 30 | "url": "https://github.com/afragen/translations-updater" 31 | } 32 | ], 33 | "prefer-stable": true, 34 | "require": { 35 | "php": ">=5.4" 36 | }, 37 | "require-dev": { 38 | "wp-coding-standards/wpcs": "^3.0.0" 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "Fragen\\Translations_Updater\\": "src/Translations_Updater/" 43 | } 44 | }, 45 | "config": { 46 | "allow-plugins": { 47 | "dealerdirect/phpcodesniffer-composer-installer": true 48 | } 49 | }, 50 | "scripts": { 51 | "wpcs": [ 52 | "vendor/bin/phpcbf .; vendor/bin/phpcs ." 53 | ] 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /includes/class-plugins-screens.php: -------------------------------------------------------------------------------- 1 | get_setting( 'enable', false ) ) { 37 | add_filter( 'install_plugins_tabs', [ $this, 'remove_unused_filter_tabs' ] ); 38 | } 39 | } 40 | 41 | /** 42 | * Initialize Class. 43 | * 44 | * @return object 45 | */ 46 | public static function get_instance() { 47 | if ( null === self::$instance ) { 48 | self::$instance = new self(); 49 | } 50 | return self::$instance; 51 | } 52 | 53 | /** 54 | * Remove unused filter tabs from the Add New Plugin screen. 55 | * 56 | * @param array $tabs An array of tab labels, keyed on each tab's slug. 57 | * @return array An array of tabs. 58 | */ 59 | public function remove_unused_filter_tabs( $tabs ) { 60 | foreach ( $this->unsupported_filters as $filter ) { 61 | unset( $tabs[ $filter ] ); 62 | } 63 | return $tabs; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /assets/playground/blueprint.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://playground.wordpress.net/blueprint-schema.json", 3 | "preferredVersions": { 4 | "php": "latest", 5 | "wp": "latest" 6 | }, 7 | "meta": { 8 | "title": "AspirePress AspireUpdate Plugin Demo", 9 | "description": "Load table AspireUpdate plugin into a WordPress Playground site", 10 | "author": "asirota", 11 | "categories": [ 12 | "demo", 13 | "plugin" 14 | ] 15 | }, 16 | "siteOptions": { 17 | "blogname": "AspireUpdate Demo Site" 18 | }, 19 | "plugins": [ 20 | "https://github-proxy.com/proxy/?repo=AspirePress/AspireUpdate&branch=main", 21 | "error-log-viewer", 22 | "plugin-check" 23 | ], 24 | "features": { 25 | "networking": true 26 | }, 27 | "login": true, 28 | "landingPage": "/wp-admin/admin.php?page=aspireupdate-settings", 29 | "steps": [ 30 | { 31 | "step": "defineWpConfigConsts", 32 | "consts": { 33 | "WP_DISABLE_FATAL_ERROR_HANDLER": false, 34 | "WP_DEBUG": false, 35 | "WP_DEBUG_LOG": false, 36 | "WP_DEBUG_DISPLAY": true 37 | } 38 | }, 39 | { 40 | "step": "writeFile", 41 | "path": "/wordpress/wp-content/mu-plugins/rewrite.php", 42 | "data": "set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules(); } );" 43 | }, 44 | { 45 | "step": "installTheme", 46 | "themeData": { 47 | "resource": "wordpress.org/themes", 48 | "slug": "twentytwentytwo" 49 | } 50 | }, 51 | { 52 | "step": "writeFile", 53 | "path": "/wordpress/wp-content/mu-plugins/bgnightly-notice.php", 54 | "data": "

Welcome to AspireUpdate Demo. Visit AspirePress documentation for more details.

'; });" 55 | }, 56 | { 57 | "step": "rm", 58 | "path": "/wordpress/wp-content/plugins/hello.php" 59 | } 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === AspireUpdate === 2 | Contributors: sarah-savage, namithj, asirota 3 | Donate link: https://github.com/sponsors/aspirepress 4 | Requires at least: 5.3 5 | Tested up to: 6.7 6 | Stable tag: 0.6 7 | Requires PHP: 7.4 8 | License: GPLv2 9 | License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | This plugin allows a WordPress user to automatically rewrite certain URLs and URL paths to a new URL. 12 | 13 | == Description == 14 | 15 | This plugin allows a WordPress user to automatically rewrite certain URLs and URL paths to a new URL. This is helpful because it allows for the rewriting of api.wordpress.org to some other repository that contains the plugins the user wants. 16 | 17 | The plugin supports multiple rewrites, and also supports rewriting the URL paths of the requests on a per-host basis. This improves the capacity of the plugin to adequately support newer or different repositories. 18 | 19 | == Frequently Asked Questions == 20 | 21 | = A question that someone might have = 22 | 23 | An answer to that question. 24 | 25 | = What about foo bar? = 26 | 27 | Answer to foo bar dilemma. 28 | 29 | == Screenshots == 30 | 31 | 1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Screenshots are stored in the /assets directory. 32 | 2. This is the second screen shot 33 | 34 | == Changelog == 35 | 36 | = 0.6 = 37 | * Admin Settings: Added notices for when settings are saved or reset 38 | * Branding: Added branded notices to inform users when AspireUpdate is in operation on a screen 39 | * Multisite: Added multisite support 40 | * Debug: Added Clear Logs and View Logs functionality 41 | * I18N: Added Catalan translation 42 | * I18N: Added Dutch translation 43 | * I18N: Added Spanish translation 44 | * I18N: Added Swedish translation 45 | * I18N: Updated Dutch translation 46 | * I18N: Updated French translation 47 | * I18N: Updated German translation 48 | * Testing: Added Git Updater integration 49 | * Testing: Added support both main and playground-ready links in the README 50 | * Testing: Made Playground default to the `main` branch 51 | * Testing: Removed Hello Dolly from the Playground blueprint 52 | * Security: Fixed Plugin Check security warnings 53 | 54 | = 0.5 = 55 | * first stable version, connects to api.wordpress.org or an alternative AspireCloud repository 56 | 57 | == Upgrade Notice == 58 | -------------------------------------------------------------------------------- /aspire-update.php: -------------------------------------------------------------------------------- 1 | delete_all_settings(); 60 | } 61 | 62 | // Load and start translations updater. 63 | add_action( 'init', 'aspireupdate_init_translations' ); 64 | function aspireupdate_init_translations() { 65 | require_once __DIR__ . '/vendor/afragen/autoloader/Autoloader.php'; 66 | new Fragen\Autoloader( [ 'Fragen\\Translations_Updater' => __DIR__ . '/vendor/afragen/translations-updater/src/Translations_Updater' ] ); 67 | $config = [ 68 | 'git' => 'github', 69 | 'type' => 'plugin', 70 | 'slug' => 'aspireupdate', 71 | 'version' => AP_VERSION, // Current version of plugin|theme. 72 | 'languages' => 'https://github.com/aspirepress/aspireupdate-translations', 73 | 'branch' => 'main', 74 | ]; 75 | 76 | ( new \Fragen\Translations_Updater\Init() )->run( $config ); 77 | } 78 | -------------------------------------------------------------------------------- /includes/class-api-rewrite.php: -------------------------------------------------------------------------------- 1 | redirected_host = $this->default_host; 44 | } else { 45 | $this->redirected_host = strtolower( $redirected_host ); 46 | } 47 | $this->disable_ssl = $disable_ssl; 48 | add_filter( 'pre_http_request', [ $this, 'pre_http_request' ], 10, 3 ); 49 | } 50 | 51 | /** 52 | * Rewrite the API End points. 53 | * 54 | * @param mixed $response The response for the request. 55 | * @param array $parsed_args The arguments for the request. 56 | * @param string $url The URL for the request. 57 | * 58 | * @return mixed The response or false. 59 | */ 60 | public function pre_http_request( $response, $parsed_args, $url ) { 61 | if ( 62 | isset( $this->default_host ) && 63 | ( '' !== $this->default_host ) && 64 | isset( $this->redirected_host ) && 65 | ( '' !== $this->redirected_host ) 66 | ) { 67 | if ( false !== strpos( $url, $this->default_host ) ) { 68 | Debug::log_string( 'Default API Found: ' . $url ); 69 | Debug::log_request( $parsed_args ); 70 | 71 | if ( $this->default_host !== $this->redirected_host ) { 72 | if ( $this->disable_ssl ) { 73 | Debug::log_string( 'SSL Verification Disabled' ); 74 | $parsed_args['sslverify'] = false; 75 | } 76 | 77 | $updated_url = str_replace( $this->default_host, $this->redirected_host, $url ); 78 | Debug::log_string( 'API Rerouted to: ' . $updated_url ); 79 | 80 | /** 81 | * Temporarily Unhook Filter to prevent recursion. 82 | */ 83 | remove_filter( 'pre_http_request', [ $this, 'pre_http_request' ] ); 84 | $response = wp_remote_request( $updated_url, $parsed_args ); 85 | add_filter( 'pre_http_request', [ $this, 'pre_http_request' ], 10, 3 ); 86 | 87 | Debug::log_response( $response ); 88 | 89 | return $response; 90 | 91 | } 92 | } 93 | } 94 | return $response; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /includes/class-themes-screens.php: -------------------------------------------------------------------------------- 1 | get_setting( 'enable', false ) ) { 36 | add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); 37 | add_action( 'load-theme-install.php', [ $this, 'redirect_to_theme_install' ] ); 38 | } 39 | } 40 | 41 | /** 42 | * Initialize Class. 43 | * 44 | * @return object 45 | */ 46 | public static function get_instance() { 47 | if ( null === self::$instance ) { 48 | self::$instance = new self(); 49 | } 50 | return self::$instance; 51 | } 52 | 53 | /** 54 | * Enqueue the styles. 55 | * 56 | * @param string $hook The page identifier. 57 | * @return void 58 | */ 59 | public function admin_enqueue_scripts( $hook ) { 60 | if ( 'theme-install.php' !== $hook ) { 61 | return; 62 | } 63 | 64 | if ( ! empty( $this->unsupported_filters ) ) { 65 | wp_register_style( 66 | 'aspire_update_themes_screens_css', 67 | false, 68 | [], 69 | AP_VERSION 70 | ); 71 | 72 | wp_enqueue_style( 'aspire_update_themes_screens_css' ); 73 | 74 | $css_selectors = []; 75 | foreach ( $this->unsupported_filters as $filter ) { 76 | $css_selectors[] = '.wp-filter .filter-links a[data-sort="' . $filter . '"]'; 77 | } 78 | 79 | wp_add_inline_style( 80 | 'aspire_update_themes_screens_css', 81 | implode( ', ', $css_selectors ) . '{ display: none; }' 82 | ); 83 | } 84 | } 85 | 86 | /** 87 | * Redirect unsupported filters to theme-install.php. 88 | * 89 | * @param string $hook The page identifier. 90 | * @return void 91 | */ 92 | public function redirect_to_theme_install() { 93 | 94 | $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : false; 95 | if ( ! $nonce || ! wp_verify_nonce( $nonce, 'query-themes' ) ) { 96 | return; 97 | } 98 | 99 | $browse = isset( $_GET['browse'] ) ? sanitize_text_field( wp_unslash( $_GET['browse'] ) ) : ''; 100 | 101 | if ( ! in_array( $browse, $this->unsupported_filters, true ) ) { 102 | return; 103 | } 104 | 105 | $admin_settings = Admin_Settings::get_instance(); 106 | if ( $admin_settings->get_setting( 'enable', false ) ) { 107 | wp_safe_redirect( admin_url( 'theme-install.php' ) ); 108 | ! defined( 'AP_RUN_TESTS' ) && exit; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /includes/class-controller.php: -------------------------------------------------------------------------------- 1 | api_rewrite(); 23 | add_action( 'wp_ajax_aspireupdate_clear_log', [ $this, 'clear_log' ] ); 24 | add_action( 'wp_ajax_aspireupdate_read_log', [ $this, 'read_log' ] ); 25 | } 26 | 27 | /** 28 | * Enable API Rewrites based on the Users settings. 29 | * 30 | * @codeCoverageIgnore Side-effects are from other methods already covered by tests. 31 | * 32 | * @return void 33 | */ 34 | private function api_rewrite() { 35 | $admin_settings = Admin_Settings::get_instance(); 36 | 37 | if ( $admin_settings->get_setting( 'enable', false ) ) { 38 | $api_host = $admin_settings->get_setting( 'api_host', '' ); 39 | } else { 40 | $api_host = 'debug'; 41 | } 42 | 43 | if ( isset( $api_host ) && ( '' !== $api_host ) ) { 44 | $enable_debug = $admin_settings->get_setting( 'enable_debug', false ); 45 | $disable_ssl = $admin_settings->get_setting( 'disable_ssl_verification', false ); 46 | if ( $enable_debug && $disable_ssl ) { 47 | new API_Rewrite( $api_host, true ); 48 | } else { 49 | new API_Rewrite( $api_host, false ); 50 | } 51 | } 52 | } 53 | 54 | /** 55 | * Ajax action to clear the Log file. 56 | * 57 | * @codeCoverageIgnore Cannot be tested. Results in script termination. 58 | * 59 | * @return void 60 | */ 61 | public function clear_log() { 62 | if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'aspireupdate-ajax' ) ) { 63 | wp_send_json_error( 64 | [ 65 | 'message' => __( 'Error: You are not authorized to access this resource.', 'aspireupdate' ), 66 | ] 67 | ); 68 | } 69 | 70 | $status = Debug::clear(); 71 | if ( is_wp_error( $status ) ) { 72 | wp_send_json_error( 73 | [ 74 | 'message' => $status->get_error_message(), 75 | ] 76 | ); 77 | } 78 | 79 | wp_send_json_success( 80 | [ 81 | 'message' => __( 'Log file cleared successfully.', 'aspireupdate' ), 82 | ] 83 | ); 84 | } 85 | 86 | /** 87 | * Ajax action to read the Log file. 88 | * 89 | * @codeCoverageIgnore Cannot be tested. Results in script termination. 90 | * 91 | * @return void 92 | */ 93 | public function read_log() { 94 | if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'aspireupdate-ajax' ) ) { 95 | wp_send_json_error( 96 | [ 97 | 'message' => __( 'Error: You are not authorized to access this resource.', 'aspireupdate' ), 98 | ] 99 | ); 100 | } 101 | 102 | $content = Debug::read( 1000 ); 103 | if ( is_wp_error( $content ) ) { 104 | wp_send_json_error( 105 | [ 106 | 'message' => $content->get_error_message(), 107 | ] 108 | ); 109 | } 110 | 111 | wp_send_json_success( 112 | [ 113 | 'content' => $content, 114 | ] 115 | ); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/src/Translations_Updater/Init.php: -------------------------------------------------------------------------------- 1 | caller = $caller; 42 | } 43 | 44 | /** 45 | * Test for proper user capabilities. 46 | * 47 | * @return bool 48 | */ 49 | private function can_update() { 50 | // WP-CLI access has full capabilities. 51 | if ( defined( 'WP_CLI' ) && \WP_CLI ) { 52 | return true; 53 | } 54 | 55 | $can_user_update = current_user_can( 'update_plugins' ) && current_user_can( 'update_themes' ); 56 | 57 | return $can_user_update; 58 | } 59 | 60 | /** 61 | * Start the processing. 62 | * 63 | * @param mixed $config [ 'git' => '{github|bitbucket|gitlab|gitea}', 64 | * 'type' => '{plugin|theme}', 65 | * 'slug' => 'my-repo-slug', 66 | * 'version => '1.0', 67 | * 'languages' => 'https://github.com//my-translations', 68 | * ]. 69 | * @return void|bool 70 | */ 71 | public function run( $config ) { 72 | if ( ! isset( $config['git'], $config['type'], $config['slug'], $config['version'], $config['languages'] ) ) { 73 | return false; 74 | } 75 | $config['branch'] = isset( $config['branch'] ) ? $config['branch'] : 'master'; 76 | if ( $this->can_update() ) { 77 | $config = $this->sanitize( $config ); 78 | $this->get_remote_repo_data( $config ); 79 | } 80 | } 81 | 82 | /** 83 | * Load relevant action hooks for EDD Software Licensing. 84 | */ 85 | public function edd_run() { 86 | add_action( 'post_edd_sl_plugin_updater_setup', [ $this, 'parse_edd_config' ], 15, 1 ); 87 | add_action( 'post_edd_sl_theme_updater_setup', [ $this, 'parse_edd_config' ], 15, 1 ); 88 | } 89 | 90 | /** 91 | * Parse passed config from EDD SL. 92 | * 93 | * @param array $config EDD SL config array. 94 | * 95 | * @return void 96 | */ 97 | public function parse_edd_config( $config ) { 98 | $edd_sl_updater = 'EDD\Software_Licensing\Updater'; 99 | if ( $edd_sl_updater !== $this->caller ) { 100 | if ( 'post_edd_sl_plugin_updater_setup' === current_filter() ) { 101 | $slug = array_keys( $config )[0]; 102 | $config = array_values( $config )[0]; 103 | $config['type'] = 'plugin'; 104 | $config['slug'] = $slug; 105 | } 106 | if ( 'post_edd_sl_theme_updater_setup' === current_filter() ) { 107 | $config['type'] = 'theme'; 108 | $config['slug'] = $config['theme_slug']; 109 | } 110 | } 111 | $this->run( $config ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/src/Translations_Updater/Language_Pack.php: -------------------------------------------------------------------------------- 1 | languages ) { 50 | return; 51 | } 52 | 53 | $this->repo = $config; 54 | $this->repo_api = $api; 55 | } 56 | 57 | /** 58 | * Do the Language Pack integration. 59 | */ 60 | public function run() { 61 | $headers = $this->parse_header_uri( $this->repo->languages ); 62 | $repo = $this->repo_api->get_language_pack( $headers ); 63 | if ( is_wp_error( $repo ) ) { 64 | return; 65 | } 66 | $this->config[ $repo->slug ] = $repo; 67 | 68 | add_filter( 'site_transient_update_plugins', [ $this, 'update_site_transient' ] ); 69 | add_filter( 'site_transient_update_themes', [ $this, 'update_site_transient' ] ); 70 | } 71 | 72 | /** 73 | * Add language translations to update_plugins or update_themes transients. 74 | * 75 | * @param \stdClass $transient Update transient. 76 | * 77 | * @return mixed 78 | */ 79 | public function update_site_transient( $transient ) { 80 | $locales = get_available_languages(); 81 | $locales = ! empty( $locales ) ? $locales : [ get_locale() ]; 82 | $repos = []; 83 | 84 | if ( ! isset( $transient->translations ) ) { 85 | return $transient; 86 | } 87 | 88 | if ( 'site_transient_update_plugins' === current_filter() ) { 89 | $translations = wp_get_installed_translations( 'plugins' ); 90 | } 91 | if ( 'site_transient_update_themes' === current_filter() ) { 92 | $translations = wp_get_installed_translations( 'themes' ); 93 | } 94 | 95 | $repos = array_filter( 96 | (array) $this->config, 97 | function ( $e ) { 98 | return isset( $e->language_packs ); 99 | } 100 | ); 101 | 102 | foreach ( $repos as $repo ) { 103 | if ( ! str_contains( current_filter(), $repo->type ) ) { 104 | continue; 105 | } 106 | foreach ( $locales as $locale ) { 107 | $lang_pack_mod = isset( $repo->language_packs->$locale ) 108 | ? strtotime( $repo->language_packs->$locale->updated ) 109 | : 0; 110 | $translation_mod = isset( $translations[ $repo->slug ][ $locale ] ) 111 | ? strtotime( $translations[ $repo->slug ][ $locale ]['PO-Revision-Date'] ) 112 | : 0; 113 | if ( $lang_pack_mod > $translation_mod ) { 114 | $transient->translations[] = (array) $repo->language_packs->$locale; 115 | } 116 | } 117 | } 118 | 119 | $transient->translations = array_unique( $transient->translations, SORT_REGULAR ); 120 | 121 | return $transient; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/src/Translations_Updater/Base.php: -------------------------------------------------------------------------------- 1 | languages ) ) { 47 | return false; 48 | } 49 | 50 | $this->config[ $config->slug ] = $config; 51 | $language_pack = new Language_Pack( $config, new Language_Pack_API( $config ) ); 52 | $language_pack->run(); 53 | 54 | return true; 55 | } 56 | 57 | /** 58 | * Parse URI param returning array of parts. 59 | * 60 | * @param string $repo_header Repository URI. 61 | * 62 | * @return array $header 63 | */ 64 | final protected function parse_header_uri( $repo_header ) { 65 | $header_parts = parse_url( $repo_header ); 66 | $header_path = pathinfo( $header_parts['path'] ); 67 | $header['original'] = $repo_header; 68 | $header['scheme'] = isset( $header_parts['scheme'] ) ? $header_parts['scheme'] : null; 69 | $header['host'] = isset( $header_parts['host'] ) ? $header_parts['host'] : null; 70 | $header['type'] = explode( '.', $header['host'] )[0] . '_' . $this->repo->type; 71 | $header['owner'] = trim( $header_path['dirname'], '/' ); 72 | $header['repo'] = $header_path['filename']; 73 | $header['owner_repo'] = implode( '/', [ $header['owner'], $header['repo'] ] ); 74 | $header['base_uri'] = str_replace( $header_parts['path'], '', $repo_header ); 75 | $header['uri'] = isset( $header['scheme'] ) ? trim( $repo_header, '/' ) : null; 76 | 77 | $header = $this->sanitize( $header ); 78 | 79 | return $header; 80 | } 81 | 82 | /** 83 | * Sanitize each setting field as needed. 84 | * 85 | * @param array $input Contains all settings fields as array keys. 86 | * 87 | * @return array 88 | */ 89 | final public function sanitize( $input ) { 90 | $new_input = []; 91 | foreach ( array_keys( (array) $input ) as $id ) { 92 | $new_input[ sanitize_file_name( $id ) ] = sanitize_text_field( $input[ $id ] ); 93 | } 94 | 95 | return $new_input; 96 | } 97 | 98 | /** 99 | * Delete options from database. 100 | * 101 | * @return void 102 | */ 103 | final public function delete_cached_data() { 104 | global $wpdb; 105 | 106 | $table = is_multisite() ? $wpdb->base_prefix . 'sitemeta' : $wpdb->base_prefix . 'options'; 107 | $column = is_multisite() ? 'meta_key' : 'option_name'; 108 | // phpcs:disable WordPress.DB 109 | $delete_string = 'DELETE FROM ' . $table . ' WHERE ' . $column . ' LIKE %s LIMIT 1000'; 110 | 111 | $wpdb->query( $wpdb->prepare( $delete_string, [ '%tu-%' ] ) ); 112 | // phpcs:enable 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /vendor/afragen/autoloader/Autoloader.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT 7 | * @link http://github.com/afragen/autoloader 8 | * @copyright 2015 Andy Fragen 9 | * @package autoloader 10 | */ 11 | 12 | namespace Fragen; 13 | 14 | /* 15 | * Exit if called directly. 16 | */ 17 | if ( ! defined( 'WPINC' ) ) { 18 | die; 19 | } 20 | 21 | if ( ! class_exists( 'Fragen\\Autoloader' ) ) { 22 | /** 23 | * Class Autoloader 24 | * 25 | * To use with different plugins be sure to create a new namespace. 26 | * 27 | * @author Andy Fragen 28 | * @author Barry Hughes 29 | * @link http://github.com/afragen/autoloader 30 | * @copyright 2015-2018 Andy Fragen 31 | * @version 3.0.0 32 | */ 33 | class Autoloader { 34 | /** 35 | * Roots to scan when autoloading. 36 | * 37 | * @var array 38 | */ 39 | protected $roots = array(); 40 | 41 | /** 42 | * List of class names and locations in filesystem, for situations 43 | * where they deviate from convention etc. 44 | * 45 | * @var array 46 | */ 47 | protected $map = array(); 48 | 49 | /** 50 | * Constructor. 51 | * 52 | * @access public 53 | * 54 | * @param array $roots Roots to scan when autoloading. 55 | * @param array|null $static_map Array of classes that deviate from convention. 56 | * Defaults to null. 57 | */ 58 | public function __construct( array $roots, array $static_map = null ) { 59 | $this->roots = $roots; 60 | if ( null !== $static_map ) { 61 | $this->map = $static_map; 62 | } 63 | spl_autoload_register( array( $this, 'autoload' ) ); 64 | } 65 | 66 | /** 67 | * Load classes. 68 | * 69 | * @access protected 70 | * 71 | * @param string $class The class name to autoload. 72 | * 73 | * @return void 74 | */ 75 | protected function autoload( $class ) { 76 | // Check for a static mapping first of all. 77 | if ( isset( $this->map[ $class ] ) && file_exists( $this->map[ $class ] ) ) { 78 | include_once $this->map[ $class ]; 79 | 80 | return; 81 | } 82 | 83 | // Else scan the namespace roots. 84 | foreach ( $this->roots as $namespace => $root_dir ) { 85 | // If the class doesn't belong to this namespace, move on to the next root. 86 | if ( 0 !== strpos( $class, $namespace ) ) { 87 | continue; 88 | } 89 | 90 | $psr4_fname = substr( $class, strlen( $namespace ) + 1 ); 91 | $psr4_fname = str_replace( '\\', DIRECTORY_SEPARATOR, $psr4_fname ); 92 | 93 | // Determine the possible path to the class, include all subdirectories. 94 | $objects = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $root_dir ), \RecursiveIteratorIterator::SELF_FIRST ); 95 | foreach ( $objects as $name => $object ) { 96 | if ( is_dir( $name ) ) { 97 | $directories[] = rtrim( $name, './' ); 98 | } 99 | } 100 | $directories = array_unique( $directories ); 101 | 102 | $paths = $this->get_paths( $directories, array( $psr4_fname ) ); 103 | 104 | // Test for its existence and load if present. 105 | foreach ( $paths as $path ) { 106 | if ( file_exists( $path ) ) { 107 | include_once $path; 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | 114 | /** 115 | * Get and return an array of possible file paths. 116 | * 117 | * @param array $dirs Array of plugin directories and subdirectories. 118 | * @param array $file_names Array of possible file names. 119 | * 120 | * @return mixed 121 | */ 122 | private function get_paths( $dirs, $file_names ) { 123 | foreach ( $file_names as $file_name ) { 124 | $paths[] = array_map( 125 | function ( $dir ) use ( $file_name ) { 126 | return $dir . DIRECTORY_SEPARATOR . $file_name . '.php'; 127 | }, 128 | $dirs 129 | ); 130 | } 131 | 132 | return call_user_func_array( 'array_merge', $paths ); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /includes/class-branding.php: -------------------------------------------------------------------------------- 1 | get_setting( 'enable', false ) ) { 27 | $admin_notices_hook = is_multisite() ? 'network_admin_notices' : 'admin_notices'; 28 | add_action( $admin_notices_hook, [ $this, 'output_admin_notice' ] ); 29 | add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); 30 | } 31 | } 32 | 33 | /** 34 | * Initialize Class. 35 | * 36 | * @return object 37 | */ 38 | public static function get_instance() { 39 | if ( null === self::$instance ) { 40 | self::$instance = new self(); 41 | } 42 | return self::$instance; 43 | } 44 | 45 | /** 46 | * Enqueue scripts and styles. 47 | * 48 | * @param string $hook The page identifier. 49 | * @return void 50 | */ 51 | public function admin_enqueue_scripts( $hook ) { 52 | if ( defined( 'AP_REMOVE_UI' ) && AP_REMOVE_UI ) { 53 | return; 54 | } 55 | 56 | $allowed_screens = [ 57 | 'update-core', 58 | 'plugins', 59 | 'plugin-install', 60 | 'themes', 61 | 'theme-install', 62 | ]; 63 | 64 | $screen = \WP_Screen::get( $hook ); 65 | if ( in_array( $screen->id, $allowed_screens, true ) ) { 66 | wp_enqueue_style( 'aspire_update_settings_css', plugin_dir_url( __DIR__ ) . 'assets/css/aspire-update.css', [], AP_VERSION ); 67 | } 68 | } 69 | 70 | /** 71 | * Output admin notice. 72 | * 73 | * @return void 74 | */ 75 | public function output_admin_notice() { 76 | if ( defined( 'AP_REMOVE_UI' ) && AP_REMOVE_UI ) { 77 | return; 78 | } 79 | 80 | $current_screen = get_current_screen(); 81 | if ( ! $current_screen instanceof \WP_Screen ) { 82 | return; 83 | } 84 | 85 | $message = ''; 86 | switch ( $current_screen->id ) { 87 | case 'plugins': 88 | case 'plugin-install': 89 | if ( is_multisite() ) { 90 | break; 91 | } 92 | // Fall-through. 93 | case 'plugins-network': 94 | case 'plugin-install-network': 95 | $message = sprintf( 96 | /* translators: 1: The name of the plugin, 2: The documentation URL. */ 97 | __( 'Your plugin updates are now powered by %1$s. Learn more', 'aspireupdate' ), 98 | 'AspireUpdate', 99 | __( 'https://docs.aspirepress.org/aspireupdate/', 'aspireupdate' ) 100 | ); 101 | break; 102 | case 'themes': 103 | case 'theme-install': 104 | if ( is_multisite() ) { 105 | break; 106 | } 107 | // Fall-through. 108 | case 'themes-network': 109 | case 'theme-install-network': 110 | $message = sprintf( 111 | /* translators: 1: The name of the plugin, 2: The documentation URL. */ 112 | __( 'Your theme updates are now powered by %1$s. Learn more', 'aspireupdate' ), 113 | 'AspireUpdate', 114 | __( 'https://docs.aspirepress.org/aspireupdate/', 'aspireupdate' ) 115 | ); 116 | break; 117 | case 'update-core': 118 | if ( is_multisite() ) { 119 | break; 120 | } 121 | // Fall-through. 122 | case 'update-core-network': 123 | $message = sprintf( 124 | /* translators: 1: The name of the plugin, 2: The documentation URL. */ 125 | __( 'Your WordPress, plugin, theme and translation updates are now powered by %1$s. Learn more', 'aspireupdate' ), 126 | 'AspireUpdate', 127 | __( 'https://docs.aspirepress.org/aspireupdate/', 'aspireupdate' ) 128 | ); 129 | break; 130 | } 131 | 132 | if ( '' === $message ) { 133 | return; 134 | } 135 | 136 | echo wp_kses_post( '

' . $message . '

' ); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Translations Updater 3 | 4 | * Contributors: [Andy Fragen](https://github.com/afragen) 5 | * Tags: plugins, themes, edd software licensing, language pack, updater 6 | * Requires at least: 4.6 7 | * Requires PHP: 5.4 8 | * Donate link: 9 | * License: MIT 10 | * License URI: 11 | 12 | ## Description 13 | 14 | This framework allows for decoupled language pack updates for your WordPress plugins or themes that are hosted on public repositories in GitHub, Bitbucket, GitLab, or Gitea. 15 | 16 | The URI should point to a repository that contains the translations files. Refer to [Git Updater Translations](https://github.com/afragen/git-updater-translations) as an example. It is created using the [Language Pack Maker](https://github.com/afragen/language-pack-maker). The repo **must** be a public repo. 17 | 18 | ## Usage 19 | 20 | Install via Composer: `composer require afragen/translations-updater:^1` 21 | 22 | **Prior to release use the following command** 23 | `composer require afragen/translations-updater:dev-` currently `dev-master` 24 | 25 | Add `require_once __DIR__ . '/vendor/autoload.php';` to the main plugin file or theme's functions.php file. 26 | 27 | A configuration array with the following format is needed. All array elements are required. 28 | 29 | ```php 30 | add_action( 'admin_init', function() { 31 | $config = [ 32 | 'git' => '(github|bitbucket|gitlab|gitea)', 33 | 'type' => '(plugin|theme)', 34 | 'slug' => 'my-repo-slug', // Should be lowercase. 35 | 'version' => 'my-repo-version', // Current version of plugin|theme. 36 | 'languages' => 'https://my-path-to/language-packs', 37 | 'branch' => 'master', // Default (optional). 38 | ]; 39 | 40 | ( new \Fragen\Translations_Updater\Init() )->run( $config ); 41 | } ); 42 | ``` 43 | 44 | If you wish to delete the data stored in the options table associated with this framework you will need to issue the following command. 45 | 46 | ```php 47 | ( new \Fragen\Translations_Updater\Init() )->delete_cached_data(); 48 | ``` 49 | 50 | ## EDD Software Licensing Usage 51 | 52 | If using this framework with EDD Software Licensing you will need to update to the latest versions of the updaters in the EDD Software Licensing sample code to ensure the appropriate action hooks are present. 53 | 54 | You will need to add two key/value pairs to your setup array similar to the following, 55 | ```php 56 | 'git' => 'github', 57 | 'languages' => 'https://github.com//my-language-pack', 58 | ``` 59 | 60 | You will need to include the following command to your bootstrap file to activate the updater. 61 | 62 | ```php 63 | ( new \Fragen\Translations_Updater\Init( __NAMESPACE__ ) )->edd_run(); 64 | ``` 65 | 66 | ### Plugins 67 | 68 | You must add two additional key/value pairs to the setup array in your `EDD_SL_Plugin_Updater` setup. The array will be similar to the following from the `edd-sample-plugin.php` file. 69 | 70 | ```php 71 | $edd_updater = new EDD_SL_Plugin_Updater( EDD_SAMPLE_STORE_URL, __FILE__, array( 72 | 'version' => '1.0', // current version number 73 | 'license' => $license_key, // license key (used get_option above to retrieve from DB) 74 | 'item_name' => EDD_SAMPLE_ITEM_NAME, // name of this plugin 75 | 'author' => 'Pippin Williamson', // author of this plugin 76 | 'beta' => false, 77 | 'git' => 'bitbucket', 78 | 'languages' => 'https://bitbucket.org/afragen/test-language-pack', 79 | ) 80 | ``` 81 | 82 | ### Themes 83 | 84 | You must add two additional key/value pairs to the setup array in your `EDD_Theme_Updater_Admin` setup. The array will be similar to the following from the `edd-sample-theme/updater/theme-updater.php` file. 85 | 86 | ```php 87 | $updater = new EDD_Theme_Updater_Admin( 88 | 89 | // Config settings 90 | $config = array( 91 | 'remote_api_url' => 'https://easydigitaldownloads.com', // Site where EDD is hosted 92 | 'item_name' => 'Theme Name', // Name of theme 93 | 'theme_slug' => 'theme-slug', // Theme slug 94 | 'version' => '1.0.0', // The current version of this theme 95 | 'author' => 'Easy Digital Downloads', // The author of this theme 96 | 'download_id' => '', // Optional, used for generating a license renewal link 97 | 'renew_url' => '', // Optional, allows for a custom license renewal link 98 | 'beta' => false, // Optional, set to true to opt into beta versions 99 | 'git' => 'github', 100 | 'languages' => 'https://github.com//my-language-pack', 101 | ), 102 | ... 103 | ``` 104 | -------------------------------------------------------------------------------- /assets/css/aspire-update.css: -------------------------------------------------------------------------------- 1 | @keyframes glow { 2 | 0% { 3 | background-color: rgba(255, 223, 0, 0.1); 4 | } 5 | 6 | 100% { 7 | background-color: none; 8 | } 9 | } 10 | 11 | .glow-reveal { 12 | animation: glow 0.5s ease-in-out; 13 | } 14 | 15 | .aspireupdate-settings-field-hosts-wrapper .aspireupdate-settings-field-hosts-row { 16 | margin: 0 0 10px; 17 | } 18 | 19 | #aspireupdate-generate-api-key { 20 | display: inline-block; 21 | width: 30px; 22 | height: 30px; 23 | background: url(../images/icon-key.svg) no-repeat center center / 24px 24px; 24 | background-color: #cbcbcb; 25 | border: 1px solid #8c8f94; 26 | border-radius: 3px; 27 | clip-path: inset(0 0 0 0); 28 | color: transparent; 29 | cursor: pointer; 30 | transition: background-color 0.3s ease; 31 | } 32 | 33 | #aspireupdate-generate-api-key:hover { 34 | background-color: #e3e3e3; 35 | } 36 | 37 | .aspireupdate-settings-field-wrapper p.error { 38 | color: #bc3b3b; 39 | display: none; 40 | } 41 | 42 | .aspireupdate-notice { 43 | background-color: #f0f6fc; 44 | border: 1px solid #70b9e3; 45 | border-radius: 50px; 46 | max-width: max-content; 47 | } 48 | 49 | .aspireupdate-notice p::before { 50 | content: ""; 51 | display: inline-block; 52 | margin-inline-end: 0.5em; 53 | vertical-align: middle; 54 | background: url(../images/aspirepress-logo-icon.svg) no-repeat center center / 20px 20px; 55 | height: 20px; 56 | width: 20px; 57 | } 58 | 59 | .button.button-clearlog { 60 | border-color: #b32d2e; 61 | color: #b32d2e; 62 | } 63 | 64 | #aspireupdate-log-viewer { 65 | position: fixed; 66 | width: 100%; 67 | height: 100%; 68 | top: 0; 69 | right: 0; 70 | bottom: 0; 71 | left: 0; 72 | z-index: 999998; 73 | display: none; 74 | } 75 | 76 | #aspireupdate-log-viewer:before { 77 | content: ""; 78 | position: fixed; 79 | width: 100%; 80 | height: 100%; 81 | top: 0; 82 | right: 0; 83 | bottom: 0; 84 | left: 0; 85 | z-index: 999998; 86 | background: rgba(255, 255, 255, 0.9); 87 | } 88 | 89 | #aspireupdate-log-viewer .outer { 90 | position: fixed; 91 | width: calc(100% - 60px); 92 | height: calc(100% - 60px); 93 | top: 50%; 94 | left: 50%; 95 | transform: translate(-50%, -50%); 96 | background-color: lightgray; 97 | z-index: 999999; 98 | box-shadow: 0 0 5px #000; 99 | padding: 15px; 100 | } 101 | 102 | #aspireupdate-log-viewer .outer span.close { 103 | position: fixed; 104 | right: -1px; 105 | z-index: 999999; 106 | display: block; 107 | width: 20px; 108 | height: 20px; 109 | line-height: 20px; 110 | font-size: 20px; 111 | top: 1px; 112 | text-align: center; 113 | font-weight: 600; 114 | cursor: pointer; 115 | } 116 | 117 | #aspireupdate-log-viewer .outer span.close:before, 118 | #aspireupdate-log-viewer .outer span.close:after { 119 | position: absolute; 120 | top: 50%; 121 | left: 50%; 122 | width: 4px; 123 | height: 20px; 124 | background-color: #b32d2e; 125 | transform: rotate(45deg) translate(-50%, -50%); 126 | transform-origin: top left; 127 | content: ''; 128 | } 129 | 130 | #aspireupdate-log-viewer .outer span.close:after { 131 | transform: rotate(-45deg) translate(-50%, -50%); 132 | } 133 | 134 | #aspireupdate-log-viewer .inner { 135 | position: fixed; 136 | width: calc(100% - 40px); 137 | height: calc(100% - 40px); 138 | top: 20px; 139 | right: 20px; 140 | bottom: 20px; 141 | left: 20px; 142 | counter-reset: line; 143 | overflow: auto; 144 | } 145 | 146 | #aspireupdate-log-viewer .inner div { 147 | display: flex; 148 | align-items: flex-start; 149 | } 150 | 151 | #aspireupdate-log-viewer .inner>div:nth-child(odd) { 152 | background-color: #e9e9e9; 153 | } 154 | 155 | #aspireupdate-log-viewer .inner>div:nth-child(even) { 156 | background-color: #e0e0e0; 157 | } 158 | 159 | #aspireupdate-log-viewer .inner .number { 160 | counter-increment: line; 161 | width: 60px; 162 | text-align: right; 163 | padding-right: 10px; 164 | font-weight: bold; 165 | color: #555; 166 | } 167 | 168 | #aspireupdate-log-viewer .inner .number::before { 169 | content: counter(line); 170 | } 171 | 172 | #aspireupdate-log-viewer .inner .content { 173 | white-space: pre-wrap; 174 | word-break: break-all; 175 | margin: 0; 176 | flex: 1; 177 | } 178 | 179 | #voltron { 180 | color: transparent; 181 | font-size: clamp(4px, 0.9vw, 8px); 182 | line-height: 6px; 183 | display: inline-block; 184 | cursor: default; 185 | } 186 | 187 | #voltron:hover { 188 | animation: blink 1.8s ease-in-out infinite; 189 | animation-delay: 5s; 190 | } 191 | 192 | @keyframes blink { 193 | 194 | 0%, 195 | 100% { 196 | color: inherit; 197 | } 198 | 199 | 50% { 200 | color: transparent; 201 | } 202 | } 203 | 204 | @media only screen and (max-width: 576px) { 205 | #voltron { 206 | display: none; 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/src/Translations_Updater/Language_Pack_API.php: -------------------------------------------------------------------------------- 1 | repo = $config; 42 | $this->response = $this->get_repo_cache( $config->slug ); 43 | } 44 | 45 | /** 46 | * Get/process Language Packs. 47 | * 48 | * @param array $headers Array of headers of Language Pack. 49 | * 50 | * @return \stdClass|\WP_Error 51 | */ 52 | public function get_language_pack( $headers ) { 53 | $response = ! empty( $this->response['languages'] ) ? $this->response['languages'] : false; 54 | 55 | if ( ! $response ) { 56 | $response = $this->get_language_pack_json( $this->repo->git, $headers ); 57 | 58 | if ( $response ) { 59 | foreach ( $response as $locale ) { 60 | $package = $this->process_language_pack_package( $this->repo->git, $locale, $headers ); 61 | 62 | $response->{$locale->language}->package = $package; 63 | $response->{$locale->language}->type = $this->repo->type; 64 | $response->{$locale->language}->version = $this->repo->version; 65 | } 66 | $this->set_repo_cache( 'languages', $response, $this->repo->slug ); 67 | } else { 68 | return new \WP_Error( 69 | 'language_pack_validation_error', 70 | 'API timeout error', 71 | [ self::$error_code ] 72 | ); 73 | } 74 | } 75 | $this->repo->language_packs = $response; 76 | 77 | return $this->repo; 78 | } 79 | 80 | /** 81 | * Get language-pack.json from appropriate host. 82 | * 83 | * @param string $git ( github|bitbucket|gitlab|gitea ). 84 | * @param array $headers Repository headers. 85 | * 86 | * @return array|bool|mixed|object $response API response object. 87 | */ 88 | private function get_language_pack_json( $git, $headers ) { 89 | $type = $this->return_repo_type(); 90 | switch ( $git ) { 91 | // phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode 92 | case 'github': 93 | $response = $this->api( "/repos/{$headers['owner']}/{$headers['repo']}/contents/language-pack.json" ); 94 | $response = isset( $response->content ) 95 | ? json_decode( base64_decode( $response->content ) ) 96 | : null; 97 | break; 98 | case 'bitbucket': 99 | $response = $this->api( "/2.0/repositories/{$headers['owner']}/{$headers['repo']}/src/{$type['branch']}/language-pack.json" ); 100 | break; 101 | case 'gitlab': 102 | $id = rawurlencode( $headers['owner'] . '/' . $headers['repo'] ); 103 | $response = $this->api( "/projects/{$id}/repository/files/language-pack.json" ); 104 | $response = isset( $response->content ) 105 | ? json_decode( base64_decode( $response->content ) ) 106 | : null; 107 | break; 108 | case 'gitea': 109 | $response = $this->api( "/repos/{$headers['owner']}/{$headers['repo']}/raw/{$type['branch']}/language-pack.json" ); 110 | $response = isset( $response->content ) 111 | ? json_decode( base64_decode( $response->content ) ) 112 | : null; 113 | break; 114 | // phpcs:enable 115 | } 116 | 117 | if ( $this->validate_response( $response ) ) { 118 | return false; 119 | } 120 | 121 | return $response; 122 | } 123 | 124 | /** 125 | * Process $package for update transient. 126 | * 127 | * @param string $git ( github|bitbucket|gitlab|gitea ). 128 | * @param \stdClass $locale Site locale. 129 | * @param array $headers Repository headers. 130 | * 131 | * @return string 132 | */ 133 | private function process_language_pack_package( $git, $locale, $headers ) { 134 | $package = null; 135 | $type = $this->return_repo_type(); 136 | switch ( $git ) { 137 | case 'github': 138 | $package = [ $headers['uri'], "blob/{$type['branch']}" ]; 139 | $package = implode( '/', $package ) . $locale->package; 140 | $package = add_query_arg( [ 'raw' => 'true' ], $package ); 141 | break; 142 | case 'bitbucket': 143 | $package = [ $headers['uri'], "raw/{$type['branch']}" ]; 144 | $package = implode( '/', $package ) . $locale->package; 145 | break; 146 | case 'gitlab': 147 | $package = [ $headers['uri'], "raw/{$type['branch']}" ]; 148 | $package = implode( '/', $package ) . $locale->package; 149 | break; 150 | case 'gitea': 151 | // TODO: make sure this works. 152 | $package = [ $headers['uri'], "raw/{$type['branch']}" ]; 153 | $package = implode( '/', $package ) . $locale->package; 154 | break; 155 | } 156 | 157 | return $package; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /languages/aspireupdate.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 AspirePress 2 | # This file is distributed under the GPLv2. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: aspireupdate 0.6\n" 6 | "Report-Msgid-Bugs-To: https://github.com/aspirepress/aspireupdate/issues\n" 7 | "Last-Translator: FULL NAME \n" 8 | "Language-Team: LANGUAGE \n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "POT-Creation-Date: 2024-11-24T02:58:38+00:00\n" 13 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 | "X-Generator: WP-CLI 2.11.0\n" 15 | "X-Domain: aspireupdate\n" 16 | 17 | #. Plugin Name of the plugin 18 | #: aspire-update.php 19 | msgid "AspireUpdate" 20 | msgstr "" 21 | 22 | #. Plugin URI of the plugin 23 | #: aspire-update.php 24 | msgid "https://aspirepress.org/" 25 | msgstr "" 26 | 27 | #. Description of the plugin 28 | #: aspire-update.php 29 | msgid "Update plugins and themes for WordPress." 30 | msgstr "" 31 | 32 | #. Author of the plugin 33 | #: aspire-update.php 34 | msgid "AspirePress" 35 | msgstr "" 36 | 37 | #. Author URI of the plugin 38 | #: aspire-update.php 39 | #: includes/class-branding.php:99 40 | #: includes/class-branding.php:114 41 | #: includes/class-branding.php:127 42 | msgid "https://docs.aspirepress.org/aspireupdate/" 43 | msgstr "" 44 | 45 | #: includes/class-admin-settings.php:139 46 | msgid "Settings have been reset to default." 47 | msgstr "" 48 | 49 | #: includes/class-admin-settings.php:156 50 | msgid "Settings Saved" 51 | msgstr "" 52 | 53 | #: includes/class-admin-settings.php:329 54 | msgid "Unexpected Error" 55 | msgstr "" 56 | 57 | #: includes/class-admin-settings.php:383 58 | msgid "API Configuration" 59 | msgstr "" 60 | 61 | #: includes/class-admin-settings.php:394 62 | msgid "Enable AspireUpdate API Rewrites" 63 | msgstr "" 64 | 65 | #: includes/class-admin-settings.php:407 66 | msgid "API Host" 67 | msgstr "" 68 | 69 | #: includes/class-admin-settings.php:415 70 | msgid "Your new API Host." 71 | msgstr "" 72 | 73 | #: includes/class-admin-settings.php:425 74 | msgid "Other" 75 | msgstr "" 76 | 77 | #: includes/class-admin-settings.php:434 78 | msgid "API Key" 79 | msgstr "" 80 | 81 | #: includes/class-admin-settings.php:442 82 | msgid "Provides an API key for repositories that may require authentication." 83 | msgstr "" 84 | 85 | #: includes/class-admin-settings.php:448 86 | msgid "API Debug Configuration" 87 | msgstr "" 88 | 89 | #: includes/class-admin-settings.php:459 90 | msgid "Enable Debug Mode" 91 | msgstr "" 92 | 93 | #: includes/class-admin-settings.php:467 94 | msgid "Enables debug mode for the plugin." 95 | msgstr "" 96 | 97 | #: includes/class-admin-settings.php:473 98 | msgid "Enable Debug Type" 99 | msgstr "" 100 | 101 | #: includes/class-admin-settings.php:482 102 | msgid "Request" 103 | msgstr "" 104 | 105 | #: includes/class-admin-settings.php:483 106 | msgid "Response" 107 | msgstr "" 108 | 109 | #: includes/class-admin-settings.php:484 110 | msgid "String" 111 | msgstr "" 112 | 113 | #: includes/class-admin-settings.php:486 114 | msgid "Outputs the request URL and headers / response headers and body / string that is being rewritten." 115 | msgstr "" 116 | 117 | #: includes/class-admin-settings.php:492 118 | msgid "Disable SSL Verification" 119 | msgstr "" 120 | 121 | #: includes/class-admin-settings.php:501 122 | msgid "Disables the verification of SSL to allow local testing." 123 | msgstr "" 124 | 125 | #: includes/class-admin-settings.php:564 126 | msgid "Generate API Key" 127 | msgstr "" 128 | 129 | #. translators: 1: The name of the plugin, 2: The documentation URL. 130 | #: includes/class-branding.php:97 131 | msgid "Your plugin updates are now powered by %1$s. Learn more" 132 | msgstr "" 133 | 134 | #. translators: 1: The name of the plugin, 2: The documentation URL. 135 | #: includes/class-branding.php:112 136 | msgid "Your theme updates are now powered by %1$s. Learn more" 137 | msgstr "" 138 | 139 | #. translators: 1: The name of the plugin, 2: The documentation URL. 140 | #: includes/class-branding.php:125 141 | msgid "Your WordPress, plugin, theme and translation updates are now powered by %1$s. Learn more" 142 | msgstr "" 143 | 144 | #: includes/class-controller.php:61 145 | #: includes/class-controller.php:91 146 | msgid "Error: You are not authorized to access this resource." 147 | msgstr "" 148 | 149 | #: includes/class-controller.php:77 150 | msgid "Log file cleared successfully." 151 | msgstr "" 152 | 153 | #: includes/class-debug.php:85 154 | msgid "Error: Unable to read the log file." 155 | msgstr "" 156 | 157 | #: includes/class-debug.php:98 158 | msgid "*****Log file is empty.*****" 159 | msgstr "" 160 | 161 | #. translators: 1: The number of lines at which the content was truncated. 162 | #: includes/class-debug.php:102 163 | msgid "*****Log truncated at %s lines.*****" 164 | msgstr "" 165 | 166 | #: includes/class-debug.php:118 167 | msgid "Error: Unable to access the log file." 168 | msgstr "" 169 | 170 | #: includes/views/page-admin-settings.php:8 171 | msgid "AspireUpdate Settings" 172 | msgstr "" 173 | 174 | #: includes/views/page-admin-settings.php:17 175 | msgid "Reset" 176 | msgstr "" 177 | 178 | #: includes/views/page-admin-settings.php:18 179 | msgid "Clear Log" 180 | msgstr "" 181 | 182 | #: includes/views/page-admin-settings.php:19 183 | msgid "View Log" 184 | msgstr "" 185 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AspireUpdate 2 | 3 | This plugin allows a WordPress user to automatically rewrite certain URLs and URL paths to a new URL. This is 4 | helpful because it allows for the rewriting of `api.wordpress.org` to some other repository that contains the plugins 5 | the user wants. 6 | 7 | The plugin supports multiple rewrites, and also supports rewriting the URL paths of the requests on a per-host basis. 8 | This improves the capacity of the plugin to adequately support newer or different repositories. 9 | 10 | ## Requirements 11 | 12 | This plugin requires: 13 | 14 | - WordPress 5.3 or later 15 | - PHP 7.4 or later 16 | - The ability to upload files to your WordPress installation 17 | - The ability to modify your configuration in wp-config.php 18 | 19 | ## Installation 20 | 21 | To install this plugin, follow these steps: 22 | 23 | 1. Download a copy of this plugin as a ZIP file from GitHub or the Releases section. 24 | 2. Go to the WordPress Dashboard (/wp-admin) section and log in if necessary as an administrator. 25 | 3. Go to the Plugins menu and click on "Add New Plugin". 26 | 4. Click the button "Upload Plugin" and upload the plugin ZIP file. 27 | 5. Activate the AspireUpdate plugin. 28 | 6. Configure the plugin if necessary with the user interface. 29 | 7. Test and enjoy! 30 | 31 | ## Configuration 32 | 33 | The plugin menu appears under the Dashboard main menu item. Don't look for it in Settings or Tools, it won't be there :). 34 | 35 | The plugin can use the following configuration options in wp-config.php: 36 | 37 | | Configuration Parameter | Description | Default, if any | 38 | | :---------------------- | -------------------------------------------------------------------------------------------------------: | -------------------------------------: | 39 | | AP_ENABLE | Enable API rewrite | false | 40 | | AP_API_KEY | The API Key for AspireCloud (not currently enforced) | | 41 | | AP_HOST | API domain name | api.aspirecloud.org | 42 | | AP_DEBUG | Enable Debug Mode | false | 43 | | AP_DEBUG_TYPES | an array of debug modes | array('string', 'request', 'response') | 44 | | AP_DISABLE_SSL | Disabled SSL verification for local testing | true | 45 | | AP_REMOVE_UI | Disables plugin settings user interface and branding, defaults to config parameters set in wp-config.php | false | 46 | 47 | To set AP_DEBUG_TYPES use an array to define the constant: 48 | 49 | ```php 50 | // Works as of PHP 7 51 | define('AP_DEBUG_TYPES', array( 52 | 'string', 'request', 'response' 53 | )); 54 | ``` 55 | 56 | NOTE: Any AspirePress configuration parameters set in wp-config.php _will_ override any plugin options set in the plugin user interface. 57 | 58 | NOTE 2: Setting AP_REMOVE_UI to `true` removes the plugin user interface. This is intended to be used in situations where AspireUpdate is deployed in a pre-configured mode and end-user configuration is not expected nor allowed. 59 | 60 | ## WP Playgrounds Support 61 | 62 | The AspireUpdate current build ('main' branch) can be [experimented with in the WP Playground environment](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/aspirepress/aspireupdate/refs/heads/main/assets/playground/blueprint.json). 63 | 64 | The AspireUpdate stable build ('playground-ready' branch) can be [tested with in the WP Playground environment](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/aspirepress/aspireupdate/refs/heads/playground-ready/assets/playground/blueprint.json). 65 | 66 | ## Debug Logging 67 | 68 | The AspireUpdate log file is located under /wp-content and named "debug-aspire-update.log". 69 | 70 | ## Authentication 71 | 72 | Authentication is provided by way of a randomly generated token combined with the `WP_SITEURL` constant. This token is 73 | then Base64-encoded with the separate parts of the credentials separated by a colon. It's added to the `Authorization` 74 | header. 75 | 76 | ## License 77 | 78 | This plugin is licensed under the GPLv2, as it is a WordPress plugin and that is the license required. 79 | 80 | ## Contributing 81 | 82 | Contributions are welcome. Here's a short to-do list: 83 | 84 | - Add support for more complex rewrites. Right now we only support simple string matching, but it would be nice to support pattern matching, too. 85 | - Add support for more complex debugging. Right now we only support outputting strings, but it would be nice to support more complex debugging. 86 | - Add support for verifying that the repository can be reached, and if not, reverting back to the original repository. 87 | - Add support for multiple repositories, in a priority order. This would allow for multiple fallbacks. 88 | - Add support for additional header management. Right now the plugin is designed to add a simple Authentication header, which is not always needed. Other repositories might have different authentication requirements. 89 | 90 | ## Support 91 | 92 | If you need help with this plugin, please file an issue explaining the following: 93 | 94 | - What you did 95 | - What you expected 96 | - What actually happened 97 | - Why you think this is wrong 98 | 99 | Issues that are not filed with this information will be closed. We will do our best to assist, but we cannot guarantee a response. 100 | 101 | ## CHANGELOG 102 | 103 | 0.6 - Nov 13 2024 104 | * Admin Settings: Added notices for when settings are saved or reset 105 | * Branding: Added branded notices to inform users when AspireUpdate is in operation on a screen 106 | * Multisite: Added multisite support 107 | * Debug: Added Clear Logs and View Logs functionality 108 | * I18N: Added Catalan translation 109 | * I18N: Added Dutch translation 110 | * I18N: Added Spanish translation 111 | * I18N: Added Swedish translation 112 | * I18N: Updated Dutch translation 113 | * I18N: Updated French translation 114 | * I18N: Updated German translation 115 | * Testing: Added Git Updater integration 116 | * Testing: Added support both main and playground-ready links in the README 117 | * Testing: Made Playground default to the `main` branch 118 | * Testing: Removed Hello Dolly from the Playground blueprint 119 | * Security: Fixed Plugin Check security warnings 120 | 121 | = 0.5 - Oct 2024 122 | * first stable version, connects to api.wordpress.org or an alternative AspireCloud repository 123 | -------------------------------------------------------------------------------- /includes/class-debug.php: -------------------------------------------------------------------------------- 1 | exists( $file_path ) || ! $wp_filesystem->is_readable( $file_path ) ) { 85 | return new \WP_Error( 'not_readable', __( 'Error: Unable to read the log file.', 'aspireupdate' ) ); 86 | } 87 | 88 | $file_content = $wp_filesystem->get_contents_array( $file_path ); 89 | $content = ''; 90 | $index = 0; 91 | foreach ( $file_content as $file_content_lines ) { 92 | if ( ( $index < $limit ) ) { 93 | $content .= $file_content_lines . PHP_EOL; 94 | ++$index; 95 | } 96 | } 97 | if ( '' === trim( $content ) ) { 98 | $content = esc_html__( '*****Log file is empty.*****', 'aspireupdate' ); 99 | } elseif ( $limit < count( $file_content ) ) { 100 | $content .= PHP_EOL . sprintf( 101 | /* translators: 1: The number of lines at which the content was truncated. */ 102 | esc_html__( '*****Log truncated at %s lines.*****', 'aspireupdate' ), 103 | $limit 104 | ); 105 | } 106 | return $content; 107 | } 108 | 109 | /** 110 | * Clear content of the log file. 111 | * 112 | * @return boolean|WP_Error true on success and false on failure. 113 | */ 114 | public static function clear() { 115 | $wp_filesystem = self::init_filesystem(); 116 | $file_path = self::get_file_path(); 117 | if ( ! self::verify_filesystem( $wp_filesystem ) || ! $wp_filesystem->exists( $file_path ) || ! $wp_filesystem->is_writable( $file_path ) ) { 118 | return new \WP_Error( 'not_accessible', __( 'Error: Unable to access the log file.', 'aspireupdate' ) ); 119 | } 120 | 121 | $wp_filesystem->put_contents( 122 | $file_path, 123 | '', 124 | FS_CHMOD_FILE 125 | ); 126 | return true; 127 | } 128 | 129 | /** 130 | * Logs a message to the debug log file. 131 | * 132 | * @param mixed $message The message to log. 133 | * @param string $type The log level ('string', 'request', 'response'). 134 | */ 135 | public static function log( $message, $type = 'string' ) { 136 | $wp_filesystem = self::init_filesystem(); 137 | if ( self::verify_filesystem( $wp_filesystem ) ) { 138 | $timestamp = gmdate( 'Y-m-d H:i:s' ); 139 | $formatted_message = sprintf( 140 | '[%s] [%s]: %s', 141 | $timestamp, 142 | strtoupper( $type ), 143 | self::format_message( $message ) 144 | ) . PHP_EOL; 145 | 146 | $file_path = self::get_file_path(); 147 | 148 | $content = ''; 149 | if ( $wp_filesystem->exists( $file_path ) ) { 150 | if ( $wp_filesystem->is_readable( $file_path ) ) { 151 | $content = $wp_filesystem->get_contents( $file_path ); 152 | } 153 | } 154 | $wp_filesystem->put_contents( 155 | $file_path, 156 | $formatted_message . $content, 157 | FS_CHMOD_FILE 158 | ); 159 | } 160 | } 161 | 162 | /** 163 | * Formats the message to be logged. 164 | * 165 | * @param mixed $message The message to format (string, array, object, etc.). 166 | * @return string The formatted message. 167 | */ 168 | private static function format_message( $message ) { 169 | if ( is_array( $message ) || is_object( $message ) ) { 170 | // phpcs:disable WordPress.PHP.DevelopmentFunctions 171 | /** 172 | * Priting an array or object to log file. This is a valid use case. 173 | */ 174 | return print_r( $message, true ); 175 | // phpcs:enable 176 | } 177 | return (string) $message; 178 | } 179 | 180 | /** 181 | * Log an info message. 182 | * 183 | * @param mixed $message The message to log. 184 | * 185 | * @return void 186 | */ 187 | public static function log_string( $message ) { 188 | $admin_settings = Admin_Settings::get_instance(); 189 | $debug_mode = $admin_settings->get_setting( 'enable_debug', false ); 190 | $debug_types = $admin_settings->get_setting( 'enable_debug_type', [] ); 191 | if ( $debug_mode && is_array( $debug_types ) && in_array( 'string', $debug_types, true ) ) { 192 | self::log( $message, 'string' ); 193 | } 194 | } 195 | 196 | /** 197 | * Log a warning message. 198 | * 199 | * @param mixed $message The message to log. 200 | * 201 | * @return void 202 | */ 203 | public static function log_request( $message ) { 204 | $admin_settings = Admin_Settings::get_instance(); 205 | $debug_mode = $admin_settings->get_setting( 'enable_debug', false ); 206 | $debug_types = $admin_settings->get_setting( 'enable_debug_type', [] ); 207 | if ( $debug_mode && is_array( $debug_types ) && in_array( 'request', $debug_types, true ) ) { 208 | self::log( $message, 'request' ); 209 | } 210 | } 211 | 212 | /** 213 | * Log an error message. 214 | * 215 | * @param mixed $message The message to log. 216 | * 217 | * @return void 218 | */ 219 | public static function log_response( $message ) { 220 | $admin_settings = Admin_Settings::get_instance(); 221 | $debug_mode = $admin_settings->get_setting( 'enable_debug', false ); 222 | $debug_types = $admin_settings->get_setting( 'enable_debug_type', [] ); 223 | if ( $debug_mode && is_array( $debug_types ) && in_array( 'response', $debug_types, true ) ) { 224 | self::log( $message, 'response' ); 225 | } 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /vendor/afragen/translations-updater/src/Translations_Updater/API.php: -------------------------------------------------------------------------------- 1 | repo->slug => $code ) 44 | */ 45 | protected static $error_code = []; 46 | 47 | /** 48 | * Return repo data for API calls. 49 | * 50 | * @return array 51 | */ 52 | final protected function return_repo_type() { 53 | $arr = []; 54 | $arr['type'] = $this->repo->type; 55 | $arr['branch'] = $this->repo->branch; 56 | 57 | switch ( $this->repo->git ) { 58 | case 'github': 59 | $arr['git'] = 'github'; 60 | $arr['base_uri'] = 'https://api.github.com'; 61 | $arr['base_download'] = 'https://github.com'; 62 | break; 63 | case 'bitbucket': 64 | $arr['git'] = 'bitbucket'; 65 | $arr['base_uri'] = 'https://bitbucket.org/api'; 66 | $arr['base_download'] = 'https://bitbucket.org'; 67 | break; 68 | case 'gitlab': 69 | $arr['git'] = 'gitlab'; 70 | $arr['base_uri'] = 'https://gitlab.com/api/v4'; 71 | $arr['base_download'] = 'https://gitlab.com'; 72 | break; 73 | case 'gitea': 74 | $arr['git'] = 'gitea'; 75 | // TODO: make sure this works. 76 | $arr['base_uri'] = $this->repo->languages . '/api/v1'; 77 | $arr['base_download'] = $this->repo->languages; 78 | break; 79 | } 80 | 81 | return $arr; 82 | } 83 | 84 | /** 85 | * Call the API and return a json decoded body. 86 | * 87 | * @param string $url Repository URL. 88 | * 89 | * @return boolean|\stdClass 90 | */ 91 | final protected function api( $url ) { 92 | $url = $this->get_api_url( $url ); 93 | $args = []; 94 | 95 | // Use cached API failure data to avoid hammering the API. 96 | $response = $this->get_repo_cache( md5( $url ) ); 97 | $cached = isset( $response['error_cache'] ); 98 | $response = $response ? $response['error_cache'] : $response; 99 | $response = empty( $response ) 100 | ? wp_remote_get( $url, $args ) 101 | : $response; 102 | 103 | $code = (int) wp_remote_retrieve_response_code( $response ); 104 | $allowed_codes = [ 200 ]; 105 | 106 | if ( is_wp_error( $response ) ) { 107 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions 108 | error_log( var_export( $response, true ) ); 109 | 110 | return $response; 111 | } 112 | 113 | // Cache HTTP API error code for 60 minutes. 114 | if ( ! in_array( $code, $allowed_codes, true ) && ! $cached ) { 115 | $timeout = 60; 116 | 117 | // Set timeout to GitHub rate limit reset. 118 | $timeout = static::ratelimit_reset( $response, $this->repo->slug ); 119 | $response['timeout'] = $timeout; 120 | $this->set_repo_cache( 'error_cache', $response, md5( $url ), "+{$timeout} minutes" ); 121 | } 122 | 123 | static::$error_code[ $this->repo->slug ] = static::$error_code[ $this->repo->slug ] ?? []; 124 | static::$error_code[ $this->repo->slug ] = array_merge( 125 | static::$error_code[ $this->repo->slug ], 126 | [ 127 | 'repo' => $this->repo->slug, 128 | 'code' => $code, 129 | 'name' => $this->repo->name ?? $this->repo->slug, 130 | 'git' => $this->repo->git, 131 | ] 132 | ); 133 | if ( isset( $response['timeout'] ) ) { 134 | static::$error_code[ $this->repo->slug ]['wait'] = static::ratelimit_reset( $response, $this->repo->slug ); 135 | } 136 | 137 | if ( isset( $response['timeout'] ) && defined( 'WP_DEBUG' ) && WP_DEBUG ) { 138 | $response_body = json_decode( wp_remote_retrieve_body( $response ) ); 139 | if ( null !== $response_body && property_exists( $response_body, 'message' ) ) { 140 | $log_message = "Translations Updater Error: {$this->repo->slug} - {$response_body->message}" 141 | . "\nTime remaining for rate limiting: {$this->ratelimit_reset($response, $this->repo->slug)} minutes"; 142 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log 143 | error_log( $log_message ); 144 | } 145 | } 146 | 147 | return json_decode( wp_remote_retrieve_body( $response ) ); 148 | } 149 | 150 | /** 151 | * Return API url. 152 | * 153 | * @access protected 154 | * 155 | * @param string $endpoint API endpoint. 156 | * 157 | * @return string $endpoint 158 | */ 159 | final protected function get_api_url( $endpoint ) { 160 | $type = $this->return_repo_type(); 161 | 162 | switch ( $type['git'] ) { 163 | case 'bitbucket': 164 | case 'gitea': 165 | break; 166 | case 'github': 167 | case 'gitlab': 168 | $endpoint = add_query_arg( 'ref', $type['branch'], $endpoint ); 169 | break; 170 | default: 171 | } 172 | 173 | return $type['base_uri'] . $endpoint; 174 | } 175 | 176 | /** 177 | * Validate wp_remote_get response. 178 | * 179 | * @param \stdClass $response API response. 180 | * 181 | * @return bool true if invalid 182 | */ 183 | final protected function validate_response( $response ) { 184 | return empty( $response ) || isset( $response->message ); 185 | } 186 | 187 | /** 188 | * Returns repo cached data. 189 | * 190 | * @param string|bool $repo Repo name or false. 191 | * 192 | * @return array|bool false for expired cache 193 | */ 194 | final protected function get_repo_cache( $repo = false ) { 195 | if ( ! $repo ) { 196 | $repo = isset( $this->repo->slug ) ? $this->repo->slug : 'tu'; 197 | } 198 | $cache_key = 'tu-' . md5( $repo ); 199 | $cache = get_site_option( $cache_key ); 200 | 201 | if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { 202 | return []; 203 | } 204 | 205 | return $cache; 206 | } 207 | 208 | /** 209 | * Sets repo data for cache in site option. 210 | * 211 | * @param string $id Data Identifier. 212 | * @param mixed $response Data to be stored. 213 | * @param string|bool $repo Repo name or false. 214 | * 215 | * @return bool 216 | */ 217 | final protected function set_repo_cache( $id, $response, $repo = false, $timeout = false ) { 218 | if ( ! $repo ) { 219 | $repo = isset( $this->repo->slug ) ? $this->repo->slug : 'tu'; 220 | } 221 | $cache_key = 'tu-' . md5( $repo ); 222 | $timeout = $timeout ? $timeout : '+' . static::$hours . ' hours'; 223 | 224 | $this->response['timeout'] = strtotime( $timeout ); 225 | $this->response[ $id ] = $response; 226 | 227 | update_site_option( $cache_key, $this->response ); 228 | 229 | return true; 230 | } 231 | 232 | /** 233 | * Calculate and store time until rate limit reset. 234 | * 235 | * @param array $response HTTP headers. 236 | * @param string $repo Repo name. 237 | * 238 | * @return void|int 239 | */ 240 | final public static function ratelimit_reset( $response, $repo ) { 241 | $headers = wp_remote_retrieve_headers( $response ); 242 | $data = $headers->getAll(); 243 | $wait = 0; 244 | if ( isset( $data['x-ratelimit-reset'] ) ) { 245 | $reset = (int) $data['x-ratelimit-reset']; 246 | //phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date 247 | $wait = date( 'i', $reset - time() ); 248 | static::$error_code[ $repo ] = static::$error_code[ $repo ] ?? []; 249 | static::$error_code[ $repo ] = array_merge( static::$error_code[ $repo ], [ 'wait' => $wait ] ); 250 | 251 | return $wait; 252 | } 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /assets/js/aspire-update.js: -------------------------------------------------------------------------------- 1 | 2 | jQuery(document).ready(function () { 3 | new ApiRewrites(); 4 | new ApiDebug(); 5 | 6 | new ClearLog(); 7 | new ViewLog(); 8 | }); 9 | 10 | class ClearLog { 11 | constructor() { 12 | ClearLog.clearlog_button.init(); 13 | } 14 | 15 | static clearlog_button = { 16 | field: jQuery('#aspireupdate-button-clearlog'), 17 | init() { 18 | ClearLog.clearlog_button.field.click(function () { 19 | ClearLog.clearlog_button.clear(); 20 | }); 21 | }, 22 | show() { 23 | ClearLog.clearlog_button.field.show(); 24 | }, 25 | hide() { 26 | ClearLog.clearlog_button.field.hide(); 27 | }, 28 | clear() { 29 | let parameters = { 30 | "url": aspireupdate.ajax_url, 31 | "type": "POST", 32 | "data": { 33 | "nonce": aspireupdate.nonce, 34 | "action": "aspireupdate_clear_log" 35 | } 36 | }; 37 | jQuery.ajax(parameters) 38 | .done(function (response) { 39 | if ('' != response.data.message) { 40 | alert(response.data.message); 41 | } else { 42 | alert(aspireupdate.unexpected_error); 43 | } 44 | }) 45 | .fail(function (response) { 46 | alert(aspireupdate.unexpected_error); 47 | }); 48 | }, 49 | } 50 | } 51 | 52 | class ViewLog { 53 | constructor() { 54 | ViewLog.viewlog_button.init(); 55 | ViewLog.viewlog_popup.init(); 56 | } 57 | 58 | static viewlog_button = { 59 | field: jQuery('#aspireupdate-button-viewlog'), 60 | init() { 61 | ViewLog.viewlog_button.field.click(function () { 62 | ViewLog.viewlog_popup.show(); 63 | }); 64 | }, 65 | show() { 66 | ViewLog.viewlog_button.field.show(); 67 | }, 68 | hide() { 69 | ViewLog.viewlog_button.field.hide(); 70 | } 71 | } 72 | 73 | static viewlog_popup = { 74 | field: jQuery('#aspireupdate-log-viewer'), 75 | popup_inner: jQuery('#aspireupdate-log-viewer .inner'), 76 | close_button: jQuery('#aspireupdate-log-viewer span.close'), 77 | init() { 78 | ViewLog.viewlog_popup.close_button.click(function () { 79 | ViewLog.viewlog_popup.close(); 80 | }); 81 | 82 | jQuery(document).keydown(function (event) { 83 | if ((event.keyCode === 27) && ViewLog.viewlog_popup.field.is(':visible')) { 84 | ViewLog.viewlog_popup.close(); 85 | } 86 | }); 87 | }, 88 | show() { 89 | let parameters = { 90 | "url": aspireupdate.ajax_url, 91 | "type": "POST", 92 | "data": { 93 | "nonce": aspireupdate.nonce, 94 | "action": "aspireupdate_read_log" 95 | } 96 | }; 97 | jQuery.ajax(parameters) 98 | .done(function (response) { 99 | if ((true == response.success) && ('' != response.data.content)) { 100 | let lines = response.data.content.split(aspireupdate.line_ending); 101 | jQuery.each(lines, function (index, line) { 102 | jQuery('
') 103 | .append( 104 | jQuery('').addClass('number'), 105 | jQuery('').addClass('content').text(line) 106 | ) 107 | .appendTo(ViewLog.viewlog_popup.popup_inner); 108 | }); 109 | ViewLog.viewlog_popup.field.show(); 110 | } else if ('' != response.data.message) { 111 | alert(response.data.message); 112 | } else { 113 | alert(aspireupdate.unexpected_error); 114 | } 115 | }) 116 | .fail(function (response) { 117 | alert(aspireupdate.unexpected_error); 118 | }); 119 | }, 120 | close() { 121 | ViewLog.viewlog_popup.field.hide(); 122 | ViewLog.viewlog_popup.popup_inner.html(''); 123 | } 124 | } 125 | } 126 | 127 | class ApiRewrites { 128 | constructor() { 129 | ApiRewrites.host_selector.init(); 130 | ApiRewrites.other_hosts.init(); 131 | ApiRewrites.api_key.init(); 132 | ApiRewrites.enabled_rewrites.init(); 133 | } 134 | 135 | static enabled_rewrites = { 136 | field: jQuery('#aspireupdate-settings-field-enable'), 137 | sub_fields: [], 138 | init() { 139 | ApiRewrites.enabled_rewrites.sub_fields = [ 140 | ApiRewrites.host_selector, 141 | ApiRewrites.api_key 142 | ]; 143 | 144 | ApiRewrites.enabled_rewrites.field.change(function () { 145 | if (jQuery(this).is(':checked')) { 146 | ApiRewrites.enabled_rewrites.show_options(); 147 | } else { 148 | ApiRewrites.enabled_rewrites.hide_options(); 149 | } 150 | }).change(); 151 | }, 152 | show_options() { 153 | Fields.show(ApiRewrites.enabled_rewrites.sub_fields); 154 | }, 155 | hide_options() { 156 | Fields.hide(ApiRewrites.enabled_rewrites.sub_fields); 157 | } 158 | } 159 | 160 | static host_selector = { 161 | field: jQuery('#aspireupdate-settings-field-api_host'), 162 | init() { 163 | ApiRewrites.host_selector.field.change(function () { 164 | let selected_option = ApiRewrites.host_selector.field.find(":selected"); 165 | if ('other' === selected_option.val()) { 166 | ApiRewrites.other_hosts.show(); 167 | } else { 168 | ApiRewrites.other_hosts.hide(); 169 | } 170 | 171 | if (ApiRewrites.host_selector.is_api_key_required()) { 172 | ApiRewrites.api_key.make_required(); 173 | } else { 174 | ApiRewrites.api_key.remove_required(); 175 | } 176 | 177 | if (ApiRewrites.host_selector.has_api_key_url()) { 178 | ApiRewrites.api_key.show_action_button(); 179 | } else { 180 | ApiRewrites.api_key.hide_action_button(); 181 | } 182 | }).change(); 183 | }, 184 | is_api_key_required() { 185 | let is_api_rewrites_enabled = jQuery('#aspireupdate-settings-field-enable').is(':checked'); 186 | let selected_option = ApiRewrites.host_selector.field.find(":selected"); 187 | let require_api_key = selected_option.attr('data-require-api-key'); 188 | if (is_api_rewrites_enabled && 'true' === require_api_key) { 189 | return true; 190 | } 191 | return false; 192 | }, 193 | has_api_key_url() { 194 | let selected_option = ApiRewrites.host_selector.field.find(":selected"); 195 | let api_url = selected_option.attr('data-api-key-url'); 196 | if ('' !== api_url) { 197 | return true; 198 | } 199 | return false; 200 | }, 201 | get_api_key_url() { 202 | let selected_option = ApiRewrites.host_selector.field.find(":selected"); 203 | let api_url = selected_option.attr('data-api-key-url'); 204 | if ('' !== api_url) { 205 | return api_url; 206 | } 207 | return ''; 208 | }, 209 | } 210 | 211 | static other_hosts = { 212 | field: jQuery('#aspireupdate-settings-field-api_host_other'), 213 | init() { 214 | ApiRewrites.other_hosts.field.on("blur", function () { 215 | let value = ApiRewrites.other_hosts.field.val(); 216 | value = ApiRewrites.other_hosts.strip_protocol(value); 217 | value = ApiRewrites.other_hosts.strip_dangerous_characters(value); 218 | ApiRewrites.other_hosts.field.val(value); 219 | }); 220 | }, 221 | show() { 222 | ApiRewrites.other_hosts.field.parent().show(); 223 | ApiRewrites.other_hosts.field.focus(); 224 | ApiRewrites.other_hosts.make_required(); 225 | }, 226 | hide() { 227 | ApiRewrites.other_hosts.field.parent().hide(); 228 | ApiRewrites.other_hosts.remove_required(); 229 | }, 230 | make_required() { 231 | ApiRewrites.other_hosts.field.prop('required', true); 232 | }, 233 | remove_required() { 234 | ApiRewrites.other_hosts.field.prop('required', false); 235 | }, 236 | strip_protocol(value) { 237 | const protocol_regex = /^(https?|ftp|sftp|smtp|ftps|file):\/\/|^www\./i; 238 | return value.replace(protocol_regex, ''); 239 | }, 240 | strip_dangerous_characters(value) { 241 | const dangerous_characters_regex = /[<>/"'&;]/g; 242 | return value.replace(dangerous_characters_regex, ''); 243 | } 244 | } 245 | 246 | static api_key = { 247 | field: jQuery('#aspireupdate-settings-field-api_key'), 248 | action_button: jQuery('#aspireupdate-generate-api-key'), 249 | init() { 250 | ApiRewrites.api_key.action_button.click(function () { 251 | ApiRewrites.api_key.hide_error(); 252 | ApiRewrites.api_key.get_api_key(); 253 | }); 254 | ApiRewrites.api_key.hide_error(); 255 | }, 256 | get_api_key() { 257 | let parameters = { 258 | "url": ApiRewrites.host_selector.get_api_key_url(), 259 | "type": "POST", 260 | "contentType": 'application/json', 261 | "data": JSON.stringify({ 262 | "domain": aspireupdate.domain 263 | }) 264 | }; 265 | jQuery.ajax(parameters) 266 | .done(function (response) { 267 | ApiRewrites.api_key.field.val(response.apikey); 268 | }) 269 | .fail(function (response) { 270 | if ((response.status === 400) || (response.status === 401)) { 271 | ApiRewrites.api_key.show_error(response.responseJSON?.error); 272 | } else { 273 | ApiRewrites.api_key.show_error(aspireupdate.unexpected_error + ' : ' + response.status); 274 | } 275 | }); 276 | }, 277 | show() { 278 | ApiRewrites.api_key.field.parent().parent().parent().show(); 279 | }, 280 | hide() { 281 | ApiRewrites.api_key.field.parent().parent().parent().hide(); 282 | }, 283 | show_action_button() { 284 | ApiRewrites.api_key.action_button.show(); 285 | }, 286 | hide_action_button() { 287 | ApiRewrites.api_key.action_button.hide(); 288 | }, 289 | make_required() { 290 | ApiRewrites.api_key.field.prop('required', true); 291 | }, 292 | remove_required() { 293 | ApiRewrites.api_key.field.prop('required', false); 294 | }, 295 | show_error(message) { 296 | ApiRewrites.api_key.field.parent().find('.error').html(message).show(); 297 | }, 298 | hide_error() { 299 | ApiRewrites.api_key.field.parent().find('.error').html('').hide(); 300 | } 301 | } 302 | } 303 | 304 | class ApiDebug { 305 | constructor() { 306 | ApiDebug.enabled_debug.init(); 307 | } 308 | 309 | static enabled_debug = { 310 | field: jQuery('#aspireupdate-settings-field-enable_debug'), 311 | sub_fields: [], 312 | init() { 313 | ApiDebug.enabled_debug.sub_fields = [ 314 | ApiDebug.debug_type, 315 | ApiDebug.disable_ssl_verification, 316 | ]; 317 | 318 | ApiDebug.enabled_debug.field.change(function () { 319 | if (jQuery(this).is(':checked')) { 320 | ApiDebug.enabled_debug.show_options(); 321 | } else { 322 | ApiDebug.enabled_debug.hide_options(); 323 | } 324 | }).change(); 325 | }, 326 | show_options() { 327 | Fields.show(ApiDebug.enabled_debug.sub_fields); 328 | ViewLog.viewlog_button.show(); 329 | ClearLog.clearlog_button.show(); 330 | }, 331 | hide_options() { 332 | Fields.hide(ApiDebug.enabled_debug.sub_fields); 333 | ViewLog.viewlog_button.hide(); 334 | ClearLog.clearlog_button.hide(); 335 | } 336 | } 337 | 338 | static debug_type = { 339 | field: jQuery('.aspireupdate-settings-field-wrapper-enable_debug_type'), 340 | } 341 | 342 | static disable_ssl_verification = { 343 | field: jQuery('#aspireupdate-settings-field-disable_ssl_verification'), 344 | } 345 | } 346 | 347 | class Fields { 348 | static show(sub_fields) { 349 | jQuery.each(sub_fields, function (index, sub_field) { 350 | sub_field.field.closest('tr').show().addClass('glow-reveal'); 351 | sub_field.field.change(); 352 | setTimeout(function () { 353 | sub_field.field.closest('tr').removeClass('glow-reveal'); 354 | }, 500); 355 | }); 356 | } 357 | 358 | static hide(sub_fields) { 359 | jQuery.each(sub_fields, function (index, sub_field) { 360 | sub_field.field.closest('tr').hide(); 361 | sub_field.field.change(); 362 | }); 363 | } 364 | } 365 | 366 | -------------------------------------------------------------------------------- /includes/views/voltron.txt: -------------------------------------------------------------------------------- 1 |
 2 | ...................................................................................................:?%,.............................................................................
 3 | .................................................................................................,;*%:..............................................................................
 4 | ...............................................................................................,++?+,...............................................................................
 5 | ..............................................................................................;**?+.................................................................................
 6 | ............................................................................................:*+;?;:++++:,...........................................................................
 7 | ..........................................................................................:*+:;%*++::;;;+++:........................................................................
 8 | ........................................................................................,+*:,+S*::+%#@#+.,*?........................................................................
 9 | ......................................................................................,+*;,.,;:;?#@@@%;,;*+,........................................................................
10 | ....................................................................................,+*;:..,+?S@@@@@%,.+*,..........................................................................
11 | ...................................................................................:*+:*+,;:*#@@@@@@?.;*,...........................................................................
12 | .................................................................................,+*:;?;:?*%.;S@@@@#+.++............................................................................
13 | ...............................................................................,*+::?S:;%:,%:,%@@@@#?.++............................................................................
14 | .............................................................................,+*;,*@%,;%:.,%:,?@@@@@%.++............................................................................
15 | ............................................................................;*;,+#@?,+%:..,%::%@@@@@?.++............................................................................
16 | ..........................................................................:*+,;S@@*,*?,...,%,:S@@@@@?.++............................................................................
17 | ........................................................................,**::%@@#;,?%+;;;;+?.:S@@@@@?.;*:;;;:.......................................................................
18 | ......................................................................,+*::?##@S::%??;,::::,,;S#####?,,::;;;%;......................................................................
19 | .....................................................................;*;,+S###%,:%??::?SSS%%SS#######SS%SS%:,?+.....................................................................
20 | ...................................................................:*;,+S####?,;%%*,+S#####################S;,*+....................................................................
21 | .................................................................:*+::%##S##*,+%?+,*#SSSSSSSSSSSSSSSSSSSSSSSS+,**,..................................................................
22 | ...............................................................,+*::?#SSSS#+,*%%;,?#SSSSS?*?#SSSSSSS##%SSSSSSS*,+*,.................................................................
23 | .............................................................,+*:,*SSSSSSS;,?S?::%SSSSSS*,.*@SSSSSSS@S.+SSSSSSS?,;?:.........................................................,;;;;;:
24 | ............................................................;*;,+SSSSSS#S::%S?,.???%??%+,.,%#%SSSSSS#S..+SSSSSSS%,:?:.......................................................:%;;;;;S
25 | ..........................................................:*+,;%#S%%%%#%,:%?%;:;;;;;:,,,:,,S#%%%%%%S@S,..,;++;;++;:;S;.....................................................,?+,?S+.%
26 | ++:::::::::::::::::::::::::::;;.........................:*+,:?SS%%%%%#?,;%:,::::::+%,.,%S,,@S%%%%%%S@#?+;,:+?%*+;;::;:.....................................................;S.+#S*,%
27 | :?*,,,;+++++++++++++++++++++;,*+......................,+*:,*SS%%%%%S#*,*%,.......;?,+*,S%,;@S%%%%%%S@#%%S%?+;:;++;:.................................,+;...................,%;:%SS*,%
28 | ..+?;.:%#SSSSSSSSSSSSSSSSSSS%;,?;...................,;*;,*SS%%%%%%S#;,??,.......;?,+@S:;:,*@%%%%%%%S@#%%%%%%S%*;:;+*+;,................:*;..........;%S+..................+?.+#%S*,%
29 | ...,+*:.;SS%%%%%%%%%%%%%%%%%%%::?:.................;*;,;%S%%%%%%%SS:,%*........*?,+#SS;..,%#%%%%%%%S@#%%%%%%%%%S%?+;:;+*+:,..........:*+;?*,........;?:*?,...............,S::S%%S*,%
30 | .....:*+,,*SS%%%%%%%%%%%%%%%%S?,+*,..............:*+,:%S%%%%%%%%#%::%+........+?,+#%%#+.,,##%%%%%%%S@#%%%%%%%%%%%%%%%*+::;++;:,....,+*:,;:+?;.......;?:.;%:..............?*,?S%%S*,%
31 | .......+?;.:%#S%%%%%%%%%%%%%%%S*.*+............:++,:?#S%%%%%%%%#?,;%;........+*,+#%%%#?,.,@S%%%%%%%S@#%%%%%%%%%%%%%%%%%%?*;:;+*+::+*;,+%S%;:?*,.....;?:.::?+............;%,:#%%%S*,%
32 | ........,+*:.;SS%%%%%%%%%%%%%%%S+.?;.........,+*:,*SS%%%%%%%%S#*.+%:........+*,*#%%%%S%:.+@%%%%%%%%S@#%%%%%%%%%%%%%%%%%%%%S%?;::;;;,:%S%%%S*,+?;....;?:.#*,??,.........,%+,%S%%%S*,%
33 | ..........:**,,*SS%%%%%%%%%%%%%SS:,?:......,;*;,+SS%%%%%%%%%S#+,*%:.......,**,*#%%%%%%#;.*#%%%%%%%%S@#%%%%%%%%S@##S%%%%%%%%%%%%?*;;?S%%%%%%S%::?*,..;?:.#S?:+%;........+?,+#%%%%S+,%
34 | ...........,;*;.:?#%%%%%%%%%%%%%S%,:%,....;*;,;%S%%%%%%%%%%SS;,*+,.......,**,*#%%%%%%%@+.%#%%%%%%%%%@#%%%%%%%%S@@@@#%%%%%%%%%%%S@@S%????????%S+,+?;.;?:.#%%%;;%+......,%;,S%%%%%S+,%
35 | .............,*?:.+S?????????????S?,;?,.:++,:?S%??????????S@;.;*.........**,*#%???????#?,#S?????????@#????????%@@S????????????S@#%????????????%?::?*;?:.#???%+:?*,....*?,*S?????S;.%
36 | ...............:%+.;S?************S*.+?**:,*S%***********SS%?:,?+......,**,*#?********%%;@?*********@#********?S?***********%@#%***************?%+,+S%:.#?***?*:*?:..:%;,S?*****S;.%
37 | ................,%+.+S*++++++++++++S;,+:,*S?*++++++++++*S%*+?%;,**....,?*.*#?+++++++++*S*#*++++++++*@#*+++++++++++++++++++?#@%*++++++++?*++++++++?*:;+,.#*++++*?:;%;.*?.??++++++S;.%
38 | .................,%;.*%+;++++;;;;;;+S,.;%%+;;;;;;;;;;;*#?;++;+S+,**,.,?+.*#*;++++++++;;#SS++++++++++##+++++++++++++;;;;;*S@%+;;+++;;;+?@S*;;+++++;+?;...#+++++;+*+:?%%,;?+;;;;;;%;.%
39 | ..................:%:,*?;;;;;;;;;;;;*S?%+;;;;;;;;;;;;?S+;;;;;;;%*,**:?+.*#+;;;;;;;;;;;*#@%;;;;;;;;;+##;;;;;;;;;;;;;;;;;?#S*;;;;;;;;;?#@@@@*;;;;;;;;;?*,.#;;;;;;;;**:+;,?*;;;;;;;%;.%
40 | ...................;?:,??::::::::::::*+:::::::::::::%S;::::::::;?*,+%;.?#+::::::::::;%@@@*:::::::::+##;::::::::::::::*S#*:::::::::;S@@@@@@#*:::::::::+?:#:::::::::;*;.+?;:::::::%;.%
41 | ....................;?,,?*::::::::::::::::::::::::;%?:::::*%;::::??,..?#+::::::::::*#@@@@;:::::::::;#S:::::::::::::::%@*::::::::;?@@@@@@@@@@?::::::::::%@:::::::::::**%+::::::::%;.%
42 | .....................+*,,%*::::::::::::::::::::::+S?:::::*@@%;::::*?:?#+:::::::::;%@@@@@@;:::::::::;##;:::::::::::::::?#?:::::::;S@@@@@@@@@@@+::::::::+#@::::::::::::*?:::::::::?;.%
43 | .....................,**,,S+::::::::::::::::::::*S*:;;;:*#@@@S;;;;:*##+:::::::::*#@@@@@@S;:::::::::;##;::::;;;+::::::::?@S+::::::;?@@@@@@@@#*;;:::::;%%*@;::::::::::::::::::::::*:.%
44 | .......................?+.:%*;;;;;;;;;;;;;;;;;+*SS;;;;;+#@@@@@*+++;*S*;;;;;;;;+S@@@@@@@@%+;;;;;;;;;+@#+;;;;;;+%?;;;;;;;;?@@?+;;;;;;*S@@@@@%+;;;;;;;?S*,:@+;;;;++;;;;;;;;;;;;;;;;?;.%
45 | .......................,?;.:S?+++++++++++++*+*?;,?%*+***%@@@@%***+?S?+++++++*%@@@@@@@@@@?++++++++++*@#*++++++*S@?++++++++?#@S*++++++*%@@#?+++++++*S%:..:@*++++?S?+++++++++++++++%;.%
46 | ........................:%;.;S?*************??:,:.*S????*%@@%???*?#%*???????#@@@@@@####@?*??????????@#?*????*?S@#?*****?**?#@@%*????**?%?*??????%S+,**,:@???*%?:*%???***********%;.%
47 | .........................:%:.;#%%%%%%%%%%%%%?,;%?+.;SS%%%%%%%%%%%#S%%%%%%%%SSS%%%%%%%?S#%%%%%%%%%%%%@@%%%%%%%%S@@#%%%%%%%%%%#@@S%%%%%%%%%%%%%%%#%::*%*,:@%%%S?,,,;S%%%%%%%%%%%%%S;.%
48 | ..........................:%:.+#SSSSSSSSSSS*,+?,,**,:%#SSSSSSSSS@#SSSSSSSSSS%SSSSSSSSS##SSSSSSSSSS%S@@SSSSSSSSS@@@#SSSSSSSSSS#@@@SS%SSSSSSS%S##+,+*,;*,:@SSSS:,%%::%SSSSSSSSSSSSS;.S
49 | ...........................:%,.*#SSSSSSSSS+,**,...+?:,?#SSSSSS#@#SSSSSSSSSSSSSSSSSSSS#@#SSSSSSSSSSS#@@SSSSSSSS#@@@@#SSSSSSSSSS#@@@@SSSSSSSS##?,:*+..;+,:@SS#;,%+;%;,?#SSSSSSSSSS#:.#
50 | ............................;?,.?@######S;,?+......:?;.+##S#S#@#S####################@@#S###########@@#SSSSSSS#@@@@@#SSSSSSSSSS#@@@@##S#S#@S;,+*:...;+,:@##*,?*,.,?*,+##SSSSSSS##:.#
51 | .............................+?,,%@####%::?;........,*+.;S###@@#####################@@@#############@@#########@@@@@@############@@@@@###@?,:?+.....;+,:@@?,*?,....*?,;S#########:.#
52 | .............................,**,,%@##?,;?:...........+*,,%@#%%%%%%%%%%%%%%%%%%%%%%%%S@#############@#########################@@@@@@@@@#S+,+?:......;+,,?*,+%,......;?::%########;.#
53 | ..............................,*+.,%@*,+*,.............;?:,+:.,,,,,,,,,,,,,,,,,,,,...;##############%,::::::::::::::::::::::::;;;;;;;;;:,:*+,.......;*+;;;+?:........;%+,?######S:.#
54 | ...............................,?+.,;,**,...............:?+.,*;;;;;;;;;;;;;;;;;;;+?,.*@@@@@@@@@@@@@@?..**;;;;;;;;;;;;;;;;::::::::::::::::+:.........,::::::,..........:?*,+#@@@@%:.#
55 | ................................,%;.,?+..................,**?;...................,#..+@@@@@@@@@@@@@@?..*+..............................................................,*?,:S@@@%:.#
56 | .................................:%+?:.....................;:....................,++,.+#@@@@@@@@@@@@S..*;................................................................;%:,%@@%:.#
57 | ..................................:+,..............................................;?:.:S@@@@@@@@@@@%..*+.................................................................:%+,*@S:.#
58 | ....................................................................................:?;.,%@@@@@@@@@@+.:?:..................................................................,?*,+?:.#
59 | .....................................................................................,?+.,?@@@@@@@@%,;?;....................................................................,*?:.,.#
60 | ......................................................................................,**,.+@@@@@@*,;?:.......................................................................;%;..#
61 | ........................................................................................;?:.;#@@#+.+?,.........................................................................:%+.#
62 | .........................................................................................:?;.:S#;.*?,...........................................................................,?*#
63 | ..........................................................................................,**,,,,**..............................................................................,*S
64 | ............................................................................................+?,,?+.................................................................................,
65 | .............................................................................................;?%;...................................................................................
66 | 
67 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, see . 308 | 309 | Also add information on how to contact you by electronic and paper mail. 310 | 311 | If the program is interactive, make it output a short notice like this 312 | when it starts in an interactive mode: 313 | 314 | Gnomovision version 69, Copyright (C) year name of author 315 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 316 | This is free software, and you are welcome to redistribute it 317 | under certain conditions; type `show c' for details. 318 | 319 | The hypothetical commands `show w' and `show c' should show the appropriate 320 | parts of the General Public License. Of course, the commands you use may 321 | be called something other than `show w' and `show c'; they could even be 322 | mouse-clicks or menu items--whatever suits your program. 323 | 324 | You should also get your employer (if you work as a programmer) or your 325 | school, if any, to sign a "copyright disclaimer" for the program, if 326 | necessary. Here is a sample; alter the names: 327 | 328 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 329 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 330 | 331 | , 1 April 1989 332 | Moe Ghoul, President of Vice 333 | 334 | This General Public License does not permit incorporating your program into 335 | proprietary programs. If your program is a subroutine library, you may 336 | consider it more useful to permit linking proprietary applications with the 337 | library. If this is what you want to do, use the GNU Lesser General 338 | Public License instead of this License. 339 | -------------------------------------------------------------------------------- /includes/class-admin-settings.php: -------------------------------------------------------------------------------- 1 | get_default_settings(); 94 | update_site_option( $this->option_name, $options ); 95 | update_site_option( 'aspireupdate-reset', 'true' ); 96 | 97 | wp_safe_redirect( 98 | add_query_arg( 99 | [ 100 | 'reset-success' => 'success', 101 | 'reset-success-nonce' => wp_create_nonce( 'aspireupdate-reset-success-nonce' ), 102 | 103 | ], 104 | network_admin_url( 'index.php?page=aspireupdate-settings' ) 105 | ) 106 | ); 107 | ! defined( 'AP_RUN_TESTS' ) && exit; 108 | } 109 | } 110 | 111 | /** 112 | * Delete all settings. 113 | * 114 | * @return void 115 | */ 116 | public function delete_all_settings() { 117 | delete_site_option( $this->option_name ); 118 | } 119 | 120 | /** 121 | * Show Admin notices. 122 | * 123 | * @return void 124 | */ 125 | public function admin_notices() { 126 | /** 127 | * The Admin Notice to convey a Reset Operation has happened. 128 | */ 129 | if ( 130 | ( 'true' === get_site_option( 'aspireupdate-reset' ) ) && 131 | isset( $_GET['reset-success'] ) && 132 | ( 'success' === $_GET['reset-success'] ) && 133 | isset( $_GET['reset-success-nonce'] ) && 134 | wp_verify_nonce( sanitize_key( $_GET['reset-success-nonce'] ), 'aspireupdate-reset-success-nonce' ) 135 | ) { 136 | add_settings_error( 137 | $this->option_name, 138 | 'aspireupdate_settings_reset', 139 | esc_html__( 'Settings have been reset to default.', 'aspireupdate' ), 140 | 'success' 141 | ); 142 | settings_errors( $this->option_name ); 143 | delete_site_option( 'aspireupdate-reset' ); 144 | } 145 | 146 | /** 147 | * The Admin Notice to convey settings have been successsfully saved. 148 | */ 149 | if ( 150 | isset( $_GET['settings-updated-wpnonce'] ) && 151 | wp_verify_nonce( sanitize_key( wp_unslash( $_GET['settings-updated-wpnonce'] ) ), 'aspireupdate-settings-updated-nonce' ) 152 | ) { 153 | add_settings_error( 154 | $this->option_name, 155 | 'aspireupdate_settings_saved', 156 | esc_html__( 'Settings Saved', 'aspireupdate' ), 157 | 'success' 158 | ); 159 | settings_errors( $this->option_name ); 160 | } 161 | } 162 | 163 | /** 164 | * Get the value of a Setting by giving priority to hard coded values. 165 | * 166 | * @param string $setting_name The name of the settings field. 167 | * @param mixed $default_value The Default value to return if the field is not defined. 168 | * 169 | * @return string The value of the settings field. 170 | */ 171 | public function get_setting( $setting_name, $default_value = false ) { 172 | if ( null === $this->options ) { 173 | $options = get_site_option( $this->option_name, false ); 174 | /** 175 | * If the options are not set load defaults. 176 | */ 177 | if ( false === $options ) { 178 | $options = $this->get_default_settings(); 179 | update_site_option( $this->option_name, $options ); 180 | } 181 | $config_file_options = $this->get_settings_from_config_file(); 182 | if ( is_array( $options ) ) { 183 | /** 184 | * If User Options are saved do some processing to make it match the structure of the data from the config file. 185 | */ 186 | if ( isset( $options['api_host'] ) && ( 'other' === $options['api_host'] ) ) { 187 | $options['api_host'] = $options['api_host_other']; 188 | } 189 | 190 | if ( isset( $options['enable_debug_type'] ) && is_array( $options['enable_debug_type'] ) ) { 191 | $debug_types = []; 192 | foreach ( $options['enable_debug_type'] as $debug_type_name => $debug_type_enabled ) { 193 | if ( $debug_type_enabled ) { 194 | $debug_types[] = $debug_type_name; 195 | } 196 | } 197 | $options['enable_debug_type'] = $debug_types; 198 | } 199 | $this->options = wp_parse_args( $config_file_options, $options ); 200 | } 201 | } 202 | return $this->options[ $setting_name ] ?? $default_value; 203 | } 204 | 205 | /** 206 | * Get the values defined in the config file. 207 | * 208 | * @return array An array of values as defined in the Config File. 209 | */ 210 | private function get_settings_from_config_file() { 211 | $options = []; 212 | 213 | if ( ! defined( 'AP_ENABLE' ) ) { 214 | define( 'AP_ENABLE', false ); 215 | } elseif ( AP_ENABLE ) { 216 | $options['enable'] = AP_ENABLE; 217 | } 218 | 219 | if ( ! defined( 'AP_HOST' ) ) { 220 | define( 'AP_HOST', '' ); 221 | } else { 222 | $options['api_host'] = AP_HOST; 223 | } 224 | 225 | if ( ! defined( 'AP_API_KEY' ) ) { 226 | define( 'AP_API_KEY', '' ); 227 | } else { 228 | $options['api_key'] = AP_API_KEY; 229 | } 230 | 231 | if ( ! defined( 'AP_DEBUG' ) ) { 232 | define( 'AP_DEBUG', false ); 233 | } elseif ( AP_DEBUG ) { 234 | $options['enable_debug'] = AP_DEBUG; 235 | } 236 | 237 | if ( ! defined( 'AP_DEBUG_TYPES' ) ) { 238 | define( 'AP_DEBUG_TYPES', [] ); 239 | } elseif ( is_array( AP_DEBUG_TYPES ) ) { 240 | $options['enable_debug_type'] = AP_DEBUG_TYPES; 241 | } 242 | 243 | if ( ! defined( 'AP_DISABLE_SSL' ) ) { 244 | define( 'AP_DISABLE_SSL', false ); 245 | } elseif ( AP_DISABLE_SSL ) { 246 | $options['disable_ssl_verification'] = AP_DISABLE_SSL; 247 | } 248 | 249 | return $options; 250 | } 251 | 252 | /** 253 | * Update settings for single site or network activated. 254 | * 255 | * @link http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message 256 | * @link http://benohead.com/wordpress-network-wide-plugin-settings/ 257 | * 258 | * @return void 259 | */ 260 | public function update_settings() { 261 | // Exit if improper privileges. 262 | if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'aspireupdate-settings' ) ) { 263 | return; 264 | } 265 | 266 | // Save settings and redirect. 267 | if ( ( isset( $_POST['option_page'], $_POST['aspireupdate_settings'] ) && 'aspireupdate_settings' === $_POST['option_page'] ) ) { 268 | update_site_option( 269 | $this->option_name, 270 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Contents are sanitized in Admin_Settings::sanitize_settings. 271 | $this->sanitize_settings( wp_unslash( $_POST['aspireupdate_settings'] ) ) 272 | ); 273 | 274 | wp_safe_redirect( 275 | add_query_arg( 276 | [ 277 | 'settings-updated-wpnonce' => wp_create_nonce( 'aspireupdate-settings-updated-nonce' ), 278 | ], 279 | network_admin_url( 'index.php?page=aspireupdate-settings' ) 280 | ) 281 | ); 282 | ! defined( 'AP_RUN_TESTS' ) && exit; 283 | } 284 | } 285 | 286 | /** 287 | * Register the Admin Menu. 288 | * 289 | * @return void 290 | */ 291 | public function register_admin_menu() { 292 | if ( ! defined( 'AP_REMOVE_UI' ) ) { 293 | define( 'AP_REMOVE_UI', false ); 294 | } 295 | if ( false === AP_REMOVE_UI ) { 296 | add_submenu_page( 297 | 'index.php', 298 | 'AspireUpdate', 299 | 'AspireUpdate', 300 | is_multisite() ? 'manage_network_options' : 'manage_options', 301 | 'aspireupdate-settings', 302 | [ $this, 'the_settings_page' ] 303 | ); 304 | } 305 | } 306 | 307 | /** 308 | * Enqueue the Scripts and Styles. 309 | * 310 | * @param string $hook The page identifier. 311 | * @return void 312 | */ 313 | public function admin_enqueue_scripts( $hook ) { 314 | 315 | if ( ! in_array( $hook, [ 'dashboard_page_aspireupdate-settings', 'index_page_aspireupdate-settings' ], true ) ) { 316 | 317 | return; 318 | } 319 | wp_enqueue_style( 'aspire_update_settings_css', plugin_dir_url( __DIR__ ) . 'assets/css/aspire-update.css', [], AP_VERSION ); 320 | wp_enqueue_script( 'aspire_update_settings_js', plugin_dir_url( __DIR__ ) . 'assets/js/aspire-update.js', [ 'jquery' ], AP_VERSION, true ); 321 | wp_localize_script( 322 | 'aspire_update_settings_js', 323 | 'aspireupdate', 324 | [ 325 | 'ajax_url' => network_admin_url( 'admin-ajax.php' ), 326 | 'nonce' => wp_create_nonce( 'aspireupdate-ajax' ), 327 | 'domain' => Utilities::get_site_domain(), 328 | 'line_ending' => PHP_EOL, 329 | 'unexpected_error' => esc_html__( 'Unexpected Error', 'aspireupdate' ), 330 | ] 331 | ); 332 | } 333 | 334 | /** 335 | * The Settings Page Markup. 336 | * 337 | * @return void 338 | */ 339 | public function the_settings_page() { 340 | $reset_url = add_query_arg( 341 | [ 342 | 'reset' => 'reset', 343 | 'reset-nonce' => wp_create_nonce( 'aspireupdate-reset-nonce' ), 344 | 345 | ], 346 | network_admin_url( 'index.php?page=aspireupdate-settings' ) 347 | ); 348 | Utilities::include_file( 349 | 'page-admin-settings.php', 350 | [ 351 | 'reset_url' => $reset_url, 352 | 'option_group' => $this->option_group, 353 | ] 354 | ); 355 | } 356 | 357 | /** 358 | * Register all Settings. 359 | * 360 | * @return void 361 | */ 362 | public function register_settings() { 363 | $nonce = wp_create_nonce( 'aspireupdate-settings' ); 364 | $options = get_site_option( $this->option_name, false ); 365 | /** 366 | * If the options are not set load defaults. 367 | */ 368 | if ( false === $options ) { 369 | $options = $this->get_default_settings(); 370 | update_site_option( $this->option_name, $options ); 371 | } 372 | 373 | register_setting( 374 | $this->option_group, 375 | $this->option_name, 376 | [ 377 | 'sanitize_callback' => [ $this, 'sanitize_settings' ], 378 | ] 379 | ); 380 | 381 | add_settings_section( 382 | 'aspireupdate_settings_section', 383 | esc_html__( 'API Configuration', 'aspireupdate' ), 384 | null, 385 | 'aspireupdate-settings', 386 | [ 387 | 'before_section' => '
', 388 | 'after_section' => '
', 389 | ] 390 | ); 391 | 392 | add_settings_field( 393 | 'enable', 394 | esc_html__( 'Enable AspireUpdate API Rewrites', 'aspireupdate' ), 395 | [ $this, 'add_settings_field_callback' ], 396 | 'aspireupdate-settings', 397 | 'aspireupdate_settings_section', 398 | [ 399 | 'id' => 'enable', 400 | 'type' => 'checkbox', 401 | 'data' => $options, 402 | ] 403 | ); 404 | 405 | add_settings_field( 406 | 'api_host', 407 | esc_html__( 'API Host', 'aspireupdate' ), 408 | [ $this, 'add_settings_field_callback' ], 409 | 'aspireupdate-settings', 410 | 'aspireupdate_settings_section', 411 | [ 412 | 'id' => 'api_host', 413 | 'type' => 'hosts', 414 | 'data' => $options, 415 | 'description' => esc_html__( 'Your new API Host.', 'aspireupdate' ), 416 | 'options' => [ 417 | [ 418 | 'value' => 'api.aspirecloud.org', 419 | 'label' => 'AspireCloud (api.aspirecloud.org)', 420 | 'require-api-key' => 'false', 421 | 'api-key-url' => 'api.aspirecloud.org/v1/apitoken', 422 | ], 423 | [ 424 | 'value' => 'other', 425 | 'label' => esc_html__( 'Other', 'aspireupdate' ), 426 | 'require-api-key' => 'false', 427 | ], 428 | ], 429 | ] 430 | ); 431 | 432 | add_settings_field( 433 | 'api_key', 434 | esc_html__( 'API Key', 'aspireupdate' ), 435 | [ $this, 'add_settings_field_callback' ], 436 | 'aspireupdate-settings', 437 | 'aspireupdate_settings_section', 438 | [ 439 | 'id' => 'api_key', 440 | 'type' => 'api-key', 441 | 'data' => $options, 442 | 'description' => esc_html__( 'Provides an API key for repositories that may require authentication.', 'aspireupdate' ), 443 | ] 444 | ); 445 | 446 | add_settings_section( 447 | 'aspireupdate_debug_settings_section', 448 | esc_html__( 'API Debug Configuration', 'aspireupdate' ), 449 | null, 450 | 'aspireupdate-settings', 451 | [ 452 | 'before_section' => '
', 453 | 'after_section' => '
', 454 | ] 455 | ); 456 | 457 | add_settings_field( 458 | 'enable_debug', 459 | esc_html__( 'Enable Debug Mode', 'aspireupdate' ), 460 | [ $this, 'add_settings_field_callback' ], 461 | 'aspireupdate-settings', 462 | 'aspireupdate_debug_settings_section', 463 | [ 464 | 'id' => 'enable_debug', 465 | 'type' => 'checkbox', 466 | 'data' => $options, 467 | 'description' => esc_html__( 'Enables debug mode for the plugin.', 'aspireupdate' ), 468 | ] 469 | ); 470 | 471 | add_settings_field( 472 | 'enable_debug_type', 473 | esc_html__( 'Enable Debug Type', 'aspireupdate' ), 474 | [ $this, 'add_settings_field_callback' ], 475 | 'aspireupdate-settings', 476 | 'aspireupdate_debug_settings_section', 477 | [ 478 | 'id' => 'enable_debug_type', 479 | 'type' => 'checkbox-group', 480 | 'data' => $options, 481 | 'options' => [ 482 | 'request' => esc_html__( 'Request', 'aspireupdate' ), 483 | 'response' => esc_html__( 'Response', 'aspireupdate' ), 484 | 'string' => esc_html__( 'String', 'aspireupdate' ), 485 | ], 486 | 'description' => esc_html__( 'Outputs the request URL and headers / response headers and body / string that is being rewritten.', 'aspireupdate' ), 487 | ] 488 | ); 489 | 490 | add_settings_field( 491 | 'disable_ssl_verification', 492 | esc_html__( 'Disable SSL Verification', 'aspireupdate' ), 493 | [ $this, 'add_settings_field_callback' ], 494 | 'aspireupdate-settings', 495 | 'aspireupdate_debug_settings_section', 496 | [ 497 | 'id' => 'disable_ssl_verification', 498 | 'type' => 'checkbox', 499 | 'data' => $options, 500 | 'class' => 'advanced-setting', 501 | 'description' => esc_html__( 'Disables the verification of SSL to allow local testing.', 'aspireupdate' ), 502 | ] 503 | ); 504 | } 505 | 506 | /** 507 | * The Fields API which any CMS should have in its core but something we dont, hence this ugly hack. 508 | * 509 | * @param array $args The Field Parameters. 510 | * 511 | * @return void Echos the Field HTML. 512 | */ 513 | public function add_settings_field_callback( $args = [] ) { 514 | 515 | $defaults = [ 516 | 'id' => '', 517 | 'type' => 'text', 518 | 'description' => '', 519 | 'data' => [], 520 | 'options' => [], 521 | ]; 522 | $args = wp_parse_args( $args, $defaults ); 523 | $id = $args['id']; 524 | $type = $args['type']; 525 | $description = $args['description']; 526 | $group_options = $args['options']; 527 | $options = $args['data']; 528 | 529 | echo '
'; 530 | switch ( $type ) { 531 | case 'text': 532 | ?> 533 | 534 | 539 | 540 | 545 | /> 546 | $label ) { 551 | ?> 552 |

553 | 556 |

557 | 563 | 564 | 565 |

566 | 571 | 587 |

588 | 595 |

596 | ' . esc_html( $description ) . '

'; 600 | echo '
'; 601 | } 602 | 603 | /** 604 | * Sanitize the Inputs. 605 | * 606 | * @param array $input The Input values. 607 | * @return array The processed Input. 608 | */ 609 | public function sanitize_settings( $input ) { 610 | $sanitized_input = []; 611 | 612 | $sanitized_input['enable'] = (int) ! empty( $input['enable'] ); 613 | $sanitized_input['api_key'] = sanitize_text_field( $input['api_key'] ?? '' ); 614 | $sanitized_input['api_host'] = sanitize_text_field( $input['api_host'] ?? '' ); 615 | $sanitized_input['api_host_other'] = sanitize_text_field( $input['api_host_other'] ?? '' ); 616 | 617 | $sanitized_input['enable_debug'] = (int) ! empty( $input['enable_debug'] ); 618 | if ( isset( $input['enable_debug_type'] ) && is_array( $input['enable_debug_type'] ) ) { 619 | $sanitized_input['enable_debug_type'] = array_map( 'sanitize_text_field', $input['enable_debug_type'] ); 620 | } else { 621 | $sanitized_input['enable_debug_type'] = []; 622 | } 623 | $sanitized_input['disable_ssl_verification'] = (int) ! empty( $input['disable_ssl_verification'] ); 624 | 625 | return $sanitized_input; 626 | } 627 | } 628 | --------------------------------------------------------------------------------