| Conditions | 23 |
| Paths | 288 |
| Total Lines | 57 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php if ( !defined( 'ABSPATH' ) ) exit; |
||
| 25 | function __construct() { |
||
|
|
|||
| 26 | |||
| 27 | /** Call administration style definition & scripts */ |
||
| 28 | add_action( 'admin_init', array( &$this, 'admin_scripts' ) ); |
||
| 29 | |||
| 30 | $current_step = ( !empty( $_GET['wps-installation-step'] ) ) ? sanitize_title( $_GET['wps-installation-step'] ) : $this->current_installation_step; |
||
| 31 | |||
| 32 | /** Instanciate datas saver components */ |
||
| 33 | $wps_installer_model = new wps_installer_model(); |
||
| 34 | |||
| 35 | $action = !empty( $_POST[ 'action' ] ) ? sanitize_text_field( $_POST[ 'action' ] ) : ''; |
||
| 36 | /** Call datas saver */ |
||
| 37 | if ( !empty( $current_step ) && !empty( $action ) && ( "wps-installation" == $action ) ) { |
||
| 38 | $step_to_save = $current_step - 1; |
||
| 39 | $wps_installer_model->save_step( $step_to_save ); |
||
| 40 | if ( WPSINSTALLER_STEPS_COUNT == $current_step ) { |
||
| 41 | add_action( 'init', array( &$this, 'go_to_wpshop_about' ) ); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | /** Set the current installatino step */ |
||
| 46 | $this->current_installation_step = get_option( 'wps-installation-current-step', 1 ); |
||
| 47 | |||
| 48 | /** Get current version for wpshop plugin */ |
||
| 49 | $wps_current_db_version = get_option( 'wpshop_db_options', 0 ); |
||
| 50 | |||
| 51 | /** Check the configuration state */ |
||
| 52 | $installation_state = !empty( $_GET[ 'installation_state' ] ) ? sanitize_text_field( $_GET[ 'installation_state' ] ) : ''; |
||
| 53 | if ( isset( $installation_state ) && !empty( $installation_state ) && !empty( $wps_current_db_version ) |
||
| 54 | && (empty( $wps_current_db_version[ 'installation_state' ] ) || ( $wps_current_db_version[ 'installation_state' ] != 'completed' ) ) ) { |
||
| 55 | $wps_current_db_version = $wps_installer_model->installer_state_saver( $installation_state, $wps_current_db_version ); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** Do verification for shop who are configured for being sale shop */ |
||
| 59 | $current_page = strstr( $_SERVER[ "REQUEST_URI" ], 'wps-about'); |
||
| 60 | if ( isset( $wps_current_db_version['installation_state'] ) && ( $wps_current_db_version[ 'installation_state' ] == 'completed' ) && ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) && empty( $current_page ) ) { |
||
| 61 | add_action( 'admin_notices', array( 'wpshop_notices' , 'sale_shop_notice' ) ); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** Create an administration menu */ |
||
| 65 | add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
||
| 66 | |||
| 67 | /** In case that configuration have not been done and that instalation is not asked to be ignored */ |
||
| 68 | if ( empty( $wps_current_db_version ) || empty( $wps_current_db_version[ 'installation_state' ] ) || ( !empty( $wps_current_db_version[ 'installation_state' ] ) && !in_array( $wps_current_db_version[ 'installation_state' ], array( 'completed', 'ignored' ) ) ) ) { |
||
| 69 | /* Check the db installation state for admin message output */ |
||
| 70 | $current_page = strstr( $_SERVER[ "REQUEST_URI" ], 'wps-installer'); |
||
| 71 | if( ( WPSINSTALLER_STEPS_COUNT > $this->current_installation_step ) && ( empty( $current_page ) ) ) { |
||
| 72 | add_action( 'admin_notices', array( &$this, 'install_admin_notice' ) ); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | /** Hook wpshop dashboard in order to display the notice banner with quick links - wordpress like */ |
||
| 77 | add_filter( 'wps-dashboard-notice', array( $this, 'wps_dashboard_notice' ), 10, 1 ); |
||
| 78 | |||
| 79 | /** Hook ajax action when clicking on hide welcome banner on wpshop dashboard */ |
||
| 80 | add_action( 'wp_ajax_wps-hide-welcome-panel', array( $this, 'wps_hide_welcome_panel' ) ); |
||
| 81 | } |
||
| 82 | |||
| 227 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.