diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a366aa4 Binary files /dev/null and b/.DS_Store differ diff --git a/class-dlm-as-hooks.php b/class-dlm-as-hooks.php index d4902b3..aa61d39 100644 --- a/class-dlm-as-hooks.php +++ b/class-dlm-as-hooks.php @@ -1,9 +1,16 @@ settings['dlm_xhr_progress']['display'] ) ? $this->settings['dlm_xhr_progress']['display'] : $value['display']; + $value['display'] = ! empty( $this->settings['dlm_xhr_progress']['display'] ) ? $this->settings['dlm_xhr_progress']['display'] : $value['display']; $value['animation'] = ! empty( $this->settings['dlm_xhr_progress']['animation'] ) ? $this->settings['dlm_xhr_progress']['animation'] : $value['animation']; - + return $value; } /** * Filter for 404 redirect * - * @param string $value The default value. + * @param string $value The default value. * * @return string * @since 1.0.0 @@ -115,7 +121,7 @@ public function filter_dlm_404_redirect( $value ) { /** * Filter for placeholder image src * - * @param string $value The default value. + * @param string $value The default value. * * @return string * @since 1.0.0 @@ -133,7 +139,7 @@ public function filter_dlm_placeholder_image_src( $value ) { /** * Filer for restricted file types * - * @param array $value The default value. + * @param array $value The default value. * * @return array * @since 1.0.0 @@ -145,7 +151,7 @@ public function filter_dlm_restricted_file_types( array $value ) { } // The new files should be string with every file separated by a comma. Make an array from them. $new_files = explode( ',', $this->settings['dlm_restricted_file_types'] ); - + // Send the merge between $value and $new_files. return array_merge( $value, $new_files ); } @@ -153,7 +159,7 @@ public function filter_dlm_restricted_file_types( array $value ) { /** * Filter for Reports * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 @@ -170,7 +176,7 @@ public function filter_dlm_enable_reports( $value ) { /** * Filter timestamp link * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 @@ -187,7 +193,7 @@ public function filter_dlm_timestamp_link( $value ) { /** * Filter for XHR downloads * - * @param bool $value The default value. + * @param bool $value The default value. * * @return mixed * @since 1.0.0 @@ -204,7 +210,7 @@ public function filter_dlm_do_xhr( $value ) { /** * Filter for meta version in header * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 @@ -221,7 +227,7 @@ public function filter_dlm_count_meta_downloads( $value ) { /** * Filter for meta version in header * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 @@ -233,7 +239,7 @@ public function filter_dlm_hide_meta_version( $value ) { /** * Filter for delete files when deleting a download * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 @@ -250,7 +256,7 @@ public function filter_dlm_delete_files( $value ) { /** * Filter for X-Accel-Redirect / X-Sendfile * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 @@ -267,7 +273,7 @@ public function filter_dlm_x_sendfile( $value ) { /** * Filter for preventing hot linking * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 @@ -284,7 +290,7 @@ public function filter_dlm_hotlink_protection( $value ) { /** * Filter for allowing proxy IP override * - * @param bool $value The default value. + * @param bool $value The default value. * * @return bool * @since 1.0.0 diff --git a/dlm-advanced-settings.php b/dlm-advanced-settings.php index 790950f..93a2940 100644 --- a/dlm-advanced-settings.php +++ b/dlm-advanced-settings.php @@ -7,6 +7,7 @@ Author: raldea89 Author URI: https://github.com/razvanaldea89/ License: GPL v3 + Text Domain: dlm-advanced-settings This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -125,105 +126,105 @@ private function __construct() { $this->hooks = array( 'dlm_delete_files' => array( - 'label' => __( 'Delete files when deleting a download', 'dlm-advanced-settings' ), - 'default' => '0', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'Enabling this will let you automatically delete files associated with a Download upon the Download deletion', 'dlm-advanced-settings' ) + 'label' => __( 'Delete files when deleting a download', 'dlm-advanced-settings' ), + 'default' => '0', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'Enabling this will let you automatically delete files associated with a Download upon the Download deletion', 'dlm-advanced-settings' ), ), 'dlm_hotlink_protection' => array( - 'label' => __( 'Hotlink protection','dlm-advanced-settings' ), - 'default' => '0', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'Enabling this will allow the download handler to check the PHP referer to see if it originated from your site and if not, redirect them to the homepage.', 'dlm-advanced-settings' ) + 'label' => __( 'Hotlink protection', 'dlm-advanced-settings' ), + 'default' => '0', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'Enabling this will allow the download handler to check the PHP referer to see if it originated from your site and if not, redirect them to the homepage.', 'dlm-advanced-settings' ), ), 'dlm_allow_x_forwarded_for' => array( - 'label' => __( 'Allow Proxy IP Override', 'dlm-advanced-settings' ), - 'default' => '0', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'If enabled, Download Monitor will use the X_FORWARDED_FOR HTTP header set by proxies as the IP address. Note that anyone can set this header, making it less secure.', 'dlm-advanced-settings' ) + 'label' => __( 'Allow Proxy IP Override', 'dlm-advanced-settings' ), + 'default' => '0', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'If enabled, Download Monitor will use the X_FORWARDED_FOR HTTP header set by proxies as the IP address. Note that anyone can set this header, making it less secure.', 'dlm-advanced-settings' ), ), 'dlm_x_sendfile' => array( - 'label' => 'Enable X-Accel-Redirect / X-Sendfile', - 'default' => '0', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'If supported, X-Accel-Redirect / X-Sendfile can be used to serve downloads instead of PHP (server requires mod_xsendfile) Attention! Enabling this option will disable the XHR functionality!', 'dlm-advanced-settings' ) + 'label' => 'Enable X-Accel-Redirect / X-Sendfile', + 'default' => '0', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'If supported, X-Accel-Redirect / X-Sendfile can be used to serve downloads instead of PHP (server requires mod_xsendfile) Attention! Enabling this option will disable the XHR functionality!', 'dlm-advanced-settings' ), ), 'dlm_timestamp_link' => array( - 'label' => __( 'Show a timestamp in the download link', 'dlm-advanced-settings' ), - 'default' => '1', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'If enabled, the download URL will have a timestamp attached as a parameter. This serves as a cache preventing solution for plugins that cache the URL.', 'dlm-advanced-settings' ) + 'label' => __( 'Show a timestamp in the download link', 'dlm-advanced-settings' ), + 'default' => '1', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'If enabled, the download URL will have a timestamp attached as a parameter. This serves as a cache preventing solution for plugins that cache the URL.', 'dlm-advanced-settings' ), ), 'dlm_enable_reports' => array( - 'label' => __( 'Enable reports', 'dlm-advanced-settings' ), - 'default' => '1', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'Enable or disable the Reports functionality. This will also enable/disable logging detailed info into the Logs Table of the Database. Disabling this will not disable the download count funtionality.', 'dlm-advanced-settings' ) + 'label' => __( 'Enable reports', 'dlm-advanced-settings' ), + 'default' => '1', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'Enable or disable the Reports functionality. This will also enable/disable logging detailed info into the Logs Table of the Database. Disabling this will not disable the download count funtionality.', 'dlm-advanced-settings' ), ), 'dlm_hide_meta_version' => array( - 'label' => __( 'Hide meta version in header', 'dlm-advanced-settings' ), - 'default' => '0', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'Hide or show Download Monitor\'s version in the HTML\'s head.', 'dlm-advanced-settings' ) + 'label' => __( 'Hide meta version in header', 'dlm-advanced-settings' ), + 'default' => '0', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'Hide or show Download Monitor\'s version in the HTML\'s head.', 'dlm-advanced-settings' ), ), 'dlm_count_meta_downloads' => array( - 'label' => __( 'Add meta value to download count', 'dlm-advanced-settings' ), - 'default' => '1', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'Add the manual download count ( the one set when editing a Download ) to the total download count of a Download', 'dlm-advanced-settings' ) + 'label' => __( 'Add meta value to download count', 'dlm-advanced-settings' ), + 'default' => '1', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'Add the manual download count ( the one set when editing a Download ) to the total download count of a Download', 'dlm-advanced-settings' ), ), 'dlm_do_xhr' => array( - 'label' => __( 'XHR downloads', 'dlm-advanced-settings' ), - 'default' => '1', - 'params' => 1, - 'type' => 'checkbox', - 'description' => __( 'Enable or disable downloading files using the newly XHR functionality. Disabling this may cause the reports to not be so pricise.', 'dlm-advanced-settings' ) + 'label' => __( 'XHR downloads', 'dlm-advanced-settings' ), + 'default' => '1', + 'params' => 1, + 'type' => 'checkbox', + 'description' => __( 'Enable or disable downloading files using the newly XHR functionality. Disabling this may cause the reports to not be so pricise.', 'dlm-advanced-settings' ), ), 'dlm_restricted_file_types' => array( - 'label' => __( 'Restricted file types', 'dlm-advanced-settings' ), - 'default' => '', - 'params' => 2, - 'type' => 'text', - 'description' => __( 'Define extra file types that should be restricted. Each file type needs to be separated by a comma (,). Only input the extension( ex.: txt, pdf ).', 'dlm-advanced-settings' ) + 'label' => __( 'Restricted file types', 'dlm-advanced-settings' ), + 'default' => '', + 'params' => 2, + 'type' => 'text', + 'description' => __( 'Define extra file types that should be restricted. Each file type needs to be separated by a comma (,). Only input the extension( ex.: txt, pdf ).', 'dlm-advanced-settings' ), ), 'dlm_404_redirect' => array( - 'label' => __( '404 redirect URL', 'dlm-advanced-settings' ), - 'default' => '', - 'params' => 1, - 'type' => 'text', - 'description' => __( 'Define a custom 404 redirect for when a Download can\'t be found.', 'dlm-advanced-settings' ) + 'label' => __( '404 redirect URL', 'dlm-advanced-settings' ), + 'default' => '', + 'params' => 1, + 'type' => 'text', + 'description' => __( 'Define a custom 404 redirect for when a Download can\'t be found.', 'dlm-advanced-settings' ), ), 'dlm_placeholder_image_src' => array( - 'label' => __( 'Placeholder image src', 'dlm-advanced-settings' ), - 'default' => download_monitor()->get_plugin_url() . '/assets/images/placeholder.png', - 'params' => 1, - 'type' => 'text', - 'description' => __( 'Define a custom URL for the Download CPT placeholder.', 'dlm-advanced-settings' ) + 'label' => __( 'Placeholder image src', 'dlm-advanced-settings' ), + 'default' => download_monitor()->get_plugin_url() . '/assets/images/placeholder.png', + 'params' => 1, + 'type' => 'text', + 'description' => __( 'Define a custom URL for the Download CPT placeholder.', 'dlm-advanced-settings' ), ), 'dlm_reports_server_limits' => array( - 'label' => __( 'Reports server limits', 'dlm-advanced-access' ), - 'default' => $this->php_info, - 'params' => 1, - 'type' => 'multi_text', - 'description' => __( 'Define other servet limits. Usefull when you have any problems with the Reports not being displayed a possible problem might be your server\'s lack of resources. This way you can control how much data is retrieved in one request.', 'dlm-advanced-settings' ) + 'label' => __( 'Reports server limits', 'dlm-advanced-access' ), + 'default' => $this->php_info, + 'params' => 1, + 'type' => 'multi_text', + 'description' => __( 'Define other servet limits. Usefull when you have any problems with the Reports not being displayed a possible problem might be your server\'s lack of resources. This way you can control how much data is retrieved in one request.', 'dlm-advanced-settings' ), ), 'dlm_xhr_progress' => array( - 'label' => __( 'XHR progress animation', 'dlm-advanced-settings' ), - 'default' => array( + 'label' => __( 'XHR progress animation', 'dlm-advanced-settings' ), + 'default' => array( 'display' => true, 'animation' => includes_url( '/images/spinner.gif' ), ), - 'params' => 1, - 'type' => 'multi_text', - 'description' => __( 'Define whether to display the XHR progress or not. Also, define a custom URL for the loading animation.', 'dlm-advanced-settings' ) + 'params' => 1, + 'type' => 'multi_text', + 'description' => __( 'Define whether to display the XHR progress or not. Also, define a custom URL for the loading animation.', 'dlm-advanced-settings' ), ), ); @@ -244,7 +245,6 @@ private function __construct() { * @since 1.0.0 */ public static function get_instance() { - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof DLM_Advanced_Settings ) ) { self::$instance = new DLM_Advanced_Settings(); } @@ -258,7 +258,7 @@ public static function get_instance() { * @return void * @since 1.0.0 */ - private function set_wp_hooks(){ + private function set_wp_hooks() { add_action( 'admin_init', array( $this, 'register_settings' ) ); add_filter( 'dlm_admin_menu_links', array( $this, 'add_submenu_page' ), 120 ); add_action( 'init', array( $this, 'set_dlm_hooks' ) ); @@ -288,7 +288,7 @@ public function register_settings() { /** * Add the submenu page to the Downloads menu * - * @param array $links The links array. + * @param array $links The links array. * * @since 1.0.0 */ @@ -312,11 +312,15 @@ public function add_submenu_page( $links ) { */ public function render_submenu_page() { ?> -
-

-

functions.php file.' , 'dlm-advanced-settings' ) ); ?>

-
+
+

+

functions.php file.', 'dlm-advanced-settings' ) ); ?>

+ ' . get_submit_button( 'Save Settings' ) . ''; $html .= ''; - echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo wp_kses_post( $html ); ?>
@@ -380,7 +384,8 @@ public function render_submenu_page() { public function dlm_needed() { // Add our WP Notice. ?> -
+

settings ) ) { return; @@ -427,9 +431,9 @@ public function set_dlm_hooks() { /** * Sanitize settings * - * @param array $value The new value. - * @param array $option The option. - * @param array $old_value The old value. + * @param array $value The new value. + * @param array $option The option. + * @param array $old_value The old value. * * @return array * @since 1.0.0 @@ -451,6 +455,7 @@ public function sanitize_settings( $value, $option, $old_value ) { $value[ $key ] = '1'; } } + // Return value. return $value; } diff --git a/readme.txt b/readme.txt index 7e61849..a8d2bd6 100644 --- a/readme.txt +++ b/readme.txt @@ -2,10 +2,10 @@ Contributors: raldea89 Tags: download monitor, filters, hooks, advanced settings Requires at least: 5.4 -Tested up to: 6.3 +Tested up to: 6.4 Stable tag: 1.0.0 License: GPLv3 -Text Domain: - +Text Domain: dlm-advanced-settings Requires PHP: 7.0 Download Monitor is a plugin for uploading and managing downloads, tracking downloads and displaying links.