| Conditions | 11 |
| Paths | 1024 |
| Total Lines | 152 |
| Code Lines | 83 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 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 |
||
| 118 | function ppp_display_social() { |
||
| 119 | do_action( 'ppp_social_settings_pre_form' ); |
||
| 120 | |||
| 121 | $ppp_share_settings = get_option( 'ppp_share_settings' ); |
||
| 122 | ?> |
||
| 123 | <div class="wrap"> |
||
| 124 | <div id="icon-options-general" class="icon32"></div><h1><?php _e( 'Post Promoter Pro - Social Settings', 'ppp-txt' ); ?></h1> |
||
| 125 | <form method="post" action="options.php"> |
||
| 126 | <?php wp_nonce_field( 'ppp-share-settings' ); ?> |
||
| 127 | <h3><?php _e( 'Social Media Accounts', 'ppp-txt' ); ?></h3> |
||
| 128 | <?php |
||
| 129 | require_once PPP_PATH . 'includes/admin/class-accounts-table.php'; |
||
| 130 | |||
| 131 | $accounts_table = new PPP_Accounts_Table(); |
||
| 132 | $accounts_table->prepare_items(); |
||
| 133 | |||
| 134 | $accounts_table->display(); |
||
| 135 | ?> |
||
| 136 | <table class="form-table"> |
||
| 137 | <?php $analytics_option = isset( $ppp_share_settings['analytics'] ) ? $ppp_share_settings['analytics'] : 0; ?> |
||
| 138 | <tr valign="top"> |
||
| 139 | <th scope="row" valign="top"> |
||
| 140 | <?php _e( 'Analytics', 'ppp-txt' ); ?></span> |
||
| 141 | </th> |
||
| 142 | <td id="ppp-analytics-options"> |
||
| 143 | <p> |
||
| 144 | <input id="ppp_no_tracking" |
||
| 145 | name="ppp_share_settings[analytics]" |
||
| 146 | type="radio" |
||
| 147 | value="none" |
||
| 148 | <?php checked( 'none', $analytics_option, true ); ?> |
||
| 149 | /> <label for="ppp_no_tracking"><?php _e( 'None', 'ppp-txt' ); ?></label> |
||
| 150 | </p> |
||
| 151 | <br /> |
||
| 152 | <p> |
||
| 153 | <input id="ppp_unique_links" |
||
| 154 | name="ppp_share_settings[analytics]" |
||
| 155 | type="radio" |
||
| 156 | value="unique_links" |
||
| 157 | <?php checked( 'unique_links', $analytics_option, true ); ?> |
||
| 158 | /> <label for="ppp_unique_links"><?php _e( 'Simple Tracking', 'ppp-txt' ); ?></label><br /> |
||
| 159 | <small><?php _e( 'Appends a query string to shared links for analytics.', 'ppp-txt' ); ?></small> |
||
| 160 | </p> |
||
| 161 | <br /> |
||
| 162 | <p> |
||
| 163 | <input id="ppp_ga_tags" |
||
| 164 | name="ppp_share_settings[analytics]" |
||
| 165 | type="radio" |
||
| 166 | value="google_analytics" |
||
| 167 | <?php checked( 'google_analytics', $analytics_option, true ); ?> |
||
| 168 | /> <label for="ppp_ga_tags"><?php _e( 'Google Analytics Tags', 'ppp-txt' ); ?></label><br /> |
||
| 169 | <small><?php _e( 'Results can be seen in the Acquisition Menu under "Campaigns"', 'ppp-txt' ); ?></small> |
||
| 170 | </p> |
||
| 171 | <?php do_action( 'ppp-settings-analytics-radio' ); ?> |
||
| 172 | <p id="ppp-link-example"> |
||
| 173 | <hr /> |
||
| 174 | <small><?php _e( 'Here is an example of what your link will look like', 'ppp-txt' ); ?>: <br /> |
||
| 175 | <?php $post = wp_get_recent_posts( array( 'numberposts' => 1 ) ); ?> |
||
| 176 | <?php if( count( $post ) > 0 ): ?> |
||
| 177 | <code><?php echo ppp_generate_link( $post[0]['ID'], 'sharedate_1_' . $post[0]['ID'], false ); ?></code></small> |
||
| 178 | <?php else: ?> |
||
| 179 | <em><?php _e( 'No posts available to generate link from.', 'ppp-txt' ); ?></em> |
||
| 180 | <?php endif; ?> |
||
| 181 | </p> |
||
| 182 | </td> |
||
| 183 | </tr> |
||
| 184 | |||
| 185 | <?php |
||
| 186 | $tw_sop = ! empty( $ppp_share_settings['twitter']['share_on_publish'] ) ? true : false; |
||
| 187 | $fb_sop = ! empty( $ppp_share_settings['facebook']['share_on_publish'] ) ? true : false; |
||
| 188 | $li_sop = ! empty( $ppp_share_settings['linkedin']['share_on_publish'] ) ? true : false; |
||
| 189 | ?> |
||
| 190 | <tr valign="top"> |
||
| 191 | <th scope="row" valign="top"> |
||
| 192 | <?php _e( 'Share on Publish Defaults', 'ppp-txt' ); ?></span><br /> |
||
| 193 | <small><em><?php _e( 'Enabled sharing on publish by default', 'ppp-txt' ); ?></em></small> |
||
| 194 | </th> |
||
| 195 | <td id="ppp-share-on-publish-wrapper"> |
||
| 196 | <?php if ( ppp_twitter_enabled() ) : ?> |
||
| 197 | <p> |
||
| 198 | <input type="checkbox" id="twitter-share-on-publish" value="1" <?php checked( true, $tw_sop, true ); ?> name="ppp_share_settings[twitter][share_on_publish]" /> |
||
| 199 | <label for="twitter-share-on-publish"><?php _e( 'Twitter', 'ppp-txt' ); ?></label> |
||
| 200 | </p> |
||
| 201 | <?php endif; ?> |
||
| 202 | |||
| 203 | <?php if ( ppp_facebook_enabled() ) : ?> |
||
| 204 | <p> |
||
| 205 | <input type="checkbox" id="facebook-share-on-publish" value="1" <?php checked( true, $fb_sop, true ); ?> name="ppp_share_settings[facebook][share_on_publish]" /> |
||
| 206 | <label for="facebook-share-on-publish"><?php _e( 'Facebook', 'ppp-txt' ); ?></label> |
||
| 207 | </p> |
||
| 208 | <?php endif; ?> |
||
| 209 | |||
| 210 | <?php if ( ppp_linkedin_enabled() ) : ?> |
||
| 211 | <p> |
||
| 212 | <input type="checkbox" id="linkedin-share-on-publish" value="1" <?php checked( true, $li_sop, true ); ?> name="ppp_share_settings[linkedin][share_on_publish]" /> |
||
| 213 | <label for="linkedin-share-on-publish"><?php _e( 'LinkedIn', 'ppp-txt' ); ?></label> |
||
| 214 | </p> |
||
| 215 | <?php endif; ?> |
||
| 216 | </td> |
||
| 217 | </tr> |
||
| 218 | |||
| 219 | <?php $twitter_cards_enabled = ppp_tw_cards_enabled(); ?> |
||
| 220 | <tr valign="top"> |
||
| 221 | <th scope="row" valign="top"> |
||
| 222 | <?php _e( 'Twitter Settings', 'ppp-txt' ); ?></span> |
||
| 223 | </th> |
||
| 224 | <td id="ppp-twitter-cards-wrapper"> |
||
| 225 | <p> |
||
| 226 | <input id="ppp-twitter-cards" |
||
| 227 | name="ppp_share_settings[twitter][cards_enabled]" |
||
| 228 | type="checkbox" |
||
| 229 | value="1" |
||
| 230 | <?php checked( true, $twitter_cards_enabled, true ); ?> |
||
| 231 | /> <label for="ppp-twitter-cards"><?php _e( 'Enable Twitter Cards', 'ppp-txt' ); ?></label> |
||
| 232 | </p> |
||
| 233 | </td> |
||
| 234 | </tr> |
||
| 235 | |||
| 236 | <?php |
||
| 237 | $shortener = isset( $ppp_share_settings['shortener'] ) ? $ppp_share_settings['shortener'] : false; |
||
| 238 | ?> |
||
| 239 | <tr valign="top"> |
||
| 240 | <th scope="row" valign="top"> |
||
| 241 | <?php _e( 'URL Shortener', 'ppp-txt' ); ?></span> |
||
| 242 | </th> |
||
| 243 | <td id="ppp-shortener-options"> |
||
| 244 | <p> |
||
| 245 | <select name="ppp_share_settings[shortener]"> |
||
| 246 | <option value="-1"><?php _e( 'Select a Service', 'ppp-txt' ); ?></option> |
||
| 247 | <?php do_action( 'ppp_url_shorteners', $shortener ); ?> |
||
| 248 | </select> |
||
| 249 | </p> |
||
| 250 | <?php if ( $shortener ) : ?> |
||
| 251 | <?php do_action( 'ppp_shortener_settings-' . $shortener ); ?> |
||
| 252 | <?php endif; ?> |
||
| 253 | </td> |
||
| 254 | </tr> |
||
| 255 | |||
| 256 | <?php settings_fields( 'ppp-share-settings' ); ?> |
||
| 257 | |||
| 258 | <input type="hidden" name="action" value="update" /> |
||
| 259 | <input type="hidden" name="page_options" value="ppp_share_settings,ppp_social_settings" /> |
||
| 260 | |||
| 261 | |||
| 262 | </table> |
||
| 263 | |||
| 264 | <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'ppp-txt' ) ?>" /> |
||
| 265 | |||
| 266 | </form> |
||
| 267 | </div> |
||
| 268 | <?php |
||
| 269 | } |
||
| 270 | |||
| 395 |