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