Conditions | 8 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 18 |
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 |
||
8 | * @var Imgix_Options_page |
||
9 | */ |
||
10 | protected static $instance; |
||
11 | |||
12 | /** |
||
13 | * Plugin options |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $options = []; |
||
18 | |||
19 | |||
20 | public function __construct() { |
||
21 | $this->options = get_option( 'imgix_settings', [] ); |
||
22 | add_action( 'admin_init', [ $this, 'imgix_register_settings' ] ); |
||
23 | add_action( 'admin_menu', [ $this, 'imgix_add_options_link' ] ); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Plugin loader instance. |
||
28 | * |
||
29 | * @return Imgix_Options_page |
||
30 | */ |
||
31 | public static function instance() { |
||
32 | if ( ! isset( self::$instance ) ) { |
||
33 | self::$instance = new self; |
||
34 | } |
||
35 | |||
36 | return self::$instance; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Renders options page |
||
41 | */ |
||
42 | public function imgix_options_page() { |
||
43 | ?> |
||
44 | <div class="wrap"> |
||
45 | |||
46 | <h1> |
||
47 | <img src="<?php echo plugins_url( 'assets/images/imgix-logo.png', __DIR__ ); ?>" alt="imgix Logo"> |
||
48 | </h1> |
||
49 | |||
50 | <p><strong>Need help getting started?</strong> It's easy! Check out our |
||
51 | <a href="https://github.com/imgix-wordpress/imgix-wordpress#getting-started" target="_blank">instructions.</a> |
||
52 | </p> |
||
53 | |||
54 | <form method="post" action="<?php echo admin_url( 'options.php' ); ?>"> |
||
55 | <?php settings_fields( 'imgix_settings_group' ); ?> |
||
56 | <table class="form-table"> |
||
57 | <tbody> |
||
58 | <tr> |
||
59 | <th> |
||
60 | <label class="description" for="imgix_settings[cdn_link]"><?php esc_html_e( 'imgix Source', 'imgix' ); ?> |
||
61 | </th> |
||
134 |