| Conditions | 2 |
| Paths | 2 |
| Total Lines | 81 |
| Code Lines | 49 |
| 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 |
||
| 43 | public function get_settings() { |
||
| 44 | $settings = array(); |
||
| 45 | |||
| 46 | $current_section = give_get_current_setting_section(); |
||
| 47 | |||
| 48 | switch ( $current_section ) { |
||
| 49 | case 'advanced-options': |
||
| 50 | $settings = array( |
||
| 51 | array( |
||
| 52 | 'id' => 'give_title_data_control_2', |
||
| 53 | 'type' => 'title' |
||
|
|
|||
| 54 | ), |
||
| 55 | array( |
||
| 56 | 'name' => esc_html__( 'Remove Data on Uninstall', 'give' ), |
||
| 57 | 'desc' => esc_html__( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ), |
||
| 58 | 'id' => 'uninstall_on_delete', |
||
| 59 | 'type' => 'radio_inline', |
||
| 60 | 'default' => 'disabled', |
||
| 61 | 'options' => array( |
||
| 62 | 'enabled' => __( 'Yes, Remove all data', 'give' ), |
||
| 63 | 'disabled' => __( 'No, keep my Give settings and donation data', 'give' ), |
||
| 64 | ) |
||
| 65 | ), |
||
| 66 | array( |
||
| 67 | /* translators: %s: the_content */ |
||
| 68 | 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ), |
||
| 69 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
||
| 70 | 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
||
| 71 | 'id' => 'the_content_filter', |
||
| 72 | 'default' => 'enabled', |
||
| 73 | 'type' => 'radio_inline', |
||
| 74 | 'options' => array( |
||
| 75 | 'enabled' => __( 'Enabled', 'give' ), |
||
| 76 | 'disabled' => __( 'Disabled', 'give' ), |
||
| 77 | ) |
||
| 78 | ), |
||
| 79 | array( |
||
| 80 | 'name' => esc_html__( 'Script Loading Location', 'give' ), |
||
| 81 | 'desc' => __( 'This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give' ), |
||
| 82 | 'id' => 'scripts_footer', |
||
| 83 | 'type' => 'radio_inline', |
||
| 84 | 'default' => 'disabled', |
||
| 85 | 'options' => array( |
||
| 86 | 'enabled' => __( 'Footer', 'give' ), |
||
| 87 | 'disabled' => __( 'Head', 'give' ), |
||
| 88 | ) |
||
| 89 | ), |
||
| 90 | array( |
||
| 91 | 'name' => esc_html__( 'Advanced Settings Docs Link', 'give' ), |
||
| 92 | 'id' => 'advanced_settings_docs_link', |
||
| 93 | 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
||
| 94 | 'title' => __( 'Advanced Settings', 'give' ), |
||
| 95 | 'type' => 'give_docs_link', |
||
| 96 | ), |
||
| 97 | array( |
||
| 98 | 'id' => 'give_title_data_control_2', |
||
| 99 | 'type' => 'sectionend' |
||
| 100 | ) |
||
| 101 | ); |
||
| 102 | break; |
||
| 103 | } |
||
| 104 | |||
| 105 | |||
| 106 | /** |
||
| 107 | * Filter the advanced settings. |
||
| 108 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
||
| 109 | */ |
||
| 110 | $settings = apply_filters( 'give_settings_advanced', $settings ); |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Filter the settings. |
||
| 114 | * |
||
| 115 | * @since 1.8 |
||
| 116 | * |
||
| 117 | * @param array $settings |
||
| 118 | */ |
||
| 119 | $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
||
| 120 | |||
| 121 | // Output. |
||
| 122 | return $settings; |
||
| 123 | } |
||
| 124 | |||
| 143 |