function AtD_display_unignore_form()
{
    if (!AtD_is_allowed()) {
        return;
    }
    $user = wp_get_current_user();
    if (!$user || $user->ID == 0) {
        return;
    }
    $ignores = AtD_get_setting($user->ID, 'AtD_ignored_phrases');
    ?>
<script>
function atd_show_phrases( ignored )
{
	var element = jQuery( '#atd_ignores' ),
	    items   = [],
	    delLink;

	ignored.sort();

	element.empty();
	for ( var i = 0; i < ignored.length; i++ ) {
		if ( ignored[i].length > 0 ) {
			delLink = jQuery( '<span id="atd_' + i + '">&nbsp;</span>' );
			delLink
				.text( delLink.text() + ignored[i] )
				.prepend( jQuery( '<a class="ntdelbutton">X</a>' ).data( 'ignored', ignored[i] ) );
			element.append( delLink ).append( '<br />' );
		}
	}
}

function atd_unignore( phrase ) {
	/* get the ignored values and remove the unwanted phrase */
	var ignored = jQuery( '#AtD_ignored_phrases' ).val().split( /,/g );
        ignored = jQuery.map(ignored, function(value, index) { return value == phrase ? null : value; });
        jQuery( '#AtD_ignored_phrases' ).val( ignored.join(',') );

	/* update the UI */
	atd_show_phrases( ignored );

	/* show a nifty message to the user */
        jQuery( '#AtD_message' ).show();
}

function atd_ignore () {
	/* get the ignored values and update the hidden field */
	var ignored = jQuery( '#AtD_ignored_phrases' ).val().split( /,/g );

        jQuery.map(jQuery( '#AtD_add_ignore' ).val().split(/,\s*/g), function(value, index) { ignored.push(value); });

        jQuery( '#AtD_ignored_phrases' ).val( ignored.join(',') );

	/* update the UI */
	atd_show_phrases( ignored );
	jQuery( '#AtD_add_ignore' ).val('');

	/* show that nifteroo messaroo to the useroo */
        jQuery( '#AtD_message' ).show();
}

function atd_ignore_init() {
	jQuery( '#AtD_message' ).hide();
	jQuery( '#atd_ignores' ).delegate( 'a', 'click', function() {
		atd_unignore( jQuery(this).data( 'ignored' ) );
		return false;
	} );
	atd_show_phrases( jQuery( '#AtD_ignored_phrases' ).val().split( /,/g ) );
}

/* document.ready() does not execute in IE6 unless it's at the bottom of the page. oi! */
if (navigator.appName == 'Microsoft Internet Explorer')
	setTimeout( atd_ignore_init, 2500 );
else
	jQuery( document ).ready( atd_ignore_init );
</script>
   <input type="hidden" name="AtD_ignored_phrases" id="AtD_ignored_phrases" value="<?php 
    echo esc_attr($ignores);
    ?>
">

          <p style="font-weight: bold"><?php 
    _e('Ignored Phrases', 'jetpack');
    ?>
</font>

          <p><?php 
    _e('Identify words and phrases to ignore while proofreading your posts and pages:', 'jetpack');
    ?>
</p>

          <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>

          <div class="tagchecklist" id="atd_ignores"></div>

          <div class="plugin-update-tr" id="AtD_message" style="display: none">
          <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>
          </div>

         </td>
      </tr>
   </table>

<?php 
}
function AtD_change_mce_settings($init_array)
{
    if (!AtD_is_allowed()) {
        return $init_array;
    }
    $user = wp_get_current_user();
    $init_array['atd_rpc_url'] = admin_url('admin-ajax.php?action=proxy_atd&url=');
    $init_array['atd_ignore_rpc_url'] = admin_url('admin-ajax.php?action=atd_ignore&phrase=');
    $init_array['atd_rpc_id'] = 'WPORG-' . md5(get_bloginfo('wpurl'));
    $init_array['atd_theme'] = 'wordpress';
    $init_array['atd_ignore_enable'] = 'true';
    $init_array['atd_strip_on_get'] = 'true';
    $init_array['atd_ignore_strings'] = json_encode(explode(',', AtD_get_setting($user->ID, 'AtD_ignored_phrases')));
    $init_array['atd_show_types'] = AtD_get_setting($user->ID, 'AtD_options');
    $init_array['gecko_spellcheck'] = 'false';
    return $init_array;
}
Пример #3
0
function AtD_change_mce_settings($init_array)
{
    if (!AtD_is_allowed()) {
        return $init_array;
    }
    if (!is_array($init_array)) {
        $init_array = array();
    }
    $user = wp_get_current_user();
    $init_array['atd_rpc_url'] = admin_url('admin-ajax.php?action=proxy_atd&_wpnonce=' . wp_create_nonce('proxy_atd') . '&url=');
    $init_array['atd_ignore_rpc_url'] = admin_url('admin-ajax.php?action=atd_ignore&_wpnonce=' . wp_create_nonce('atd_ignore') . '&phrase=');
    $init_array['atd_rpc_id'] = AtD_get_rpc_id();
    $init_array['atd_theme'] = 'wordpress';
    $init_array['atd_ignore_enable'] = 'true';
    $init_array['atd_strip_on_get'] = 'true';
    $init_array['atd_ignore_strings'] = json_encode(explode(',', AtD_get_setting($user->ID, 'AtD_ignored_phrases')));
    $init_array['atd_show_types'] = AtD_get_setting($user->ID, 'AtD_options');
    $init_array['gecko_spellcheck'] = 'false';
    return $init_array;
}
Пример #4
0
function AtD_display_unignore_form()
{
    if (!AtD_is_allowed()) {
        return;
    }
    $user = wp_get_current_user();
    if (!$user || $user->ID == 0) {
        return;
    }
    $ignores = AtD_get_setting($user->ID, 'AtD_ignored_phrases');
    ?>
<script>
function atd_show_phrases( ignored )
{
	var element = jQuery( '#atd_ignores' ).get( 0 );
	var items   = new Array();

	ignored.sort();

	for ( var i = 0; i < ignored.length; i++ ) {
		if ( ignored[i].length > 0 )
			items.push( '<span id="atd_' + i + '"><a class="ntdelbutton" href="javascript:atd_unignore(\'' + encodeURIComponent( ignored[i].replace("'", "\\'") ) + '\')">X</a>&nbsp;' + ignored[i] + '</span>' );
	}

	element.innerHTML = items.length >= 1 ? items.join("<br>") : ''; 
}

function atd_unignore( phrase, eid ) {
	/* get the ignored values and remove the unwanted phrase */
	var ignored = jQuery( '#AtD_ignored_phrases' ).val().split( /,/g );
        ignored = jQuery.map(ignored, function(value, index) { return value == phrase ? null : value; });
        jQuery( '#AtD_ignored_phrases' ).val( ignored.join(',') );

	/* update the UI */
	atd_show_phrases( ignored );

	/* show a nifty message to the user */
        jQuery( '#AtD_message' ).show();
}

function atd_ignore () {
	/* get the ignored values and update the hidden field */
	var ignored = jQuery( '#AtD_ignored_phrases' ).val().split( /,/g );

        jQuery.map(jQuery( '#AtD_add_ignore' ).val().split(/,\s*/g), function(value, index) { ignored.push(value); });

        jQuery( '#AtD_ignored_phrases' ).val( ignored.join(',') );

	/* update the UI */
	atd_show_phrases( ignored );
	jQuery( '#AtD_add_ignore' ).val('');             

	/* show that nifteroo messaroo to the useroo */
        jQuery( '#AtD_message' ).show(); 
}

function atd_ignore_init() {
	jQuery( '#AtD_message' ).hide();
	atd_show_phrases( jQuery( '#AtD_ignored_phrases' ).val().split( /,/g ) );
}

/* document.ready() does not execute in IE6 unless it's at the bottom of the page. oi! */
if (navigator.appName == 'Microsoft Internet Explorer')
	setTimeout( atd_ignore_init, 2500 );
else
	jQuery( document ).ready( atd_ignore_init );
</script>
   <input type="hidden" name="AtD_ignored_phrases" id="AtD_ignored_phrases" value="<?php 
    echo esc_attr($ignores);
    ?>
">

          <p style="font-weight: bold"><?php 
    _e('Ignored Phrases', 'after-the-deadline');
    ?>
</font>
     
          <p><?php 
    _e('Identify words and phrases to ignore while proofreading your posts and pages:', 'after-the-deadline');
    ?>
</p>

          <p><input type="text" id="AtD_add_ignore" name="AtD_add_ignore"> <input type="button" value="<?php 
    _e('Add', 'after-the-deadline');
    ?>
" onclick="javascript:atd_ignore()"></p>

          <div class="tagchecklist" id="atd_ignores"></div>

          <div class="plugin-update-tr" id="AtD_message" style="display: none">
          <div class="update-message"><strong><?php 
    _e('Be sure to click "Update Profile" at the bottom of the screen to save your changes.', 'after-the-deadline');
    ?>
</strong></div>
          </div>

         </td>
      </tr>
   </table>

<?php 
}