Guest User

Untitled

a guest
Oct 18th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. //From functions_thought_catalog.php
  2. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  3. /**
  4. * Let's add a meta box for author links to the guest authors profile pages
  5. *
  6. */
  7. add_action( 'add_meta_boxes', 'coauthors_add_on_the_web_box' );
  8.  
  9. function coauthors_add_on_the_web_box() {
  10. add_meta_box(
  11. 'coauthors-manage-guest-author-on-the-web',
  12. __( 'On the Web', 'co-authors-plus'),
  13. 'metabox_manage_guest_author_on_the_web',
  14. $post_type,
  15. 'normal',
  16. 'low'
  17. );
  18. }
  19.  
  20. function metabox_manage_guest_author_on_the_web() {
  21. global $post;
  22. global $coauthors_plus;
  23.  
  24. $fields = $coauthors_plus->guest_authors->get_guest_author_fields( 'on-the-web' );
  25. echo '<table class="form-table"><tbody>';
  26. foreach( $fields as $field ) {
  27. $pm_key = $coauthors_plus->guest_authors->get_post_meta_key( $field['key'] );
  28. $value = get_post_meta( $post->ID, $pm_key, true );
  29. echo '<tr><th>';
  30. echo '<label for="' . esc_attr( $pm_key ) . '">' . $field['label'] . '</label>';
  31. echo '</th><td>';
  32. echo '<input type="text" name="' . esc_attr( $pm_key ) . '" value="' . esc_attr( $value ) . '" class="regular-text" />';
  33. echo '</td></tr>';
  34. }
  35. echo '</tbody></table>';
  36.  
  37. }
  38.  
  39. //add_filter( 'coauthors_guest_author_fields', 'add_guest_author_on_the_web_fields', 10, 2);
  40.  
  41. // function add_guest_author_on_the_web_fields( $groups, $global_fields ) {
  42. //
  43. // }
  44.  
  45. //From modified class-coauthors-guest-authors.php
  46. function get_guest_author_fields( $groups = 'all' ) {
  47.  
  48. $groups = (array)$groups;
  49. $global_fields = array(
  50. // Hidden (included in object, no UI elements)
  51. array(
  52. 'key' => 'ID',
  53. 'label' => __( 'ID', 'co-authors-plus' ),
  54. 'group' => 'hidden',
  55. ),
  56. // Name
  57. array(
  58. 'key' => 'display_name',
  59. 'label' => __( 'Display Name', 'co-authors-plus'),
  60. 'group' => 'name',
  61. ),
  62. array(
  63. 'key' => 'first_name',
  64. 'label' => __( 'First Name', 'co-authors-plus'),
  65. 'group' => 'name',
  66. ),
  67. array(
  68. 'key' => 'last_name',
  69. 'label' => __( 'Last Name', 'co-authors-plus'),
  70. 'group' => 'name',
  71. ),
  72. array(
  73. 'key' => 'user_login',
  74. 'label' => __( 'Slug', 'co-authors-plus'),
  75. 'group' => 'slug',
  76. ),
  77. // Contact info
  78. array(
  79. 'key' => 'user_email',
  80. 'label' => __( 'E-mail', 'co-authors-plus' ),
  81. 'group' => 'contact-info',
  82. ),
  83. array(
  84. 'key' => 'linked_account',
  85. 'label' => __( 'Linked Account', 'co-authors-plus' ),
  86. 'group' => 'slug',
  87. ),
  88. array(
  89. 'key' => 'website',
  90. 'label' => __( 'Website', 'co-authors-plus' ),
  91. 'group' => 'contact-info',
  92. ),
  93. array(
  94. 'key' => 'aim',
  95. 'label' => __( 'AIM', 'co-authors-plus' ),
  96. 'group' => 'contact-info',
  97. ),
  98. array(
  99. 'key' => 'yahooim',
  100. 'label' => __( 'Yahoo IM', 'co-authors-plus' ),
  101. 'group' => 'contact-info',
  102. ),
  103. array(
  104. 'key' => 'jabber',
  105. 'label' => __( 'Jabber / Google Talk', 'co-authors-plus' ),
  106. 'group' => 'contact-info',
  107. ),
  108. array(
  109. 'key' => 'description',
  110. 'label' => __( 'Biographical Info', 'co-authors-plus' ),
  111. 'group' => 'about',
  112. 'sanitize_function' => 'wp_filter_post_kses',
  113. ),
  114. //I added these arrays. I need to use add_filter to handle this in a theme file.
  115. array(
  116. 'key' => 'url_1',
  117. 'label' => __( 'URL', 'co-authors-plus' ),
  118. 'group' => 'on-the-web',
  119. ),
  120. array(
  121. 'key' => 'title_1',
  122. 'label' => __( 'Title', 'co-authors-plus'),
  123. 'group' => 'on-the-web',
  124. )
  125. );
  126. $fields_to_return = array();
  127. foreach( $global_fields as $single_field ) {
  128. if ( in_array( $single_field['group'], $groups ) || $groups[0] == 'all' && $single_field['group'] != 'hidden' )
  129. $fields_to_return[] = $single_field;
  130. }
  131.  
  132. return apply_filters( 'coauthors_guest_author_fields', $fields_to_return, $groups );
  133.  
  134. }
Add Comment
Please, Sign In to add comment