AtD_display_unignore_form

Display the AtD unignore form on a page.

Description

AtD_display_unignore_form(); 

Usage

  1. if ( !function_exists( 'AtD_display_unignore_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/after-the-deadline/config-unignore.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = AtD_display_unignore_form(); 
  7.  

Defined (1)

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

/modules/after-the-deadline/config-unignore.php  
  1. function AtD_display_unignore_form() { 
  2.  
  3. if ( ! AtD_is_allowed() ) 
  4. return; 
  5.  
  6. $user = wp_get_current_user(); 
  7.  
  8. if ( ! $user || $user->ID == 0 ) 
  9. return; 
  10.  
  11. $ignores = AtD_get_setting( $user->ID, 'AtD_ignored_phrases' ); 
  12. ?> 
  13. <script> 
  14. function atd_show_phrases( ignored ) 
  15. var element = jQuery( '#atd_ignores' ),  
  16. items = [],  
  17. delLink; 
  18.  
  19. ignored.sort(); 
  20.  
  21. element.empty(); 
  22. for ( var i = 0; i < ignored.length; i++ ) { 
  23. if ( ignored[i].length > 0 ) { 
  24. delLink = jQuery( '<span id="atd_' + i + '"> </span>' ); 
  25. delLink 
  26. .text( delLink.text() + ignored[i] ) 
  27. .prepend( jQuery( '<a class="ntdelbutton">X</a>' ).data( 'ignored', ignored[i] ) ); 
  28. element.append( delLink ).append( '<br />' ); 
  29.  
  30. function atd_unignore( phrase ) { 
  31. /* get the ignored values and remove the unwanted phrase */ 
  32. var ignored = jQuery( '#AtD_ignored_phrases' ).val().split( /, /g ); 
  33. ignored = jQuery.map(ignored, function(value, index) { return value == phrase ? null : value; }); 
  34. jQuery( '#AtD_ignored_phrases' ).val( ignored.join(', ') ); 
  35.  
  36. /* update the UI */ 
  37. atd_show_phrases( ignored ); 
  38.  
  39. /* show a nifty message to the user */ 
  40. jQuery( '#AtD_message' ).show(); 
  41.  
  42. function atd_ignore () { 
  43. /* get the ignored values and update the hidden field */ 
  44. var ignored = jQuery( '#AtD_ignored_phrases' ).val().split( /, /g ); 
  45.  
  46. jQuery.map(jQuery( '#AtD_add_ignore' ).val().split(/, \s*/g), function(value, index) { ignored.push(value); }); 
  47.  
  48. jQuery( '#AtD_ignored_phrases' ).val( ignored.join(', ') ); 
  49.  
  50. /* update the UI */ 
  51. atd_show_phrases( ignored ); 
  52. jQuery( '#AtD_add_ignore' ).val(''); 
  53.  
  54. /* show that nifteroo messaroo to the useroo */ 
  55. jQuery( '#AtD_message' ).show(); 
  56.  
  57. function atd_ignore_init() { 
  58. jQuery( '#AtD_message' ).hide(); 
  59. jQuery( '#atd_ignores' ).on( 'click', 'a', function() { 
  60. atd_unignore( jQuery(this).data( 'ignored' ) ); 
  61. return false; 
  62. } ); 
  63. atd_show_phrases( jQuery( '#AtD_ignored_phrases' ).val().split( /, /g ) ); 
  64.  
  65. /* document.ready() does not execute in IE6 unless it's at the bottom of the page. oi! */ 
  66. if (navigator.appName == 'Microsoft Internet Explorer') 
  67. setTimeout( atd_ignore_init, 2500 ); 
  68. else 
  69. jQuery( document ).ready( atd_ignore_init ); 
  70. </script> 
  71. <input type="hidden" name="AtD_ignored_phrases" id="AtD_ignored_phrases" value="<?php echo esc_attr( $ignores ); ?>"> 
  72.  
  73. <p style="font-weight: bold"><?php _e( 'Ignored Phrases', jetpack ); ?></font> 
  74.  
  75. <p><?php _e( 'Identify words and phrases to ignore while proofreading your posts and pages:', jetpack ); ?></p> 
  76.  
  77. <p><input type="text" id="AtD_add_ignore" name="AtD_add_ignore"> <input type="button" value="<?php _e( 'Add', jetpack ); ?>" onclick="javascript:atd_ignore()"></p> 
  78.  
  79. <div class="tagchecklist" id="atd_ignores"></div> 
  80.  
  81. <div class="plugin-update-tr" id="AtD_message" style="display: none"> 
  82. <div class="update-message"><strong><?php _e( 'Be sure to click "Update Profile" at the bottom of the screen to save your changes.', jetpack ); ?></strong></div> 
  83. </div> 
  84.  
  85. </td> 
  86. </tr> 
  87. </table> 
  88.  
  89. <?php