← All changes
|
src/Controllers/Hooks/Settings/class-settings-controller.php
+27
-27
3.0.5
→
4.3.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,15 +33,15 @@ | ||
| 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,21 +48,21 @@ | ||
| 48 | 48 | * |
| 49 | 49 | * @return void |
| 50 | 50 | */ |
| 51 | 51 | public function register_page() { |
| 52 | - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 53 | - add_submenu_page( | |
| 54 | - $this->configuration->get_parent_page(), | |
| 52 | + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 53 | + \add_submenu_page( | |
| 54 | + $this->settings_service->get_parent_page(), | |
| 55 | 55 | __( 'seQura', 'sequra' ), |
| 56 | 56 | __( 'seQura', 'sequra' ), |
| 57 | 57 | 'manage_options', |
| 58 | - $this->configuration->get_page(), | |
| 58 | + $this->settings_service->get_page(), | |
| 59 | 59 | array( $this, 'render_page' ) |
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | 62 | // Additionally remove WP version footer text if we are in the settings page. |
| 63 | - if ( $this->configuration->is_settings_page() ) { | |
| 64 | - remove_filter( 'update_footer', 'core_update_footer' ); | |
| 63 | + if ( $this->settings_service->is_settings_page() ) { | |
| 64 | + \remove_filter( 'update_footer', 'core_update_footer' ); | |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
| @@ -70,10 +70,10 @@ | ||
| 70 | 70 | * |
| 71 | 71 | * @return void |
| 72 | 72 | */ |
| 73 | 73 | public function render_page() { |
| 74 | - $this->logger->log_info( 'Callback executed', __FUNCTION__, __CLASS__ ); | |
| 75 | - wc_get_template( 'admin/settings_page.php', array(), '', $this->templates_path ); | |
| 74 | + $this->logger->log_debug( 'Callback executed', __FUNCTION__, __CLASS__ ); | |
| 75 | + \wc_get_template( 'admin/settings_page.php', array(), '', $this->templates_path ); | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Get the settings page URL. |
| @@ -81,9 +81,9 @@ | ||
| 81 | 81 | * @param string|null $url The URL. |
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | public function get_settings_page_url( $url = null ) { |
| 85 | - return admin_url( 'admin.php?page=' . $this->configuration->get_page() ); | |
| 85 | + return \admin_url( 'admin.php?page=' . $this->settings_service->get_page() ); | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Add action links to the plugin settings page. |
| @@ -94,15 +94,15 @@ | ||
| 94 | 94 | * @param string $context The context. |
| 95 | 95 | * @return string[] |
| 96 | 96 | */ |
| 97 | 97 | public function add_action_link( $actions, $plugin_file, $plugin_data, $context ) { |
| 98 | - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 98 | + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 99 | 99 | $args = array( |
| 100 | 100 | 'href' => $this->get_settings_page_url(), |
| 101 | 101 | 'text' => esc_attr__( 'Settings', 'sequra' ), |
| 102 | 102 | ); |
| 103 | 103 | ob_start(); |
| 104 | - wc_get_template( 'admin/action_link.php', $args, '', $this->templates_path ); | |
| 104 | + \wc_get_template( 'admin/action_link.php', $args, '', $this->templates_path ); | |
| 105 | 105 | $actions['settings'] = ob_get_clean(); |
| 106 | 106 | return $actions; |
| 107 | 107 | } |
| 108 | 108 | |
| @@ -112,10 +112,10 @@ | ||
| 112 | 112 | * @param string $text The footer text. |
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | 115 | public function remove_footer_admin( $text ) { |
| 116 | - $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 117 | - if ( ! $this->configuration->is_settings_page() ) { | |
| 116 | + $this->logger->log_debug( 'Hook executed', __FUNCTION__, __CLASS__ ); | |
| 117 | + if ( ! $this->settings_service->is_settings_page() ) { | |
| 118 | 118 | return $text; |
| 119 | 119 | } |
| 120 | 120 | return ''; |
| 121 | 121 | } |
| @@ -131,15 +131,15 @@ | ||
| 131 | 131 | if ( $this->plugin_basename === $file ) { |
| 132 | 132 | $row_meta = array( |
| 133 | 133 | 'docs' => sprintf( |
| 134 | 134 | '<a href="%s" aria-label="%s" target="_blank">%s</a>', |
| 135 | - esc_url( | |
| 135 | + \esc_url( | |
| 136 | 136 | /** |
| 137 | 137 | * Filters the URL of the plugin documentation. |
| 138 | 138 | * |
| 139 | 139 | * @since 2.0.0 |
| 140 | 140 | */ |
| 141 | - 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' ) | |
| 142 | 142 | ), |
| 143 | 143 | esc_attr__( 'View WooCommerce documentation', 'sequra' ), |
| 144 | 144 | esc_html__( 'Docs', 'woocommerce' ) |
| 145 | 145 | ), |
| @@ -144,15 +144,15 @@ | ||
| 144 | 144 | esc_html__( 'Docs', 'woocommerce' ) |
| 145 | 145 | ), |
| 146 | 146 | 'apidocs' => sprintf( |
| 147 | 147 | '<a href="%s" aria-label="%s" target="_blank">%s</a>', |
| 148 | - esc_url( | |
| 148 | + \esc_url( | |
| 149 | 149 | /** |
| 150 | 150 | * Filters the URL of the plugin API documentation. |
| 151 | 151 | * |
| 152 | 152 | * @since 2.0.0 |
| 153 | 153 | */ |
| 154 | - apply_filters( 'sequrapayment_apidocs_url', 'https://docs.sequrapi.com/' ) | |
| 154 | + \apply_filters( 'sequrapayment_apidocs_url', 'https://docs.sequrapi.com/' ) | |
| 155 | 155 | ), |
| 156 | 156 | esc_attr__( 'View WooCommerce API docs', 'sequra' ), |
| 157 | 157 | esc_html__( 'API docs', 'sequra' ) |
| 158 | 158 | ), |
| @@ -157,15 +157,15 @@ | ||
| 157 | 157 | esc_html__( 'API docs', 'sequra' ) |
| 158 | 158 | ), |
| 159 | 159 | 'support' => sprintf( |
| 160 | 160 | '<a href="%s" aria-label="%s" target="_blank">%s</a>', |
| 161 | - esc_url( | |
| 161 | + \esc_url( | |
| 162 | 162 | /** |
| 163 | 163 | * Filters the URL of the plugin support. |
| 164 | 164 | * |
| 165 | 165 | * @since 2.0.0 |
| 166 | 166 | */ |
| 167 | - 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' ) | |
| 168 | 168 | ), |
| 169 | 169 | esc_attr__( 'Support', 'sequra' ), |
| 170 | 170 | esc_html__( 'Support', 'sequra' ) |
| 171 | 171 | ), |