← All changes
|
src/Controllers/Hooks/Settings/class-settings-controller.php
+45
-34
3.0.2
→
4.1.0
View file →
| @@ -8,10 +8,10 @@ | ||
| 8 | 8 | |
| 9 | 9 | namespace SeQura\WC\Controllers\Hooks\Settings; |
| 10 | 10 | |
| 11 | 11 | use SeQura\WC\Controllers\Controller; |
| 12 | -use SeQura\WC\Core\Extension\Infrastructure\Configuration\Configuration; | |
| 13 | -use SeQura\WC\Services\Interface_Logger_Service; | |
| 12 | +use SeQura\WC\Services\Log\Interface_Logger_Service; | |
| 13 | +use SeQura\WC\Services\Service\Interface_Settings_Service; | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Implementation for the settings controller. |
| 17 | 17 | */ |
| @@ -17,13 +17,13 @@ | ||
| 17 | 17 | */ |
| 18 | 18 | class Settings_Controller extends Controller implements Interface_Settings_Controller { |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * Configuration service. | |
| 21 | + * Settings service. | |
| 22 | 22 | * |
| 23 | - * @var Configuration | |
| 23 | + * @var Interface_Settings_Service | |
| 24 | 24 | */ |
| 25 | - private $configuration; | |
| 25 | + private $settings_service; | |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Plugin basename. |
| 29 | 29 | */ |
| @@ -33,50 +33,57 @@ | ||
| 33 | 33 | * Constructor. |
| 34 | 34 | */ |
| 35 | 35 | public function __construct( |
| 36 | 36 | string $templates_path, |
| 37 | - Configuration $configuration, | |
| 37 | + Interface_Settings_Service $settings_service, | |
| 38 | 38 | Interface_Logger_Service $logger, |
| 39 | 39 | string $plugin_basename |
| 40 | 40 | ) { |
| 41 | 41 | parent::__construct( $logger, $templates_path ); |
| 42 | - $this->configuration = $configuration; | |
| 43 | - $this->plugin_basename = $plugin_basename; | |
| 42 | + $this->settings_service = $settings_service; | |
| 43 | + $this->plugin_basename = $plugin_basename; | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Register the settings page. |
| 48 | + * | |
| 49 | + * @return void | |
| 48 | 50 | */ |
| 49 | - public function register_page(): void { | |
| 50 | - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 51 | - add_submenu_page( | |
| 52 | - $this->configuration->get_parent_page(), | |
| 51 | + public function register_page() { | |
| 52 | + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 53 | + \add_submenu_page( | |
| 54 | + $this->settings_service->get_parent_page(), | |
| 53 | 55 | __( 'seQura', 'sequra' ), |
| 54 | 56 | __( 'seQura', 'sequra' ), |
| 55 | 57 | 'manage_options', |
| 56 | - $this->configuration->get_page(), | |
| 58 | + $this->settings_service->get_page(), | |
| 57 | 59 | array( $this, 'render_page' ) |
| 58 | 60 | ); |
| 59 | 61 | |
| 60 | 62 | // Additionally remove WP version footer text if we are in the settings page. |
| 61 | - if ( $this->configuration->is_settings_page() ) { | |
| 62 | - remove_filter( 'update_footer', 'core_update_footer' ); | |
| 63 | + if ( $this->settings_service->is_settings_page() ) { | |
| 64 | + \remove_filter( 'update_footer', 'core_update_footer' ); | |
| 63 | 65 | } |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | /** |
| 67 | 69 | * Render the settings page. |
| 70 | + * | |
| 71 | + * @return void | |
| 68 | 72 | */ |
| 69 | - public function render_page(): void { | |
| 70 | - $this->logger->log_info( 'Callback executed', __FUNCTION__, __CLASS__ ); | |
| 71 | - wc_get_template( 'admin/settings_page.php', array(), '', $this->templates_path ); | |
| 73 | + public function render_page() { | |
| 74 | + $this->logger->log_debug( 'Callback executed', __FUNCTION__, __CLASS__ ); | |
| 75 | + \wc_get_template( 'admin/settings_page.php', array(), '', $this->templates_path ); | |
| 72 | 76 | } |
| 73 | 77 | |
| 74 | 78 | /** |
| 75 | 79 | * Get the settings page URL. |
| 80 | + * | |
| 81 | + * @param string|null $url The URL. | |
| 82 | + * @return string | |
| 76 | 83 | */ |
| 77 | - public function get_settings_page_url( ?string $url = null ): string { | |
| 78 | - return admin_url( 'admin.php?page=' . $this->configuration->get_page() ); | |
| 84 | + public function get_settings_page_url( $url = null ) { | |
| 85 | + return \admin_url( 'admin.php?page=' . $this->settings_service->get_page() ); | |
| 79 | 86 | } |
| 80 | 87 | |
| 81 | 88 | /** |
| 82 | 89 | * Add action links to the plugin settings page. |
| @@ -84,18 +91,18 @@ | ||
| 84 | 91 | * @param string[] $actions The actions. |
| 85 | 92 | * @param string $plugin_file The plugin file. |
| 86 | 93 | * @param string $plugin_data The plugin data. |
| 87 | 94 | * @param string $context The context. |
| 88 | - * @return mixed[] | |
| 95 | + * @return string[] | |
| 89 | 96 | */ |
| 90 | - public function add_action_link( $actions, $plugin_file, $plugin_data, $context ): array { | |
| 91 | - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 97 | + public function add_action_link( $actions, $plugin_file, $plugin_data, $context ) { | |
| 98 | + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 92 | 99 | $args = array( |
| 93 | 100 | 'href' => $this->get_settings_page_url(), |
| 94 | 101 | 'text' => esc_attr__( 'Settings', 'sequra' ), |
| 95 | 102 | ); |
| 96 | 103 | ob_start(); |
| 97 | - wc_get_template( 'admin/action_link.php', $args, '', $this->templates_path ); | |
| 104 | + \wc_get_template( 'admin/action_link.php', $args, '', $this->templates_path ); | |
| 98 | 105 | $actions['settings'] = ob_get_clean(); |
| 99 | 106 | return $actions; |
| 100 | 107 | } |
| 101 | 108 | |
| @@ -100,12 +107,15 @@ | ||
| 100 | 107 | } |
| 101 | 108 | |
| 102 | 109 | /** |
| 103 | 110 | * Removes the WP footer message |
| 111 | + * | |
| 112 | + * @param string $text The footer text. | |
| 113 | + * @return string | |
| 104 | 114 | */ |
| 105 | - public function remove_footer_admin( string $text ): string { | |
| 106 | - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 107 | - if ( ! $this->configuration->is_settings_page() ) { | |
| 115 | + public function remove_footer_admin( $text ) { | |
| 116 | + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 117 | + if ( ! $this->settings_service->is_settings_page() ) { | |
| 108 | 118 | return $text; |
| 109 | 119 | } |
| 110 | 120 | return ''; |
| 111 | 121 | } |
| @@ -114,21 +124,22 @@ | ||
| 114 | 124 | * Show row meta on the plugin screen. |
| 115 | 125 | * |
| 116 | 126 | * @param array $links Plugin Row Meta. |
| 117 | 127 | * @param string $file Plugin Base file. |
| 128 | + * @return string[] | |
| 118 | 129 | */ |
| 119 | - public function add_plugin_row_meta( $links, $file ): array { | |
| 130 | + public function add_plugin_row_meta( $links, $file ) { | |
| 120 | 131 | if ( $this->plugin_basename === $file ) { |
| 121 | 132 | $row_meta = array( |
| 122 | 133 | 'docs' => sprintf( |
| 123 | 134 | '<a href="%s" aria-label="%s" target="_blank">%s</a>', |
| 124 | - esc_url( | |
| 135 | + \esc_url( | |
| 125 | 136 | /** |
| 126 | 137 | * Filters the URL of the plugin documentation. |
| 127 | 138 | * |
| 128 | 139 | * @since 2.0.0 |
| 129 | 140 | */ |
| 130 | - apply_filters( 'sequrapayment_docs_url', 'https://sequra.atlassian.net/wiki/spaces/DOC/pages/2247524378/WOOCOMMERCE' ) | |
| 141 | + \apply_filters( 'sequrapayment_docs_url', 'https://sequra.atlassian.net/wiki/spaces/DOC/pages/2247524378/WOOCOMMERCE' ) | |
| 131 | 142 | ), |
| 132 | 143 | esc_attr__( 'View WooCommerce documentation', 'sequra' ), |
| 133 | 144 | esc_html__( 'Docs', 'woocommerce' ) |
| 134 | 145 | ), |
| @@ -133,15 +144,15 @@ | ||
| 133 | 144 | esc_html__( 'Docs', 'woocommerce' ) |
| 134 | 145 | ), |
| 135 | 146 | 'apidocs' => sprintf( |
| 136 | 147 | '<a href="%s" aria-label="%s" target="_blank">%s</a>', |
| 137 | - esc_url( | |
| 148 | + \esc_url( | |
| 138 | 149 | /** |
| 139 | 150 | * Filters the URL of the plugin API documentation. |
| 140 | 151 | * |
| 141 | 152 | * @since 2.0.0 |
| 142 | 153 | */ |
| 143 | - apply_filters( 'sequrapayment_apidocs_url', 'https://docs.sequrapi.com/' ) | |
| 154 | + \apply_filters( 'sequrapayment_apidocs_url', 'https://docs.sequrapi.com/' ) | |
| 144 | 155 | ), |
| 145 | 156 | esc_attr__( 'View WooCommerce API docs', 'sequra' ), |
| 146 | 157 | esc_html__( 'API docs', 'sequra' ) |
| 147 | 158 | ), |
| @@ -146,15 +157,15 @@ | ||
| 146 | 157 | esc_html__( 'API docs', 'sequra' ) |
| 147 | 158 | ), |
| 148 | 159 | 'support' => sprintf( |
| 149 | 160 | '<a href="%s" aria-label="%s" target="_blank">%s</a>', |
| 150 | - esc_url( | |
| 161 | + \esc_url( | |
| 151 | 162 | /** |
| 152 | 163 | * Filters the URL of the plugin support. |
| 153 | 164 | * |
| 154 | 165 | * @since 2.0.0 |
| 155 | 166 | */ |
| 156 | - apply_filters( 'sequrapayment_support_url', 'https://sequra.atlassian.net/servicedesk/customer/portal/5/group/-1' ) | |
| 167 | + \apply_filters( 'sequrapayment_support_url', 'https://sequra.atlassian.net/servicedesk/customer/portal/5/group/-1' ) | |
| 157 | 168 | ), |
| 158 | 169 | esc_attr__( 'Support', 'sequra' ), |
| 159 | 170 | esc_html__( 'Support', 'sequra' ) |
| 160 | 171 | ), |