PageRenderTime 60ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/content/plugins/wordpress-seo/admin/pages/social.php

https://bitbucket.org/geniusdivision/genius-division-wordpress-theme
PHP | 189 lines | 159 code | 26 blank | 4 comment | 38 complexity | 5f4dab07d6cf992acd001aaac97d825e MD5 | raw file
  1. <?php
  2. /**
  3. * @package Admin
  4. */
  5. if ( !defined( 'WPSEO_VERSION' ) ) {
  6. header( 'HTTP/1.0 403 Forbidden' );
  7. die;
  8. }
  9. global $wpseo_admin_pages;
  10. $options = get_option( 'wpseo_social' );
  11. $fbconnect = '<p><strong>' . __( 'Facebook Insights and Admins', 'wordpress-seo' ) . '</strong><br>';
  12. $fbconnect .= sprintf( __( 'To be able to access your <a href="%s">Facebook Insights</a> for your site, you need to specify a Facebook Admin. This can be a user, but if you have an app for your site, you could use that. For most people a user will be "good enough" though.', 'wordpress-seo' ), 'https://www.facebook.com/insights' ) . '</p>';
  13. $error = false;
  14. $clearall = false;
  15. if ( isset( $_GET['delfbadmin'] ) ) {
  16. if ( wp_verify_nonce( $_GET['nonce'], 'delfbadmin' ) != 1 )
  17. die( "I don't think that's really nice of you!." );
  18. $id = $_GET['delfbadmin'];
  19. if ( isset( $options['fb_admins'][$id] ) ) {
  20. $fbadmin = $options['fb_admins'][$id]['name'];
  21. unset( $options['fb_admins'][$id] );
  22. update_option( 'wpseo_social', $options );
  23. add_settings_error( 'yoast_wpseo_social_options', 'success', sprintf( __( 'Successfully removed admin %s', 'wordpress-seo' ), $fbadmin ), 'updated' );
  24. $error = true;
  25. }
  26. }
  27. if ( isset( $_GET['fbclearall'] ) ) {
  28. if ( wp_verify_nonce( $_GET['nonce'], 'fbclearall' ) != 1 )
  29. die( "I don't think that's really nice of you!." );
  30. unset( $options['fb_admins'], $options['fbapps'], $options['fbadminapp'], $options['fbadminpage'] );
  31. update_option( 'wpseo_social', $options );
  32. add_settings_error( 'yoast_wpseo_social_options', 'success', __( 'Successfully cleared all Facebook Data', 'wordpress-seo' ), 'updated' );
  33. }
  34. if ( !isset( $options['fbconnectkey'] ) || empty( $options['fbconnectkey'] ) ) {
  35. $options['fbconnectkey'] = md5( get_bloginfo( 'url' ) . rand() );
  36. update_option( 'wpseo_social', $options );
  37. }
  38. if ( isset( $_GET['key'] ) && $_GET['key'] == $options['fbconnectkey'] ) {
  39. if ( isset( $_GET['userid'] ) ) {
  40. if ( !isset( $options['fb_admins'] ) || !is_array( $options['fb_admins'] ) )
  41. $options['fb_admins'] = array();
  42. $user_id = $_GET['userid'];
  43. $options['fb_admins'][$user_id]['name'] = urldecode( $_GET['userrealname'] );
  44. $options['fb_admins'][$user_id]['link'] = urldecode( $_GET['link'] );
  45. update_option( 'wpseo_social', $options );
  46. add_settings_error( 'yoast_wpseo_social_options', 'success', sprintf( __( 'Successfully added %s as a Facebook Admin!', 'wordpress-seo' ), '<a href="' . esc_url( $options['fb_admins'][$user_id]['link'] ) . '">' . esc_html( $options['fb_admins'][$user_id]['name'] ) . '</a>' ), 'updated' );
  47. } else if ( isset( $_GET['apps'] ) ) {
  48. $apps = json_decode( stripslashes( $_GET['apps'] ) );
  49. $options['fbapps'] = array( '0' => __( 'Do not use a Facebook App as Admin', 'wordpress-seo' ) );
  50. foreach ( $apps as $app ) {
  51. $options['fbapps'][$app->app_id] = $app->display_name;
  52. }
  53. update_option( 'wpseo_social', $options );
  54. add_settings_error( 'yoast_wpseo_social_options', 'success', __( 'Successfully retrieved your apps from Facebook, now select an app to use as admin.', 'wordpress-seo' ), 'updated' );
  55. }
  56. $error = true;
  57. }
  58. $options = get_option( 'wpseo_social' );
  59. if ( isset( $options['fb_admins'] ) && is_array( $options['fb_admins'] ) ) {
  60. foreach ( $options['fb_admins'] as $id => $admin ) {
  61. $fbconnect .= '<input type="hidden" name="wpseo_social[fb_admins][' . esc_attr( $id ) . ']" value="' . esc_attr( $admin['link'] ) . '"/>';
  62. }
  63. $clearall = true;
  64. }
  65. if ( isset( $options['fbapps'] ) && is_array( $options['fbapps'] ) ) {
  66. foreach ( $options['fbapps'] as $id => $page ) {
  67. $fbconnect .= '<input type="hidden" name="wpseo_social[fbapps][' . esc_attr( $id ) . ']" value="' . esc_attr( $page ) . '"/>';
  68. }
  69. $clearall = true;
  70. }
  71. $app_button_text = __( 'Use a Facebook App as Admin', 'wordpress-seo' );
  72. if ( isset( $options['fbapps'] ) && is_array( $options['fbapps'] ) ) {
  73. $fbconnect .= '<p>' . __( 'Select an app to use as Facebook admin:', 'wordpress-seo' ) . '</p>';
  74. $fbconnect .= '<select name="wpseo_social[fbadminapp]" id="fbadminapp">';
  75. if ( !isset( $options['fbadminapp'] ) )
  76. $options['fbadminapp'] = 0;
  77. foreach ( $options['fbapps'] as $id => $app ) {
  78. $sel = '';
  79. if ( $id == $options['fbadminapp'] )
  80. $sel = 'selected="selected"';
  81. $fbconnect .= '<option ' . $sel . ' value="' . esc_attr( $id ) . '">' . esc_attr( $app ) . '</option>';
  82. }
  83. $fbconnect .= '</select><div class="clear"></div><br/>';
  84. $app_button_text = __( 'Update Facebook Apps', 'wordpress-seo' );
  85. }
  86. if ( !isset( $options['fbadminapp'] ) || $options['fbadminapp'] == 0 ) {
  87. $button_text = __( 'Add Facebook Admin', 'wordpress-seo' );
  88. $primary = true;
  89. if ( isset( $options['fb_admins'] ) && is_array( $options['fb_admins'] ) && count( $options['fb_admins'] ) > 0 ) {
  90. $fbconnect .= '<p>' . __( 'Currently connected Facebook admins:', 'wordpress-seo' ) . '</p>';
  91. $fbconnect .= '<ul>';
  92. $nonce = wp_create_nonce( 'delfbadmin' );
  93. foreach ( $options['fb_admins'] as $admin_id => $admin ) {
  94. $admin_id = esc_attr( $admin_id );
  95. $fbconnect .= '<li><a href="' . esc_url( $admin['link'] ) . '">' . esc_html( $admin['name'] ) . '</a> - <strong><a href="' . admin_url( 'admin.php?page=wpseo_social&delfbadmin=' . $admin_id . '&nonce=' . $nonce ) . '">X</a></strong></li>';
  96. $fbconnect .= '<input type="hidden" name="wpseo_social[fb_admins][' . $admin_id . '][link]" value="' . esc_attr( $admin['link'] ) . '"/>';
  97. $fbconnect .= '<input type="hidden" name="wpseo_social[fb_admins][' . $admin_id . '][name]" value="' . esc_attr( $admin['name'] ) . '"/>';
  98. }
  99. $fbconnect .= '</ul>';
  100. $button_text = __( 'Add Another Facebook Admin', 'wordpress-seo' );
  101. $primary = false;
  102. }
  103. $but_primary = '';
  104. if ( $primary )
  105. $but_primary = '-primary';
  106. $fbconnect .= '<p><a class="button' . esc_attr( $but_primary ) . '" href="https://yoast.com/fb-connect/?key=' . $options['fbconnectkey'] . '&redirect=' . urlencode( admin_url( 'admin.php?page=wpseo_social' ) ) . '">' . $button_text . '</a></p>';
  107. }
  108. $fbconnect .= '<a class="button" href="https://yoast.com/fb-connect/?key=' . esc_url( $options['fbconnectkey'] ) . '&type=app&redirect=' . urlencode( admin_url( 'admin.php?page=wpseo_social' ) ) . '">' . esc_html( $app_button_text ) . '</a> ';
  109. if ( $clearall ) {
  110. $fbconnect .= '<a class="button" href="' . admin_url( 'admin.php?page=wpseo_social&nonce=' . wp_create_nonce( 'fbclearall' ) . '&fbclearall=true' ) . '">' . __( 'Clear all Facebook Data', 'wordpress-seo' ) . '</a> ';
  111. }
  112. $fbconnect .= '</p>';
  113. $wpseo_admin_pages->admin_header( __( 'Social', 'wordpress-seo' ), true, 'yoast_wpseo_social_options', 'wpseo_social' );
  114. if ( $error )
  115. settings_errors();
  116. ?>
  117. <h2 class="nav-tab-wrapper" id="wpseo-tabs">
  118. <a class="nav-tab nav-tab-active" id="facebook-tab" href="#top#facebook"><?php _e( 'Facebook', 'wordpress-seo' );?></a>
  119. <a class="nav-tab" id="twitter-tab" href="#top#twitter"><?php _e( 'Twitter', 'wordpress-seo' );?></a>
  120. <a class="nav-tab" id="google-tab" href="#top#google"><?php _e( 'Google+', 'wordpress-seo' );?></a>
  121. </h2>
  122. <div id="facebook" class="wpseotab">
  123. <?php
  124. echo '<p>';
  125. echo $wpseo_admin_pages->checkbox( 'opengraph', '<label for="opengraph">' . __( 'Add Open Graph meta data', 'wordpress-seo' ) . '</label>' );
  126. echo '</p>';
  127. echo'<p class="desc">' . __( 'Add Open Graph meta data to your site\'s <code>&lt;head&gt;</code> section. You can specify some of the ID\'s that are sometimes needed below:', 'wordpress-seo' ) . '</p>';
  128. echo $fbconnect;
  129. echo $wpseo_admin_pages->textinput( 'facebook_site', __( 'Facebook Page URL', 'wordpress-seo' ) );
  130. echo '<h4>' . __( 'Frontpage settings', 'wordpress-seo' ) . '</h4>';
  131. echo $wpseo_admin_pages->textinput( 'og_frontpage_image', __( 'Image URL', 'wordpress-seo' ) );
  132. echo $wpseo_admin_pages->textinput( 'og_frontpage_desc', __( 'Description', 'wordpress-seo' ) );
  133. echo '<p class="desc label">' . __( 'These are the image and description used in the Open Graph meta tags on the frontpage of your site.', 'wordpress-seo' ) . '</p>';
  134. echo '<h4>' . __( 'Default settings', 'wordpress-seo' ) . '</h4>';
  135. echo $wpseo_admin_pages->textinput( 'og_default_image', __( 'Image URL', 'wordpress-seo' ) );
  136. echo '<p class="desc label">' . __( 'This image is used if the post/page being shared does not contain any images.', 'wordpress-seo' ) . '</p>';
  137. do_action('wpseo_admin_opengraph_section');
  138. ?>
  139. </div>
  140. <div id="twitter" class="wpseotab">
  141. <?php
  142. echo '<p>';
  143. echo $wpseo_admin_pages->checkbox( 'twitter', '<label for="twitter">' . __( 'Add Twitter card meta data', 'wordpress-seo' ) . '</label>' );
  144. echo '</p>';
  145. echo'<p class="desc">' . __( 'Add Twitter card meta data to your site\'s <code>&lt;head&gt;</code> section.', 'wordpress-seo' ) . '</p>';
  146. echo $wpseo_admin_pages->textinput( 'twitter_site', __( 'Site Twitter Username', 'wordpress-seo' ) );
  147. do_action('wpseo_admin_twitter_section');
  148. ?>
  149. </div>
  150. <div id="google" class="wpseotab">
  151. <?php
  152. // echo '<h2>' . __( 'Author metadata', 'wordpress-seo' ) . '</h2>';
  153. echo '<label class="select" for="">' . __( 'Author for homepage', 'wordpress-seo' ) . ':</label>';
  154. wp_dropdown_users( array( 'show_option_none' => __( "Don't show", 'wordpress-seo' ), 'name' => 'wpseo_social[plus-author]', 'class' => 'select', 'selected' => isset( $options[ 'plus-author' ] ) ? $options[ 'plus-author' ] : '' ) );
  155. echo '<p class="desc label">' . __( 'Choose the user that should be used for the <code>rel="author"</code> on the blog homepage. Make sure the user has filled out his/her Google+ profile link on their profile page.', 'wordpress-seo' ) . '</p>';
  156. echo $wpseo_admin_pages->textinput( 'plus-publisher', __( 'Google Publisher Page', 'wordpress-seo' ) );
  157. echo '<p class="desc label">' . __( 'If you have a Google+ page for your business, add that URL here and link it on your Google+ page\'s about page.', 'wordpress-seo' ) . '</p>';
  158. do_action('wpseo_admin_googleplus_section');
  159. ?>
  160. </div>
  161. <?php
  162. $wpseo_admin_pages->admin_footer();