| Conditions | 4 |
| Paths | 4 |
| Total Lines | 72 |
| 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 |
||
| 41 | public function output( $current_view ) { |
||
| 42 | if ( $current_view !== 'getting-started' ) { |
||
| 43 | return; |
||
| 44 | } |
||
| 45 | |||
| 46 | // Get active theme |
||
| 47 | $active_theme = wp_get_theme(); |
||
| 48 | ?> |
||
| 49 | <div class="auto-load-next-post getting-started"> |
||
| 50 | |||
| 51 | <div class="container"> |
||
| 52 | |||
| 53 | <div class="content"> |
||
| 54 | <div class="logo"> |
||
| 55 | <a href="<?php echo AUTO_LOAD_NEXT_POST_STORE_URL; ?>" target="_blank"> |
||
| 56 | <img src="<?php echo AUTO_LOAD_NEXT_POST_URL_PATH . '/assets/images/logo.png'; ?>" alt="<?php esc_html_e( 'Auto Load Next Post', 'auto-load-next-post' ); ?>" /> |
||
| 57 | </a> |
||
| 58 | </div> |
||
| 59 | |||
| 60 | <h1><?php printf( __( 'Getting started with %s.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); ?></h1> |
||
| 61 | |||
| 62 | <p><strong><?php printf( __( 'Thanks for choosing %s.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); ?></strong></p> |
||
| 63 | |||
| 64 | <p><?php echo esc_html__( 'Your well on your way to increasing your pageviews by engaging your site viewers to keep reading your content and reduce bounce rate.', 'auto-load-next-post' ); ?></p> |
||
| 65 | |||
| 66 | <?php |
||
| 67 | // Is Theme already supported? |
||
| 68 | if ( is_alnp_supported() ) { |
||
| 69 | ?> |
||
| 70 | <p><?php echo sprintf( __( 'Your active theme %1$s supports %2$s so everything is already setup for you.', 'auto-load-next-post' ), '<strong>' . $active_theme->name . '</strong>', esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); ?></p> |
||
| 71 | <?php |
||
| 72 | } else { |
||
| 73 | ?> |
||
| 74 | <p><?php echo sprintf( __( 'Run the %1$s to be ready in less than 5-minutes, setting up %2$s for the first time is easy. The wizard will scan your theme to process the installation.', 'auto-load-next-post' ), esc_html__( 'Setup Wizard', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); ?></p> |
||
| 75 | |||
| 76 | <p><strong class="red"><?php _e( 'Developers:', 'auto-load-next-post' ); ?></strong> <?php printf( __( 'Enable %1$sWP_DEBUG%2$s in your %3$swp-config.php%4$s file before running the %5$s to provide you results for each step once it has scanned your theme.', 'auto-load-next-post' ), '<strong>', '</strong>', '<code>', '</code>', esc_html__( 'Setup Wizard', 'auto-load-next-post' ) ); ?></p> |
||
| 77 | |||
| 78 | <p><?php echo sprintf( __( 'You can add support for %1$s for future users by viewing the documentation and developer guides, snippets and more.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); ?></p> |
||
| 79 | |||
| 80 | <?php |
||
| 81 | /** |
||
| 82 | * Display content if you have Auto Load Next Post Pro installed or not. |
||
| 83 | */ |
||
| 84 | if ( is_alnp_pro_version_installed() ) { |
||
| 85 | include( dirname( __FILE__ ) . '/views/html-getting-started-pro.php' ); |
||
| 86 | } |
||
| 87 | ?> |
||
| 88 | |||
| 89 | <p style="text-align: center;"> |
||
| 90 | <a class="button button-primary button-large" href="<?php echo add_query_arg( array( 'page' => 'auto-load-next-post', 'view' => 'setup-wizard' ), admin_url( 'options-general.php' ) ); ?>"><?php _e( 'Setup Wizard', 'auto-load-next-post' ); ?></a> |
||
| 91 | <a class="button button-large" href="<?php echo AUTO_LOAD_NEXT_POST_DOCUMENTATION_URL; ?>"><?php _e( 'View Documentation', 'auto-load-next-post' ); ?></a> |
||
| 92 | </p> |
||
| 93 | |||
| 94 | <hr> |
||
| 95 | <?php |
||
| 96 | } |
||
| 97 | ?> |
||
| 98 | |||
| 99 | <p><?php echo sprintf( |
||
| 100 | /* translators: 1: Opening <a> tag to the Auto Load Next Post Twitter account, 2: Opening <a> tag to the Auto Load Next Post Instagram account, 3: Opening <a> tag to the Auto Load Next Post contact page, 4: Opening <a> tag to the Auto Load Next Post newsletter, 5: Closing </a> tag */ |
||
| 101 | esc_html__( 'If you have any questions or feedback, let me know on %1$sTwitter%5$s, %2$sInstagram%5$s or via the %3$sContact page%5$s. Also, %4$ssubscribe to my newsletter%5$s if you want to stay up to date with what\'s new and upcoming in Auto Load Next Post.', 'auto-load-next-post' ), '<a href="https://twitter.com/autoloadnxtpost" target="_blank">', '<a href="https://instagram.com/autoloadnextpost" target="_blank">', '<a href="https://autoloadnextpost.com/contact/" target="_blank">', '<a href="http://eepurl.com/bvLz2H" target="_blank">', '</a>' |
||
| 102 | ); |
||
| 103 | ?></p> |
||
| 104 | |||
| 105 | <p><?php echo esc_html__( 'Enjoy!', 'auto-load-next-post' ); ?></p> |
||
| 106 | </div> |
||
| 107 | |||
| 108 | </div> |
||
| 109 | |||
| 110 | </div> |
||
| 111 | <?php |
||
| 112 | } // END output() |
||
| 113 | |||
| 118 | return new ALNP_Getting_Started(); |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: