当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_text_diff函数代码示例

本文整理汇总了PHP中wp_text_diff函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_text_diff函数的具体用法?PHP wp_text_diff怎么用?PHP wp_text_diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_text_diff函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_get_revision_ui_diff

/**
 * Get the revision UI diff.
 *
 * @since 3.6.0
 *
 * @param object $post The post object.
 * @param int $compare_from The revision id to compare from.
 * @param int $compare_to The revision id to come to.
 *
 * @return array|bool Associative array of a post's revisioned fields and their diffs.
 * 	Or, false on failure.
 */
function wp_get_revision_ui_diff($post, $compare_from, $compare_to)
{
    if (!($post = get_post($post))) {
        return false;
    }
    if ($compare_from) {
        if (!($compare_from = get_post($compare_from))) {
            return false;
        }
    } else {
        // If we're dealing with the first revision...
        $compare_from = false;
    }
    if (!($compare_to = get_post($compare_to))) {
        return false;
    }
    // If comparing revisions, make sure we're dealing with the right post parent.
    // The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves.
    if ($compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID) {
        return false;
    }
    if ($compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID) {
        return false;
    }
    if ($compare_from && strtotime($compare_from->post_date_gmt) > strtotime($compare_to->post_date_gmt)) {
        $temp = $compare_from;
        $compare_from = $compare_to;
        $compare_to = $temp;
    }
    // Add default title if title field is empty
    if ($compare_from && empty($compare_from->post_title)) {
        $compare_from->post_title = __('(no title)');
    }
    if (empty($compare_to->post_title)) {
        $compare_to->post_title = __('(no title)');
    }
    $return = array();
    foreach (_wp_post_revision_fields() as $field => $name) {
        $content_from = $compare_from ? apply_filters("_wp_post_revision_field_{$field}", $compare_from->{$field}, $field, $compare_from, 'from') : '';
        $content_to = apply_filters("_wp_post_revision_field_{$field}", $compare_to->{$field}, $field, $compare_to, 'to');
        $diff = wp_text_diff($content_from, $content_to, array('show_split_view' => true));
        if (!$diff && 'post_title' === $field) {
            // It's a better user experience to still show the Title, even if it didn't change.
            // No, you didn't see this.
            $diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>';
            $diff .= '<td>' . esc_html($compare_from->post_title) . '</td><td></td><td>' . esc_html($compare_to->post_title) . '</td>';
            $diff .= '</tr></tbody>';
            $diff .= '</table>';
        }
        if ($diff) {
            $return[] = array('id' => $field, 'name' => $name, 'diff' => $diff);
        }
    }
    return $return;
}
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:67,代码来源:revision.php

示例2: diff

 public function diff()
 {
     // make sure the keys are set on $left and $right so we don't get any undefined errors
     $field_keys = array_fill_keys($this->fields_to_add, null);
     $left = array_merge($field_keys, (array) $this->left);
     $right = array_merge($field_keys, (array) $this->right);
     $identical = true;
     $rev_fields = array();
     foreach (_wp_post_revision_fields() as $field => $field_title) {
         $left_content = apply_filters("_wp_post_revision_field_{$field}", $left[$field], $field);
         $right_content = apply_filters("_wp_post_revision_field_{$field}", $right[$field], $field);
         if (!($content = wp_text_diff($left_content, $right_content))) {
             continue;
         }
         // There is no difference between left and right
         $identical = false;
         $rev_fields[] = array('field' => $field, 'title' => $field_title, 'content' => $content);
     }
     return $identical ? false : $rev_fields;
 }
开发者ID:gregoryfu,项目名称:wp-draft-revisions,代码行数:20,代码来源:Diff.php

示例3: time

if ( !isset($post_ID) || 0 == $post_ID ) {
	$form_action = 'post';
	$temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
	$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
	$autosave = false;
} else {
	$post_ID = (int) $post_ID;
	$form_action = 'editpost';
	$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
	$autosave = wp_get_post_autosave( $post_id );

	// Detect if there exists an autosave newer than the post and if that autosave is different than the post
	if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) {
		foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
			if ( wp_text_diff( $autosave->$autosave_field, $post->$autosave_field ) ) {
				$notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
				break;
			}
		}
		unset($autosave_field, $_autosave_field);
	}
}

?>
<?php if ( $notice ) : ?>
<div id="notice" class="error"><p><?php echo $notice ?></p></div>
<?php endif; ?>
<?php if (isset($_GET['message'])) : ?>
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
<?php endif; ?>
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:30,代码来源:edit-form-advanced.php

示例4: __

$notices[1] = __('There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>.');
if (!isset($post_ID) || 0 == $post_ID) {
    $form_action = 'post';
    $temp_ID = -1 * time();
    // don't change this formula without looking at wp_write_post()
    $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='{$temp_ID}' />";
    $autosave = false;
} else {
    $post_ID = (int) $post_ID;
    $form_action = 'editpost';
    $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='{$post_ID}' />";
    $autosave = wp_get_post_autosave($post_id);
    // Detect if there exists an autosave newer than the post and if that autosave is different than the post
    if ($autosave && mysql2date('U', $autosave->post_modified_gmt) > mysql2date('U', $post->post_modified_gmt)) {
        foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
            if (wp_text_diff($autosave->{$autosave_field}, $post->{$autosave_field})) {
                $notice = sprintf($notices[1], get_edit_post_link($autosave->ID));
                break;
            }
        }
        unset($autosave_field, $_autosave_field);
    }
}
if ($notice) {
    ?>
<div id="notice" class="error"><p><?php 
    echo $notice;
    ?>
</p></div>
<?php 
}
开发者ID:nurpax,项目名称:saastafi,代码行数:31,代码来源:edit-form-advanced.php

示例5: wp_get_revision_ui_diff

/**
 * Get the revision UI diff.
 *
 * @since 3.6.0
 *
 * @param object|int $post         The post object. Also accepts a post ID.
 * @param int        $compare_from The revision ID to compare from.
 * @param int        $compare_to   The revision ID to come to.
 *
 * @return array|bool Associative array of a post's revisioned fields and their diffs.
 *                    Or, false on failure.
 */
function wp_get_revision_ui_diff($post, $compare_from, $compare_to)
{
    if (!($post = get_post($post))) {
        return false;
    }
    if ($compare_from) {
        if (!($compare_from = get_post($compare_from))) {
            return false;
        }
    } else {
        // If we're dealing with the first revision...
        $compare_from = false;
    }
    if (!($compare_to = get_post($compare_to))) {
        return false;
    }
    // If comparing revisions, make sure we're dealing with the right post parent.
    // The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves.
    if ($compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID) {
        return false;
    }
    if ($compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID) {
        return false;
    }
    if ($compare_from && strtotime($compare_from->post_date_gmt) > strtotime($compare_to->post_date_gmt)) {
        $temp = $compare_from;
        $compare_from = $compare_to;
        $compare_to = $temp;
    }
    // Add default title if title field is empty
    if ($compare_from && empty($compare_from->post_title)) {
        $compare_from->post_title = __('(no title)');
    }
    if (empty($compare_to->post_title)) {
        $compare_to->post_title = __('(no title)');
    }
    $return = array();
    foreach (_wp_post_revision_fields() as $field => $name) {
        /**
         * Contextually filter a post revision field.
         *
         * The dynamic portion of the hook name, `$field`, corresponds to each of the post
         * fields of the revision object being iterated over in a foreach statement.
         *
         * @since 3.6.0
         *
         * @param string  $compare_from->$field The current revision field to compare to or from.
         * @param string  $field                The current revision field.
         * @param WP_Post $compare_from         The revision post object to compare to or from.
         * @param string  null                  The context of whether the current revision is the old
         *                                      or the new one. Values are 'to' or 'from'.
         */
        $content_from = $compare_from ? apply_filters("_wp_post_revision_field_{$field}", $compare_from->{$field}, $field, $compare_from, 'from') : '';
        /** This filter is documented in wp-admin/includes/revision.php */
        $content_to = apply_filters("_wp_post_revision_field_{$field}", $compare_to->{$field}, $field, $compare_to, 'to');
        $args = array('show_split_view' => true);
        /**
         * Filter revisions text diff options.
         *
         * Filter the options passed to {@see wp_text_diff()} when viewing a post revision.
         *
         * @since 4.1.0
         *
         * @param array   $args {
         *     Associative array of options to pass to {@see wp_text_diff()}.
         *
         *     @type bool $show_split_view True for split view (two columns), false for
         *                                 un-split view (single column). Default true.
         * }
         * @param string  $field        The current revision field.
         * @param WP_Post $compare_from The revision post to compare from.
         * @param WP_Post $compare_to   The revision post to compare to.
         */
        $args = apply_filters('revision_text_diff_options', $args, $field, $compare_from, $compare_to);
        $diff = wp_text_diff($content_from, $content_to, $args);
        if (!$diff && 'post_title' === $field) {
            // It's a better user experience to still show the Title, even if it didn't change.
            // No, you didn't see this.
            $diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>';
            $diff .= '<td>' . esc_html($compare_from->post_title) . '</td><td></td><td>' . esc_html($compare_to->post_title) . '</td>';
            $diff .= '</tr></tbody>';
            $diff .= '</table>';
        }
        if ($diff) {
            $return[] = array('id' => $field, 'name' => $name, 'diff' => $diff);
        }
    }
    /**
//.........这里部分代码省略.........
开发者ID:psycle,项目名称:wordpress,代码行数:101,代码来源:revision.php

示例6: get_side_by_side_diff

    private function get_side_by_side_diff($post_id, $original_post_id)
    {
        ob_start();
        $post = get_post($post_id);
        $original_post = get_post($original_post_id);
        $fields = array(array("type" => "wp", "name" => "title"), array("type" => "wp", "name" => "content"));
        // Get all acf field groups
        /*$field_groups = get_posts(array("post_type"=>"acf", "posts_per_page"=>-1));
        		foreach($field_groups as $field_group){
        			$fields = array_merge($fields, $this->get_acf_field_for_diff( $field_group->ID ) );
        		}*/
        // Get ACF Fields of the original post and add them to fields array
        $acf_meta = get_post_custom($original_post_id);
        $acf_field_keys = array();
        foreach ($acf_meta as $key => $val) {
            if (preg_match("/^field_/", $val[0])) {
                if (function_exists('get_field_object')) {
                    $acf_field = get_field_object($val[0]);
                    if ($acf_field["type"] == "tab" || in_array($acf_field["key"], $acf_field_keys)) {
                        continue;
                    }
                    $acf_field_keys[] = $acf_field["key"];
                    $fields[] = array("type" => "acf", "name" => $acf_field["key"]);
                }
            }
        }
        // Get post taxonomies
        $fields = array_merge($fields, $this->get_post_taxonomies_for_diff($post));
        // Include two sample files for comparison
        echo "<div class='all_differences'>";
        echo "<table width='100%' class='Differences diff_header'><tr>\n\t\t  <th></th>\n\t\t  <td>Old: <a href='" . get_edit_post_link($original_post) . "'>" . $original_post->post_title . "</a></td>\n\t\t  <th></th>\n\t\t  <td>New: <a href='" . get_edit_post_link($post) . "'>" . $post->post_title . "</a></td>\n\t\t</tr></table>";
        foreach ($fields as $field) {
            $a = $this->get_string_value($field, $original_post_id, $original_post);
            $b = $this->get_string_value($field, $post_id, $post);
            $field["label"] = ucfirst($field["label"]);
            $diff_html = wp_text_diff($a, $b);
            if ($diff_html != "") {
                ?>
		  <h3 class="diff_field_title"><?php 
                echo $field["label"];
                ?>
</h3>
		  <?php 
                echo $diff_html;
            }
        }
        echo "</div>";
        ?>
		<style type="text/css">
		.ChangeReplace, .Differences.DifferencesSideBySide {max-width: 100%;}
		.all_differences{
		  background:white;
		  padding:15px;
		  box-shadow: 0 1px 3px rgba(0,0,0,.1);
		}
		.Differences {
		  width:100%;
		}
		.Differences td{
		  width:46%;
		}
		.Differences .Left{
		}
		.Differences .ChangeInsert .Right{
		  background:#e9ffe9;
		}
		.Differences .ChangeInsert .Right ins{
		  background:#afa;
		}
		.Differences .ChangeDelete .Left{
		  background:#ffe9e9;
		}
		.Differences .ChangeDelete .Left del{
		  background:#faa;
		}
		.Differences .ChangeReplace .Right{
		  background:#e9ffe9;
		}
		.Differences .ChangeReplace .Right ins{
		  background:#afa;
		}
		.Differences .ChangeReplace .Left{
		  background:#ffe9e9;
		}
		.Differences .ChangeReplace .Left del{
		  background:#faa;
		}
		.Differences tr td{
		  padding:5px 5px;
		}
		.Differences th:first-child{
		  display:none;
		}
		.Differences th{
		  text-indent:-100000;
		  width:4%;
		  color:white;
		  font-size:0px;
		}
		.diff_field_title{
//.........这里部分代码省略.........
开发者ID:CybMeta,项目名称:duplicate-and-merge-posts,代码行数:101,代码来源:duplicate-post.php

示例7: render_updated_translations_table

 /**
  * @param $updated_translations array of updated string translations
  *
  * @return string html of the table holding the updated string translations
  */
 private function render_updated_translations_table($updated_translations)
 {
     $html = '<h3>' . sprintf(__('Updated translations (%d)', 'wpml-string-translation'), count($updated_translations)) . '</h3>';
     $html .= '<table id="icl_admo_list_table" class="widefat">';
     $html .= '<thead><tr>';
     $html .= '<th class="manage-column column-cb check-column" scope="col"><input type="checkbox" name="" value="" checked="checked" /></th>';
     $html .= '<th>' . __('String', 'wpml-string-translation') . '</th>';
     $html .= '<th style="text-align:center;">' . __('Existing translation', 'wpml-string-translation') . '</th>';
     $html .= '<th style="text-align:center;">' . __('New translation', 'wpml-string-translation') . '</th>';
     $html .= '</tr></thead>	<tbody>';
     foreach ($updated_translations as $idx => $translation) {
         $html .= '<tr><td class="column-cb">';
         $html .= '<input type="hidden" name="selected[' . $idx . ']" value="0" />';
         $html .= '<input type="checkbox" name="selected[' . $idx . ']" value="1"  checked="checked" />';
         $html .= '</td><td>';
         $html .= esc_html($translation['string']);
         $html .= '<input type="hidden" name="string[' . $idx . ']" value="' . base64_encode($translation['string']) . '" />';
         $html .= '<input type="hidden" name="name[' . $idx . ']" value="' . base64_encode($translation['name']) . '" />';
         $html .= '</td><td colspan="2">';
         $html .= wp_text_diff($translation['translation'], $translation['new']);
         $html .= '<input type="hidden" name="translation[' . $idx . ']" value="' . base64_encode($translation['new']) . '" />';
         $html .= '</td></tr>';
     }
     $html .= '</tbody><tfoot><tr>';
     $html .= '<th class="manage-column column-cb check-column" scope="col"><input type="checkbox" name="" value="" checked="checked" /></th>';
     $html .= '<th>' . __('String', 'wpml-string-translation') . '</th>';
     $html .= '<th style="text-align:center;">' . __('Existing translation', 'wpml-string-translation') . '</th>';
     $html .= '<th style="text-align:center;">' . __('New translation', 'wpml-string-translation') . '</th>';
     $html .= '</tr></tfoot>';
     $html .= '</table>';
     return $html;
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:37,代码来源:wpml-string-translation-mo-import.class.php

示例8: wsc_mod_rewrite

function wsc_mod_rewrite()
{
    global $cache_enabled, $super_cache_enabled, $valid_nonce, $cache_path, $wp_cache_mod_rewrite, $wpmu_version;
    if (!$wp_cache_mod_rewrite) {
        return false;
    }
    if (isset($wpmu_version) || function_exists('is_multisite') && is_multisite()) {
        if (false == wpsupercache_site_admin()) {
            return false;
        }
        if (function_exists("is_main_site") && false == is_main_site() || function_exists('is_main_blog') && false == is_main_blog()) {
            global $current_site;
            $protocol = 'on' == strtolower($_SERVER['HTTPS']) ? 'https://' : 'http://';
            if (isset($wpmu_version)) {
                $link_to_admin = admin_url("wpmu-admin.php?page=wpsupercache");
            } else {
                $link_to_admin = admin_url("ms-admin.php?page=wpsupercache");
            }
            echo '<div id="message" class="updated fade"><p>' . sprintf(__('Notice: WP Super Cache mod_rewrite rule checks disabled unless running on <a href="%s">the main site</a> of this network.', 'wp-super-cache'), $link_to_admin) . '</p></div>';
            return false;
        }
    }
    if (function_exists("is_main_site") && false == is_main_site() || function_exists('is_main_blog') && false == is_main_blog()) {
        return true;
    }
    ?>
	<a name="modrewrite"></a><fieldset class="options"> 
	<h3><?php 
    _e('Mod Rewrite Rules', 'wp-super-cache');
    ?>
</h3><?php 
    extract(wpsc_get_htaccess_info());
    $dohtaccess = true;
    global $wpmu_version;
    if (isset($wpmu_version)) {
        echo "<h4 style='color: #a00'>" . __('WordPress MU Detected', 'wp-super-cache') . "</h4><p>" . __("Unfortunately the rewrite rules cannot be updated automatically when running WordPress MU. Please open your .htaccess and add the following mod_rewrite rules above any other rules in that file.", 'wp-super-cache') . "</p>";
    } elseif (!$wprules || $wprules == '') {
        echo "<h4 style='color: #a00'>" . __('Mod Rewrite rules cannot be updated!', 'wp-super-cache') . "</h4>";
        echo "<p>" . sprintf(__("You must have <strong>BEGIN</strong> and <strong>END</strong> markers in %s.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:", 'wp-super-cache'), $home_path);
        echo "<blockquote><pre><em># BEGIN WordPress</em>\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n <em># END WordPress</em></pre></blockquote>";
        _e('Refresh this page when you have updated your .htaccess file.', 'wp-super-cache');
        echo "</fieldset>";
        $dohtaccess = false;
    } elseif (strpos($wprules, 'wordpressuser')) {
        // Need to clear out old mod_rewrite rules
        echo "<p><strong>" . __('Thank you for upgrading.', 'wp-super-cache') . "</strong> " . sprintf(__('The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: %1$s so it looks like this: %2$s The only changes are "HTTP_COOKIE" becomes "HTTP:Cookie" and "wordpressuser" becomes "wordpress". This is a WordPress 2.5 change but it&#8217;s backwards compatible with older versions if you&#8217;re brave enough to use them.', 'wp-super-cache'), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>') . "</p>";
        echo "</fieldset></div>";
        return;
    } elseif ($scrules != '' && strpos($scrules, '%{REQUEST_URI} !^.*[^/]$') === false && substr(get_option('permalink_structure'), -1) == '/') {
        // permalink structure has a trailing slash, need slash check in rules.
        echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __('Trailing slash check required.', 'wp-super-cache') . "</h4><p>" . __('It looks like your blog has URLs that end with a "/". Unfortunately since you installed this plugin a duplicate content bug has been found where URLs not ending in a "/" end serve the same content as those with the "/" and do not redirect to the proper URL. To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:', 'wp-super-cache') . "</p>";
        echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]{$RewriteCond} %{REQUEST_URI} !^.*//.*\$</code></blockquote>";
        echo "<p>" . __('You can see where the rules go and examine the complete rules by clicking the "View mod_rewrite rules" link below.', 'wp-super-cache') . "</p></div>";
        $dohtaccess = false;
    } elseif (strpos($scrules, 'supercache') || strpos($wprules, 'supercache')) {
        // only write the rules once
        $dohtaccess = false;
    }
    if ($dohtaccess && !$_POST['updatehtaccess']) {
        if ($scrules == '') {
            wpsc_update_htaccess_form(0);
            // don't hide the update htaccess form
        } else {
            wpsc_update_htaccess_form();
        }
    } elseif ($valid_nonce && $_POST['updatehtaccess']) {
        echo "<div style='padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
        if (wpsc_update_htaccess()) {
            echo "<h4>" . __('Mod Rewrite rules updated!', 'wp-super-cache') . "</h4>";
            echo "<p><strong>" . sprintf(__('%s.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:', 'wp-super-cache'), $home_path) . "</strong></p>\n";
        } else {
            echo "<h4>" . __('Mod Rewrite rules must be updated!', 'wp-super-cache') . "</h4>";
            echo "<p><strong>" . sprintf(__('Your %s.htaccess is not writable by the webserver and must be updated with the necessary mod_rewrite rules. The new rules go above the regular WordPress rules as shown in the code below:', 'wp-super-cache'), $home_path) . "</strong></p>\n";
        }
        echo "<p><pre>" . esc_html($rules) . "</pre></p>\n</div>";
    } else {
        ?>
		<p><?php 
        printf(__('WP Super Cache mod rewrite rules were detected in your %s.htaccess file.<br /> Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match.', 'wp-super-cache'), $home_path);
        ?>
</p>
		<?php 
        if ($rules != $scrules) {
            ?>
<p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><?php 
            _e('A difference between the rules in your .htaccess file and the plugin rewrite rules has been found. This could be simple whitespace differences but you should compare the rules in the file with those below as soon as possible. Click the &#8217;Update Mod_Rewrite Rules&#8217; button to update the rules.', 'wp-super-cache');
            ?>
</p><?php 
        }
        ?>
<a href="javascript:toggleLayer('rewriterules');" class="button"><?php 
        _e('View Mod_Rewrite Rules', 'wp-super-cache');
        ?>
</a><?php 
        wpsc_update_htaccess_form();
        echo "<div id='rewriterules' style='display: none;'>";
        if ($rules != $scrules) {
            echo '<div style="background: #fff; border: 1px solid #333; margin: 2px;">' . wp_text_diff($scrules, $rules, array('title' => 'Rewrite Rules', 'title_left' => 'Current Rules', 'title_right' => 'New Rules')) . "</div>";
        }
        echo "<p><pre># BEGIN WPSuperCache\n" . esc_html($rules) . "# END WPSuperCache</pre></p>\n";
//.........这里部分代码省略.........
开发者ID:popovdenis,项目名称:kmst,代码行数:101,代码来源:wp-cache.php

示例9: compare_revisions_iframe

    static function compare_revisions_iframe()
    {
        //add_action('admin_init', 'register_admin_colors', 1);
        set_current_screen('revision-edit');
        $left = isset($_GET['left']) ? absint($_GET['left']) : false;
        $right = isset($_GET['right']) ? absint($_GET['right']) : false;
        if (!($left_revision = get_post($left))) {
            return;
        }
        if (!($right_revision = get_post($right))) {
            return;
        }
        if (!current_user_can('read_post', $left_revision->ID) || !current_user_can('read_post', $right_revision->ID)) {
            return;
        }
        // Don't allow reverse diffs?
        if (strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt)) {
            //$redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
            // Switch-a-roo
            $temp_revision = $left_revision;
            $left_revision = $right_revision;
            $right_revision = $temp_revision;
            unset($temp_revision);
        }
        global $post;
        if ($left_revision->ID == $right_revision->post_parent) {
            // right is a revision of left
            $post = $left_revision;
        } elseif ($left_revision->post_parent == $right_revision->ID) {
            // left is a revision of right
            $post = $right_revision;
        } elseif ($left_revision->post_parent == $right_revision->post_parent) {
            // both are revisions of common parent
            $post = get_post($left_revision->post_parent);
        } else {
            wp_die(__('Sorry, But you cant compare unrelated Revisions.', 'revision-control'));
        }
        // Don't diff two unrelated revisions
        if ($left_revision->ID == $right_revision->ID || !wp_get_post_revision($left_revision->ID) && !wp_get_post_revision($right_revision->ID)) {
            wp_die(__('Sorry, But you cant compare a Revision to itself.', 'revision-control'));
        }
        $title = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;', 'revision-control'), get_the_title());
        $left = $left_revision->ID;
        $right = $right_revision->ID;
        $GLOBALS['hook_suffix'] = 'revision-control';
        wp_enqueue_style('revision-control');
        iframe_header();
        ?>
		<div class="wrap">
		
		<h2 class="long-header center"><?php 
        echo $title;
        ?>
</h2>
		
		<table class="form-table ie-fixed">
			<col class="th" />
		<tr id="revision">
			<th scope="col" class="th-full">
				<?php 
        printf(__('Older: %s', 'revision-control'), wp_post_revision_title($left_revision, false));
        ?>
				<span class="alignright"><?php 
        printf(__('Newer: %s', 'revision-control'), wp_post_revision_title($right_revision, false));
        ?>
</span>
			</th>
		</tr>
		<?php 
        $fields = _wp_post_revision_fields();
        foreach (get_object_taxonomies($post->post_type) as $taxonomy) {
            $t = get_taxonomy($taxonomy);
            $fields[$taxonomy] = $t->label;
            $left_terms = $right_terms = array();
            foreach (wp_get_object_terms($left_revision->ID, $taxonomy) as $term) {
                $left_terms[] = $term->name;
            }
            foreach (wp_get_object_terms($right_revision->ID, $taxonomy) as $term) {
                $right_terms[] = $term->name;
            }
            $left_revision->{$taxonomy} = (empty($left_terms) ? '' : "* ") . join("\n* ", $left_terms);
            $right_revision->{$taxonomy} = (empty($right_terms) ? '' : "* ") . join("\n* ", $right_terms);
        }
        $fields['postmeta'] = __('Post Meta', 'revision-control');
        $left_revision->postmeta = $right_revision->postmeta = array();
        foreach ((array) has_meta($right_revision->ID) as $meta) {
            if ('_' == $meta['meta_key'][0]) {
                continue;
            }
            $right_revision->postmeta[] = $meta['meta_key'] . ': ' . $meta['meta_value'];
            $left_val = get_post_meta('post', $left_revision->ID, $meta['meta_key'], true);
            if (!empty($left_val)) {
                $left_revision->postmeta[] = $meta['meta_key'] . ': ' . $left_val;
            }
        }
        $right_revision->postmeta = implode("\n", $right_revision->postmeta);
        $left_revision->postmeta = implode("\n", $left_revision->postmeta);
        $identical = true;
        foreach ($fields as $field => $field_title) {
            if (!($content = wp_text_diff($left_revision->{$field}, $right_revision->{$field}))) {
//.........这里部分代码省略.........
开发者ID:Karpec,项目名称:geo-mac,代码行数:101,代码来源:revision-control.php

示例10: foreach

    ?>
" />
                            
                            <?php 
    if (!$element->field_finished && !empty($job->prev_version)) {
        ?>
                            
                                <?php 
        $prev_value = '';
        foreach ($job->prev_version->elements as $pel) {
            if ($element->field_type == $pel->field_type) {
                $prev_value = TranslationManagement::decode_field_data($pel->field_data, $pel->field_format);
            }
        }
        if ($element->field_format != 'csv_base64') {
            $diff = wp_text_diff($prev_value, TranslationManagement::decode_field_data($element->field_data, $element->field_format));
        }
        if (!empty($diff)) {
            ?>
                                        <p><a href="#" onclick="jQuery(this).parent().next().slideToggle();return false;"><?php 
            _e('Show Changes', 'sitepress');
            ?>
</a></p>
                                        <div class="icl_tm_diff">
                                            <?php 
            echo $diff;
            ?>
                                        </div>
                                        <?php 
        }
        ?>
开发者ID:GeographicaGS,项目名称:gis-coast,代码行数:31,代码来源:translation-editor.php

示例11: tdomf_form_hacker_diff


//.........这里部分代码省略.........
                $form2 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK_ORIGINAL, $form_id));
            } else {
                if ($form2_type == 'hack') {
                    $form2_name = __('Hacked Form', 'tdomf');
                    $form2 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK, $form_id));
                }
            }
        }
    }
    ?>
 
  <h2><?php 
    printf(__('Form Diff: %s versus %s', 'tdomf'), $form1_name, $form2_name);
    ?>
</h2>
  <?php 
    echo "<form>";
    echo "<input type='hidden' id='page' name='page' value='tdomf_show_form_hacker' />";
    echo "<input type='hidden' id='form' name='form' value='{$form_id}' />";
    echo "<input type='hidden' id='mode' name='mode' value='{$mode}' />";
    echo "<input type='hidden' id='diff' name='diff' />";
    echo "<input type='hidden' id='form2' name='form2' value='{$form2_type}' />";
    echo "<input type='hidden' id='form1' name='form1' value='{$form1_type}' />";
    echo "<input type='hidden' id='type' name='type' value='{$type}' />";
    echo '<label for="render">' . __('Render Type', 'tdomf') . ' </label>';
    echo '<select id="render" name="render">';
    echo '<option value="wp" ';
    if ($render == 'wp') {
        echo 'selected';
    }
    echo ' >' . __('Wordpress', 'tdomf') . "\n<br/>";
    echo '<option value="default" ';
    if ($render == 'default') {
        echo 'selected';
    }
    echo ' >' . __('Default', 'tdomf') . "\n<br/>";
    echo '<option value="unified" ';
    if ($render == 'unified') {
        echo 'selected';
    }
    echo ' >' . __('Unified', 'tdomf') . "\n<br/>";
    echo '<option value="inline" ';
    if ($render == 'inline') {
        echo 'selected';
    }
    echo ' >' . __('Inline', 'tdomf') . "\n<br/>";
    echo '<option value="context" ';
    if ($render == 'context') {
        echo 'selected';
    }
    echo ' >' . __('Context', 'tdomf') . "\n<br/>";
    echo '</select>';
    echo '<input type="submit" value="' . __('Go', 'tdomf') . '" /></form><br/><br/>';
    if ($render == 'wp') {
        $args = array('title_left' => $form1_name, 'title_right' => $form2_name);
        if (!($content = wp_text_diff($form1, $form2, $args))) {
            echo "<p>" . sprintf(__('%s is the same as %s!', 'tdomf'), $form1_name, $form2_name) . "</p>";
            return;
        } else {
            ?>
          <p><i><?php 
            _e('Form code may contain lines that cannot be wrapped in a browser, so you may need to scroll a lot left to see the other form', 'tdomf');
            ?>
</i></p>
          <?php 
            echo $content;
        }
    } else {
        set_include_path(get_include_path() . PATH_SEPARATOR . ABSPATH . PLUGINDIR . DIRECTORY_SEPARATOR . TDOMF_FOLDER . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'include');
        include_once "Text/Diff.php";
        $form1 = explode("\n", $form1);
        $form2 = explode("\n", $form2);
        $diff =& new Text_Diff('auto', array($form1, $form2));
        if ($diff->isEmpty()) {
            echo "<p>" . sprintf(__('%s is the same as %s!', 'tdomf'), $form1_name, $form2_name) . "</p>";
            return;
        }
        if ($render == 'unified') {
            include_once "Text/Diff/Renderer/unified.php";
            $renderer =& new Text_Diff_Renderer_unified();
            echo "<pre>" . htmlentities($renderer->render($diff), ENT_NOQUOTES, get_bloginfo('charset')) . "</pre>";
        } else {
            if ($render == 'inline') {
                include_once "Text/Diff/Renderer/inline.php";
                $renderer =& new Text_Diff_Renderer_inline();
                echo "<pre>" . $renderer->render($diff) . "</pre>";
            } else {
                if ($render == 'context') {
                    include_once "Text/Diff/Renderer/context.php";
                    $renderer =& new Text_Diff_Renderer_context();
                    echo "<pre>" . htmlentities($renderer->render($diff), ENT_NOQUOTES, get_bloginfo('charset')) . "</pre>";
                } else {
                    include_once "Text/Diff/Renderer.php";
                    $renderer =& new Text_Diff_Renderer();
                    echo "<pre>" . htmlentities($renderer->render($diff), ENT_NOQUOTES, get_bloginfo('charset')) . "</pre>";
                }
            }
        }
    }
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:101,代码来源:tdomf-form-hacker.php

示例12: postmeta_display_callback

 /**
  * Displays value for post meta, or diff of two.
  *
  * @param object|array|string $left_value
  * @param object|array|string $right_value
  * @return string Display of the diff.
  */
 public static function postmeta_display_callback($left_value, $right_value = null)
 {
     $content = self::get_printable($left_value);
     if (!is_null($right_value)) {
         $right_value = self::get_printable($right_value);
         $content = wp_text_diff($content, $right_value);
     }
     return $content;
 }
开发者ID:netconstructor,项目名称:meta-revisions,代码行数:16,代码来源:meta-revisions.php

示例13: compare_revisions_iframe

    function compare_revisions_iframe()
    {
        if (function_exists('register_admin_colors')) {
            add_action('admin_init', 'register_admin_colors', 1);
        } else {
            // Hard coded translation strings here as the translations are not required, just the name and stlesheet.
            wp_admin_css_color('classic', 'Blue', admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7'));
            wp_admin_css_color('fresh', 'Gray', admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF'));
        }
        $left = isset($_GET['left']) ? absint($_GET['left']) : false;
        $right = isset($_GET['right']) ? absint($_GET['right']) : false;
        if (!($left_revision = get_post($left))) {
            break;
        }
        if (!($right_revision = get_post($right))) {
            break;
        }
        if (!current_user_can('read_post', $left_revision->ID) || !current_user_can('read_post', $right_revision->ID)) {
            break;
        }
        // Don't allow reverse diffs?
        if (strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt)) {
            //$redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
            // Switch-a-roo
            $temp_revision = $left_revision;
            $left_revision = $right_revision;
            $right_revision = $temp_revision;
            unset($temp_revision);
        }
        global $post;
        if ($left_revision->ID == $right_revision->post_parent) {
            // right is a revision of left
            $post = $left_revision;
        } elseif ($left_revision->post_parent == $right_revision->ID) {
            // left is a revision of right
            $post = $right_revision;
        } elseif ($left_revision->post_parent == $right_revision->post_parent) {
            // both are revisions of common parent
            $post = get_post($left_revision->post_parent);
        } else {
            wp_die(__('Sorry, But you cant compare unrelated Revisions.', 'revision-control'));
        }
        // Don't diff two unrelated revisions
        if ($left_revision->ID == $right_revision->ID || !wp_get_post_revision($left_revision->ID) && !wp_get_post_revision($right_revision->ID)) {
            wp_die(__('Sorry, But you cant compare a Revision to itself.', 'revision-control'));
        }
        $title = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;', 'revision-control'), get_the_title());
        $left = $left_revision->ID;
        $right = $right_revision->ID;
        iframe_header();
        ?>
		<div class="wrap">
		
		<h2 class="long-header center"><?php 
        echo $title;
        ?>
</h2>
		
		<table class="form-table ie-fixed">
			<col class="th" />
		<tr id="revision">
			<th scope="col" class="th-full">
				<?php 
        printf(__('Older: %s', 'revision-control'), wp_post_revision_title($left_revision, false));
        ?>
				<span class="alignright"><?php 
        printf(__('Newer: %s', 'revision-control'), wp_post_revision_title($right_revision, false));
        ?>
</span>
			</th>
		</tr>
		<?php 
        $fields = _wp_post_revision_fields();
        foreach (get_object_taxonomies($post->post_type) as $taxonomy) {
            $t = get_taxonomy($taxonomy);
            $fields[$taxonomy] = $t->label;
            $left_terms = $right_terms = array();
            foreach (wp_get_object_terms($left_revision->ID, $taxonomy) as $term) {
                $left_terms[] = $term->name;
            }
            foreach (wp_get_object_terms($right_revision->ID, $taxonomy) as $term) {
                $right_terms[] = $term->name;
            }
            $left_revision->{$taxonomy} = (empty($left_terms) ? '' : "* ") . join("\n* ", $left_terms);
            $right_revision->{$taxonomy} = (empty($right_terms) ? '' : "* ") . join("\n* ", $right_terms);
        }
        $identical = true;
        foreach ($fields as $field => $field_title) {
            if (!($content = wp_text_diff($left_revision->{$field}, $right_revision->{$field}))) {
                continue;
            }
            // There is no difference between left and right
            $identical = false;
            ?>
			<tr>
				<th scope="row"><strong><?php 
            echo esc_html($field_title);
            ?>
</strong></th>
			</tr>
//.........这里部分代码省略.........
开发者ID:niko-lgdcom,项目名称:archives,代码行数:101,代码来源:revision-control.php

示例14: page_edit_notification

    /**
     * wiki_page_edit_notification 
     * @global <type> $wpdb
     * @param <type> $pageID
     * @return NULL
     */
    function page_edit_notification($pageID)
    {
        global $wpdb;
        // First, make sure this *is* a Wiki page -CWJ
        $p = get_post($pageID);
        if ($p->post_type == 'wiki') {
            $revisions = get_children(array('post_type' => 'revision', 'post_parent' => $pageID, 'orderby' => 'post_modified_gmt', 'order' => 'DESC'));
            $wpw_options = get_option('wpw_options');
            if ($wpw_options['email_admins'] == 1) {
                $emails = $this->getAllAdmins();
                $pageTitle = $p->post_title;
                $pagelink = get_permalink($pageID);
                $subject = "[" . get_bloginfo('title') . "] Wiki Change: " . $pageTitle;
                $message = '<p>' . sprintf(__("A Wiki Page has been modified on %s."), get_option('home'), $pageTitle) . '</p>';
                $message .= "\n\r";
                $message .= '<p>' . sprintf(__("The page title is %s"), $pageTitle) . '</p>';
                $message .= "\n\r";
                $message .= '<p>' . __('To visit this page, ') . '<a href="' . $pagelink . '">' . __('click here') . '</a></p>';
                $left_revision = reset($revisions);
                $right_revision = $p;
                ob_start();
                ?>
				<style type="text/css">
				table.diff .diff-deletedline {
					background-color: #FFDDDD;
				}
				table.diff .diff-deletedline del {
					background-color: #FF9999;
				}
				table.diff .diff-addedline {
					background-color: #DDFFDD;
				}
				table.diff diff.addedline ins {
					background-color: #99FF99;
				}
				</style>
				
				<table>
				<?php 
                $identical = true;
                foreach (_wp_post_revision_fields() as $field => $field_title) {
                    $left_content = apply_filters("_wp_post_revision_field_{$field}", $left_revision->{$field}, $field);
                    $right_content = apply_filters("_wp_post_revision_field_{$field}", $right_revision->{$field}, $field);
                    if (!($content = wp_text_diff($left_content, $right_content))) {
                        continue;
                    }
                    // There is no diff between left and right
                    $identical = false;
                    ?>

					<tr id="revision-field-<?php 
                    echo $field;
                    ?>
">
					<th scope="row"><?php 
                    echo esc_html($field_title);
                    ?>
</th>
					<td><div class="pre"><?php 
                    echo $content;
                    ?>
</div></td>
					</tr>
					<?php 
                }
                if ($identical) {
                    ?>
				<tr><td colspan="2"><div class="updated"><p><?php 
                    _e('These revisions are identical.');
                    ?>
</p></div></td></tr>
				<?php 
                }
                ?>
				</table>
				<?php 
                $message .= ob_get_clean();
                foreach ($emails as $email) {
                    add_filter('wp_mail_content_type', array($this, 'allow_html_mail'));
                    wp_mail($email, $subject, $message);
                    remove_filter('wp_mail_content_type', array($this, 'allow_html_mail'));
                }
            }
        }
    }
开发者ID:radgeek,项目名称:WikiWikiWordPress,代码行数:91,代码来源:wiki_notifications.php

示例15: array

 }
 if ($theme_file) {
     $parent_content = TPLC_Admin_Status::get_file_content(get_template_directory() . '/' . $file);
     $child_content = TPLC_Admin_Status::get_file_content($theme_file);
     $parent_version = TPLC_Admin_Status::get_file_version(get_template_directory() . '/' . $file);
     $child_version = TPLC_Admin_Status::get_file_version($theme_file);
     /* Broken table if used: @link https://core.trac.wordpress.org/ticket/25473
     
     					$args = array(
     						'title'           => 'Differences',
     						'title_left'      => 'Parent Theme',
     						'title_right'     => 'Child Theme'
     					); */
     // This is important and is missing in codex :(
     $args = array('show_split_view' => true);
     $diff_table = wp_text_diff($parent_content, $child_content, $args);
     $theme = wp_get_theme();
     $template = wp_get_theme($theme->template);
     if ($diff_table) {
         $message = '';
         // reset message if diff found
         if ($parent_version && $child_version && version_compare($child_version, $parent_version, '<')) {
             $status = '<span class="alignright dashicons dashicons-no-alt" style="color:red"></span>';
         } elseif (!$child_version && $parent_version) {
             $status = '<span class="alignright dashicons dashicons-info" style="color:orange"></span>';
         } elseif (!$parent_version) {
             $status = '<span class="alignright dashicons dashicons-minus"></span>';
         } else {
             $status = '<span class="alignright dashicons dashicons-yes" style="color:green"></span>';
         }
         printf('<h3 class="trigger">%s %s %s</h3>', __('Diff for template file:', 'tl-template-checker'), $file, $status);
开发者ID:rpkoller,项目名称:tl-template-checker,代码行数:31,代码来源:html-admin-page-status-diff.php


注:本文中的wp_text_diff函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。