grunion_manage_post_columns

The Jetpack by WordPress.com grunion manage post columns function.

Description

grunion_manage_post_columns( $col, $post_id ); 

Parameters (2)

0. $col
The col.
1. $post_id
The post id.

Usage

  1. if ( !function_exists( 'grunion_manage_post_columns' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/contact-form/admin.php'; 
  3.  
  4. // The col. 
  5. $col = null; 
  6.  
  7. // The post id. 
  8. $post_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = grunion_manage_post_columns($col, $post_id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/modules/contact-form/admin.php  
  1. function grunion_manage_post_columns( $col, $post_id ) { 
  2. global $post; 
  3.  
  4. /** 
  5. * Only call parse_fields_from_content if we're dealing with a Grunion custom column. 
  6. */ 
  7. if ( ! in_array( $col, array( 'feedback_date', 'feedback_from', 'feedback_message' ) ) ) { 
  8. return; 
  9.  
  10. $content_fields = Grunion_Contact_Form_Plugin::parse_fields_from_content( $post_id ); 
  11.  
  12. switch ( $col ) { 
  13. case 'feedback_from': 
  14. $author_name = $content_fields['_feedback_author']; 
  15. $author_email = $content_fields['_feedback_author_email']; 
  16. $author_url = $content_fields['_feedback_author_url']; 
  17. $author_ip = $content_fields['_feedback_ip']; 
  18. $form_url = isset( $post->post_parent ) ? get_permalink( $post->post_parent ) : null; 
  19.  
  20. $author_name_line = ''; 
  21. if ( !empty( $author_name ) ) { 
  22. if ( !empty( $author_email ) ) 
  23. $author_name_line = get_avatar( $author_email, 32 ); 
  24.  
  25. $author_name_line .= sprintf( "<strong>%s</strong><br />", esc_html( $author_name ) ); 
  26.  
  27. $author_email_line = ''; 
  28. if ( !empty( $author_email ) ) { 
  29. $author_email_line = sprintf( "<a href='%1\$s'>%2\$s</a><br />", esc_url( "mailto:" . $author_email ) , esc_html( $author_email ) ); 
  30.  
  31. $author_url_line = ''; 
  32. if ( !empty( $author_url ) ) { 
  33. $author_url_line = sprintf( "<a href='%1\$s'>%1\$s</a><br />", esc_url( $author_url ) ); 
  34.  
  35. echo $author_name_line; 
  36. echo $author_email_line; 
  37. echo $author_url_line; 
  38. echo "<a href='edit.php?post_type=feedback&s=" . urlencode( $author_ip ); 
  39. echo "&mode=detail'>" . esc_html( $author_ip ) . "</a><br />"; 
  40. if ( $form_url ) { 
  41. echo '<a href="' . esc_url( $form_url ) . '">' . esc_html( $form_url ) . '</a>'; 
  42. break; 
  43.  
  44. case 'feedback_message': 
  45. $post_type_object = get_post_type_object( $post->post_type ); 
  46. echo '<strong>'; 
  47. echo esc_html( $content_fields['_feedback_subject'] ); 
  48. echo '</strong><br />'; 
  49. echo sanitize_text_field( get_the_content( '' ) ); 
  50. echo '<br />'; 
  51.  
  52. $extra_fields = get_post_meta( $post_id, '_feedback_extra_fields', TRUE ); 
  53. if ( !empty( $extra_fields ) ) { 
  54. echo '<br /><hr />'; 
  55. echo '<table cellspacing="0" cellpadding="0" style="">' . "\n"; 
  56. foreach ( (array) $extra_fields as $k => $v ) { 
  57. // Remove prefix from exta fields 
  58. echo "<tr><td align='right'><b>". esc_html( preg_replace( '#^\d+_#', '', $k ) ) ."</b></td><td>". sanitize_text_field( $v ) ."</td></tr>\n"; 
  59. echo '</table>'; 
  60.  
  61. echo '<div class="row-actions">'; 
  62. if ( $post->post_status == 'trash' ) { 
  63. echo '<span class="untrash" id="feedback-restore-' . $post_id; 
  64. echo '"><a title="'; 
  65. echo esc_attr__( 'Restore this item from the Trash', jetpack ); 
  66. echo '" href="' . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ); 
  67. echo '">' . __( 'Restore', jetpack ) . '</a></span> | '; 
  68.  
  69. echo "<span class='delete'> <a class='submitdelete' title='"; 
  70. echo esc_attr( __( 'Delete this item permanently', jetpack ) ); 
  71. echo "' href='" . get_delete_post_link( $post->ID, '', true ); 
  72. echo "'>" . __( 'Delete Permanently', jetpack ) . "</a></span>"; 
  73. ?> 
  74.  
  75. <script> 
  76. jQuery(document).ready(function($) { 
  77. $('#feedback-restore-<?php echo $post_id; ?>').click(function(e) { 
  78. e.preventDefault(); 
  79. $.post(ajaxurl, { 
  80. action: 'grunion_ajax_spam',  
  81. post_id: '<?php echo $post_id; ?>',  
  82. make_it: 'publish',  
  83. sub_menu: jQuery('.subsubsub .current').attr('href'),  
  84. _ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>' 
  85. },  
  86. function(r) { 
  87. $('#post-<?php echo $post_id; ?>') 
  88. .css({backgroundColor: '#59C859'}) 
  89. .fadeOut(350, function() { 
  90. $(this).remove(); 
  91. $('.subsubsub').html(r); 
  92. }); 
  93. ); 
  94. }); 
  95. }); 
  96. </script> 
  97.  
  98. <?php 
  99. } elseif ( $post->post_status == 'publish' ) { 
  100. echo '<span class="spam" id="feedback-spam-' . $post_id; 
  101. echo '"><a title="'; 
  102. echo __( 'Mark this message as spam', jetpack ); 
  103. echo '" href="' . wp_nonce_url( admin_url( 'admin-ajax.php?post_id=' . $post_id . '&action=spam' ), 'spam-feedback_' . $post_id ); 
  104. echo '">Spam</a></span>'; 
  105. echo ' | '; 
  106.  
  107. echo '<span class="delete" id="feedback-trash-' . $post_id; 
  108. echo '">'; 
  109. echo '<a class="submitdelete" title="' . esc_attr__( 'Trash', jetpack ); 
  110. echo '" href="' . get_delete_post_link( $post_id ); 
  111. echo '">' . __( 'Trash', jetpack ) . '</a></span>'; 
  112.  
  113. ?> 
  114.  
  115. <script> 
  116. jQuery(document).ready( function($) { 
  117. $('#feedback-spam-<?php echo $post_id; ?>').click( function(e) { 
  118. e.preventDefault(); 
  119. $.post( ajaxurl, { 
  120. action: 'grunion_ajax_spam',  
  121. post_id: '<?php echo $post_id; ?>',  
  122. make_it: 'spam',  
  123. sub_menu: jQuery('.subsubsub .current').attr('href'),  
  124. _ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>' 
  125. },  
  126. function( r ) { 
  127. $('#post-<?php echo $post_id; ?>') 
  128. .css( {backgroundColor:'#FF7979'} ) 
  129. .fadeOut(350, function() { 
  130. $(this).remove(); 
  131. $('.subsubsub').html(r); 
  132. }); 
  133. }); 
  134. }); 
  135.  
  136. $('#feedback-trash-<?php echo $post_id; ?>').click(function(e) { 
  137. e.preventDefault(); 
  138. $.post(ajaxurl, { 
  139. action: 'grunion_ajax_spam',  
  140. post_id: '<?php echo $post_id; ?>',  
  141. make_it: 'trash',  
  142. sub_menu: jQuery('.subsubsub .current').attr('href'),  
  143. _ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>' 
  144. },  
  145. function(r) { 
  146. $('#post-<?php echo $post_id; ?>') 
  147. .css({backgroundColor: '#FF7979'}) 
  148. .fadeOut(350, function() { 
  149. $(this).remove(); 
  150. $('.subsubsub').html(r); 
  151. }); 
  152. ); 
  153. }); 
  154. }); 
  155. </script> 
  156.  
  157. <?php 
  158. } elseif ( $post->post_status == 'spam' ) { 
  159. echo '<span class="unspam unapprove" id="feedback-ham-' . $post_id; 
  160. echo '"><a title="'; 
  161. echo __( 'Mark this message as NOT spam', jetpack ); 
  162. echo '" href="">Not Spam</a></span>'; 
  163. echo ' | '; 
  164.  
  165. echo "<span class='delete' id='feedback-trash-" . $post_id; 
  166. echo "'> <a class='submitdelete' title='"; 
  167. echo esc_attr( __( 'Delete this item permanently', jetpack ) ); 
  168. echo "' href='" . get_delete_post_link( $post->ID, '', true ); 
  169. echo "'>" . __( 'Delete Permanently', jetpack ) . "</a></span>"; 
  170. ?> 
  171.  
  172. <script> 
  173. jQuery(document).ready( function($) { 
  174. $('#feedback-ham-<?php echo $post_id; ?>').click( function(e) { 
  175. e.preventDefault(); 
  176. $.post( ajaxurl, { 
  177. action: 'grunion_ajax_spam',  
  178. post_id: '<?php echo $post_id; ?>',  
  179. make_it: 'ham',  
  180. sub_menu: jQuery('.subsubsub .current').attr('href'),  
  181. _ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>' 
  182. },  
  183. function( r ) { 
  184. $('#post-<?php echo $post_id; ?>') 
  185. .css( {backgroundColor:'#59C859'} ) 
  186. .fadeOut(350, function() { 
  187. $(this).remove(); 
  188. $('.subsubsub').html(r); 
  189. }); 
  190. }); 
  191. }); 
  192. }); 
  193. </script> 
  194.  
  195. <?php 
  196. break; 
  197.  
  198. case 'feedback_date': 
  199.  
  200. $date_time_format = _x( '%1$s \a\t %2$s', '{$date_format} \a\t {$time_format}', jetpack ); 
  201. $date_time_format = sprintf( $date_time_format, get_option( 'date_format' ), get_option( 'time_format' ) ); 
  202. $time = date_i18n( $date_time_format, get_the_time( 'U' ) ); 
  203.  
  204. echo $time; 
  205. break;