예제 #1
0
/**
 * 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;
}
예제 #2
0
 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;
 }
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; ?>
예제 #4
0
$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 
}
예제 #5
0
/**
 * 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);
        }
    }
    /**
     * Filter the fields displayed in the post revision diff UI.
     *
     * @since 4.1.0
     *
     * @param array   $return       Revision UI fields. Each item is an array of id, name and diff.
     * @param WP_Post $compare_from The revision post to compare from.
     * @param WP_Post $compare_to   The revision post to compare to.
     */
    return apply_filters('wp_get_revision_ui_diff', $return, $compare_from, $compare_to);
}
    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{
		  margin-top:20px;
		  padding-bottom:5px;
		  border-bottom:1px solid rgba(0,0,0,0.1);
		}
		.diff_header{
		  padding-top:20px;
		  text-align: center;
		  font-size:18px;
		}
		</style>
		<?php 
        return ob_get_clean();
    }
 /**
  * @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;
 }
예제 #8
0
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";
        echo "<p>" . sprintf(__('Rules must be added to %s too:', 'wp-super-cache'), WP_CONTENT_DIR . "/cache/.htaccess") . "</p>";
        echo "<pre># BEGIN supercache\n" . esc_html($gziprules) . "# END supercache</pre></p>";
        echo '</div>';
    }
    // http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
    if (!is_file($cache_path . '.htaccess')) {
        $gziprules = insert_with_markers($cache_path . '.htaccess', 'supercache', explode("\n", $gziprules));
        echo "<h4>" . sprintf(__('Gzip encoding rules in %s.htaccess created.', 'wp-super-cache'), $cache_path) . "</h4>";
    }
    ?>
</fieldset><?php 
}
예제 #9
0
    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}))) {
                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>
			<tr id="revision-field-<?php 
            echo $field;
            ?>
">
				<td><div class="pre"><?php 
            echo $content;
            ?>
</div></td>
			</tr>
			<?php 
        }
        if ($identical) {
            ?>
<tr><td><div class="updated"><p><?php 
            _e('These Revisions are identical.', 'revision-control');
            ?>
</p></div></td></tr><?php 
        }
        ?>
		</table>
		<p><?php 
        _e('<em>Please Note:</em> at present, Although Taxonomies <em>(Tags / Categories / Custom Taxonomies)</em> are stored with the revisions, Restoring a Revision will <strong>not</strong> restore the taxonomies at present.', 'revision-control');
        ?>
</p>
		<br class="clear" />
		<?php 
        iframe_footer();
    }
예제 #10
0
    ?>
" />
                            
                            <?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 
        }
        ?>
예제 #11
0
function tdomf_form_hacker_diff($form_id)
{
    $mode = $_REQUEST['mode'];
    $form1_type = $_REQUEST['form1'];
    $form2_type = $_REQUEST['form2'];
    $render = 'wp';
    if (isset($_REQUEST['render'])) {
        $render = $_REQUEST['render'];
    }
    $type = $_REQUEST['type'];
    $form1_name = "";
    $form2_name = "";
    if ($type == 'preview') {
        if ($form1_type == 'cur') {
            $form1_name = __('Current Unmodified Preview', 'tdomf');
            $form1 = trim(tdomf_preview_form(array('tdomf_form_id' => $form_id), $mode));
        } else {
            if ($form1_type == 'org') {
                $form1_name = __('Original Unmodified Preview', 'tdomf');
                $form1 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK_ORIGINAL, $form_id));
            } else {
                if ($form1_type == 'hack') {
                    $form1_name = __('Hacked Preview', 'tdomf');
                    $form1 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK, $form_id));
                }
            }
        }
        if ($form2_type == 'cur') {
            $form2_name = __('Current Unmodified Preview', 'tdomf');
            $form2 = trim(tdomf_preview_form(array('tdomf_form_id' => $form_id), $mode));
        } else {
            if ($form2_type == 'org') {
                $form2_name = __('Original Unmodified Preview', 'tdomf');
                $form2 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK_ORIGINAL, $form_id));
            } else {
                if ($form2_type == 'hack') {
                    $form2_name = __('Hacked Preview', 'tdomf');
                    $form2 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_PREVIEW_HACK, $form_id));
                }
            }
        }
    } else {
        if ($form1_type == 'cur') {
            $form1_name = __('Current Unmodified Form', 'tdomf');
            $form1 = trim(tdomf_generate_form(array('tdomf_form_id' => $form_id), $mode));
        } else {
            if ($form1_type == 'org') {
                $form1_name = __('Original Unmodified Form', 'tdomf');
                $form1 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK_ORIGINAL, $form_id));
            } else {
                if ($form1_type == 'hack') {
                    $form1_name = __('Hacked Form', 'tdomf');
                    $form1 = trim(tdomf_get_option_form(TDOMF_OPTION_FORM_HACK, $form_id));
                }
            }
        }
        if ($form2_type == 'cur') {
            $form2_name = __('Current Unmodified Form', 'tdomf');
            $form2 = trim(tdomf_generate_form($form_id, $mode));
        } else {
            if ($form2_type == 'org') {
                $form2_name = __('Original Unmodified Form', 'tdomf');
                $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>";
                }
            }
        }
    }
}
 /**
  * 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;
 }
예제 #13
0
    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>
			<tr id="revision-field-<?php 
            echo $field;
            ?>
">
				<td><div class="pre"><?php 
            echo $content;
            ?>
</div></td>
			</tr>
			<?php 
        }
        if ($identical) {
            ?>
<tr><td><div class="updated"><p><?php 
            _e('These Revisions are identical.', 'revision-control');
            ?>
</p></div></td></tr><?php 
        }
        ?>
		</table>
		<p><?php 
        _e('<em>Please Note:</em> at present, Although Taxonomies <em>(Tags / Categories / Custom Taxonomies)</em> are stored with the revisions, Restoring a Revision will <strong>not</strong> restore the taxonomies at present.', 'revision-control');
        ?>
</p>
		<br class="clear" />
		<?php 
        iframe_footer();
    }
    /**
     * 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'));
                }
            }
        }
    }
 }
 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);
예제 #16
0
/**
 * 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');
        $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;
}
예제 #17
0
function eshop_form_admin_style()
{
    //make sure options exist for the style page
    //config options
    $eshopurl = eshop_files_directory();
    $styleFile = $eshopurl['0'] . 'eshop.css';
    $style = eshop_process_style($styleFile);
    $eshopoptions = get_option('eshop_plugin_settings');
    if (!is_writeable($styleFile)) {
        echo ' <div id="message" class="error fade"><p>' . __('<strong>Warning!</strong> The css file is not currently editable/writable! File permissions must first be changed.', 'eshop') . '</p>
	   	</div>' . "\n";
    }
    ?>
<div class="wrap">
<div id="eshopicon" class="icon32"></div><h2><?php 
    _e('eShop Styles', 'eshop');
    ?>
</h2>
<?php 
    eshop_admin_mode();
    ?>
</div>
<div class="wrap">
<h2><?php 
    _e('Default Style', 'eshop');
    ?>
</h2>
<?php 
    if (@file_exists(get_stylesheet_directory() . '/eshop.css')) {
        echo '<p>';
        _e('Your active theme has an eshop style sheet, eshop.css, and will be used in preference to the default style below. Therefore changes made via the style editor below will not show on your site.', 'eshop');
        echo '</p>';
    } else {
        ?>
<p><?php 
        _e('Default style is used by default. You can edit this via the editor below, or choose not to use it.', 'eshop');
        ?>
</p>
<form action="themes.php?page=eshop-style.php" method="post" id="style_form" name="style">
 <fieldset>
  <legend><?php 
        _e('Use Default Style', 'eshop');
        ?>
</legend>
  <?php 
        if ($eshopoptions['style'] == 'yes') {
            $yes = ' checked="checked"';
            $no = '';
        } else {
            $no = ' checked="checked"';
            $yes = '';
        }
        ?>
  <input type="radio" id="usestyle" name="usestyle" value="yes"<?php 
        echo $yes;
        ?>
 /><label for="usestyle"><?php 
        _e('Yes', 'eshop');
        ?>
</label> 
  <input type="radio" id="nostyle" name="usestyle" value="no"<?php 
        echo $no;
        ?>
 /><label for="nostyle"><?php 
        _e('No', 'eshop');
        ?>
</label>
  <p class="submit eshop"><input type="submit" value="<?php 
        _e('Amend', 'eshop');
        ?>
" name="submit" /></p>

</fieldset>
</form>
<?php 
    }
    //check for new css
    $plugin_dir = WP_PLUGIN_DIR;
    $dirs = wp_upload_dir();
    $upload_dir = $dirs['basedir'];
    $eshop_goto = $upload_dir . '/eshop_files/eshop.css';
    $eshop_from = $plugin_dir . '/eshop/files/eshop.css';
    $eshopver = split('\\.', ESHOP_VERSION);
    $left_string = file_get_contents($eshop_from, true);
    $right_string = file_get_contents($eshop_goto, true);
    ?>
</div>
<div class="wrap">
<h2><?php 
    _e('Style Editor', 'eshop');
    ?>
</h2>
 <p><?php 
    _e('Use this simple <abbr><span class="abbr" title="Cascading Style Sheet">CSS</span></abbr> file editor to modify the default style sheet file.', 'eshop');
    ?>
</p>
 <form method="post" action="themes.php?page=eshop-style.php" id="edit_box">
  <fieldset>
   <legend><?php 
    _e('Style File Editor.', 'eshop');
    ?>
</legend>
   <label for="stylebox"><?php 
    _e('Edit Style', 'eshop');
    ?>
</label><br />
	<textarea rows="20" cols="80" id="stylebox" name="cssFile"><?php 
    if (!is_file($styleFile)) {
        $error = 1;
    }
    if (!isset($error) && filesize($styleFile) > 0) {
        $f = "";
        $f = fopen($styleFile, 'r');
        $file = fread($f, filesize($styleFile));
        echo $file;
        fclose($f);
    } else {
        _e('Sorry. The file you are looking for could not be found', 'eshop');
    }
    ?>
</textarea>
   <p class="submit eshop"><input type="submit" class="button-primary" value="<?php 
    _e('Update Style', 'eshop');
    ?>
" name="submit" /></p>
  </fieldset>
</form>
</div>
	<?php 
    $left_string = normalize_whitespace($left_string);
    $right_string = normalize_whitespace($right_string);
    if (isset($_GET['diff'])) {
        echo '<div class="wrap" id="diff">';
        echo wp_text_diff($right_string, $left_string, array('title' => __('Comparing Current Style with latest installed version of eShop', 'eshop'), 'title_right' => __('Latest(from plugin)', 'eshop'), 'title_left' => __('Current (in use)', 'eshop')));
        echo '</div>';
    } elseif (trim($left_string) != trim($right_string)) {
        echo '<div class="wrap">';
        echo '<p>' . __('There may have been updates to the style.', 'eshop') . ' <a href="themes.php?page=eshop-style.php&amp;diff#diff">' . __('Compare Current Style with latest installed version of eShop.', 'eshop') . '</a></p>';
        echo '</div>';
    } else {
        echo '<div class="wrap">';
        echo '<p>' . __('Your CSS matches that included with eShop.', 'eshop') . '</p>';
        echo '</div>';
    }
}
 function theme($content)
 {
     global $post;
     $revision_id = isset($_REQUEST['revision']) ? absint($_REQUEST['revision']) : 0;
     $left = isset($_REQUEST['left']) ? absint($_REQUEST['left']) : 0;
     $right = isset($_REQUEST['right']) ? absint($_REQUEST['right']) : 0;
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
     $new_content = '';
     if ($action != 'edit') {
         $top = "";
         $btop = "";
         $btop .= '<div class="incsub_wiki incsub_wiki_single">';
         $btop .= '<div class="incsub_wiki_tabs incsub_wiki_tabs_top">' . $this->tabs() . '<div class="incsub_wiki_clear"></div></div>';
         switch ($action) {
             case 'discussion':
                 break;
             case 'edit':
                 set_include_path(get_include_path() . PATH_SEPARATOR . ABSPATH . 'wp-admin');
                 $post_type_object = get_post_type_object($post->post_type);
                 $p = $post;
                 if (empty($post->ID)) {
                     wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'));
                 }
                 if (!current_user_can($post_type_object->cap->edit_post, $post_id)) {
                     wp_die(__('You are not allowed to edit this item.'));
                 }
                 if ('trash' == $post->post_status) {
                     wp_die(__('You can&#8217;t edit this item because it is in the Trash. Please restore it and try again.'));
                 }
                 if (null == $post_type_object) {
                     wp_die(__('Unknown post type.'));
                 }
                 $post_type = $post->post_type;
                 if ($last = $this->check_post_lock($post->ID)) {
                     add_action('admin_notices', '_admin_notice_post_locked');
                 } else {
                     $this->set_post_lock($post->ID);
                     wp_enqueue_script('autosave');
                 }
                 $title = $post_type_object->labels->edit_item;
                 $post = $this->post_to_edit($post_id);
                 $new_content = '';
                 break;
             case 'restore':
                 if (!($revision = wp_get_post_revision($revision_id))) {
                     break;
                 }
                 if (!current_user_can('edit_post', $revision->post_parent)) {
                     break;
                 }
                 if (!($post = get_post($revision->post_parent))) {
                     break;
                 }
                 // Revisions disabled and we're not looking at an autosave
                 if ((!WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions')) && !wp_is_post_autosave($revision)) {
                     $redirect = get_permalink() . '?action=edit';
                     break;
                 }
                 check_admin_referer("restore-post_{$post->ID}|{$revision->ID}");
                 wp_restore_post_revision($revision->ID);
                 $redirect = add_query_arg(array('message' => 5, 'revision' => $revision->ID), get_permalink() . '?action=edit');
                 break;
             case 'diff':
                 if (!($left_revision = get_post($left))) {
                     break;
                 }
                 if (!($right_revision = get_post($right))) {
                     break;
                 }
                 // If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post
                 if ($left_revision->ID == $right_revision->ID) {
                     $redirect = get_edit_post_link($left_revision->ID);
                     include ABSPATH . 'wp-admin/js/revisions-js.php';
                     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));
                     break;
                 }
                 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 {
                     break;
                 }
                 // Don't diff two unrelated revisions
                 if (!WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions')) {
                     // Revisions disabled
                     if (!wp_is_post_autosave($left_revision) && !wp_is_post_autosave($right_revision) || $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID) {
                         $redirect = get_permalink() . '?action=edit';
                         break;
                     }
                 }
                 if ($left_revision->ID == $right_revision->ID || !wp_get_post_revision($left_revision->ID) && !wp_get_post_revision($right_revision->ID)) {
                     break;
                 }
                 $post_title = '<a href="' . get_permalink() . '?action=edit' . '">' . get_the_title() . '</a>';
                 $h2 = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;'), $post_title);
                 $title = __('Revisions');
                 $left = $left_revision->ID;
                 $right = $right_revision->ID;
             case 'history':
                 $args = array('format' => 'form-table', 'parent' => false, 'right' => $right, 'left' => $left);
                 if (!WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions')) {
                     $args['type'] = 'autosave';
                 }
                 if (!isset($h2)) {
                     $post_title = '<a href="' . get_permalink() . '?action=edit' . '">' . get_the_title() . '</a>';
                     $revisions = wp_get_post_revisions($post->ID);
                     $revision = array_shift($revisions);
                     $revision_title = wp_post_revision_title($revision, false);
                     $h2 = sprintf(__('Revision for &#8220;%1$s&#8221; created on %2$s'), $post_title, $revision_title);
                 }
                 $new_content .= '<h3 class="long-header">' . $h2 . '</h3>';
                 $new_content .= '<table class="form-table ie-fixed">';
                 $new_content .= '<col class="th" />';
                 if ('diff' == $action) {
                     $new_content .= '<tr id="revision">';
                     $new_content .= '<th scope="row"></th>';
                     $new_content .= '<th scope="col" class="th-full">';
                     $new_content .= '<span class="alignleft">' . sprintf(__('Older: %s', $this->translation_domain), wp_post_revision_title($left_revision, false)) . '</span>';
                     $new_content .= '<span class="alignright">' . sprintf(__('Newer: %s', $this->translation_domain), wp_post_revision_title($right_revision, false)) . '</span>';
                     $new_content .= '</th>';
                     $new_content .= '</tr>';
                 }
                 // use get_post_to_edit filters?
                 $identical = true;
                 foreach (_wp_post_revision_fields() as $field => $field_title) {
                     if ('diff' == $action) {
                         $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 (!($rcontent = wp_text_diff($left_content, $right_content))) {
                             continue;
                         }
                         // There is no difference between left and right
                         $identical = false;
                     } else {
                         add_filter("_wp_post_revision_field_{$field}", 'htmlspecialchars');
                         $rcontent = apply_filters("_wp_post_revision_field_{$field}", $revision->{$field}, $field);
                     }
                     $new_content .= '<tr id="revision-field-<?php echo $field; ?>">';
                     $new_content .= '<th scope="row">' . esc_html($field_title) . '</th>';
                     $new_content .= '<td><div class="pre">' . $rcontent . '</div></td>';
                     $new_content .= '</tr>';
                 }
                 if ('diff' == $action && $identical) {
                     $new_content .= '<tr><td colspan="2"><div class="updated"><p>' . __('These revisions are identical.', $this->translation_domain) . '</p></div></td></tr>';
                 }
                 $new_content .= '</table>';
                 $new_content .= '<br class="clear" />';
                 $new_content .= '<div class="incsub_wiki_revisions">' . $this->list_post_revisions($post, $args) . '</div>';
                 $redirect = false;
                 break;
             default:
                 $crumbs = array();
                 foreach ($post->ancestors as $parent_pid) {
                     $parent_post = get_post($parent_pid);
                     $crumbs[] = '<a href="' . get_permalink($parent_pid) . '" class="incsub_wiki_crumbs">' . $parent_post->post_title . '</a>';
                 }
                 $crumbs[] = '<span class="incsub_wiki_crumbs">' . $post->post_title . '</span>';
                 sort($crumbs);
                 $top .= join(get_option("incsub_meta_seperator", " > "), $crumbs);
                 $children = get_children('post_parent=' . $post->ID . '&post_type=incsub_wiki');
                 $crumbs = array();
                 foreach ($children as $child) {
                     $crumbs[] = '<a href="' . get_permalink($child->ID) . '" class="incsub_wiki_crumbs">' . $child->post_title . '</a>';
                 }
                 $bottom = "<h3>" . __('Sub Wikis', $this->translation_domain) . "</h3> <ul><li>";
                 $bottom .= join("</li><li>", $crumbs);
                 if (count($crumbs) == 0) {
                     $bottom = "";
                 } else {
                     $bottom .= "</li></ul>";
                 }
                 $revisions = wp_get_post_revisions($post->ID);
                 if (current_user_can('edit_wiki')) {
                     $bottom .= '<div class="incsub_wiki-meta">';
                     if (is_array($revisions) && count($revisions) > 0) {
                         $revision = array_shift($revisions);
                     }
                     $bottom .= '</div>';
                 }
                 $notification_meta = get_post_custom($post->ID, array('incsub_wiki_email_notification' => 'enabled'));
                 if ($notification_meta['incsub_wiki_email_notification'][0] == 'enabled' && !$this->is_subscribed()) {
                     if (is_user_logged_in()) {
                         $bottom .= '<div class="incsub_wiki-subscribe"><a href="' . wp_nonce_url(add_query_arg(array('post_id' => $post->ID, 'subscribe' => 1)), "wiki-subscribe-wiki_{$post->ID}") . '">' . __('Notify me of changes', $this->translation_domain) . '</a></div>';
                     } else {
                         if (!empty($_COOKIE['incsub_wiki_email'])) {
                             $user_email = $_COOKIE['incsub_wiki_email'];
                         } else {
                             $user_email = "";
                         }
                         $bottom .= '<div class="incsub_wiki-subscribe">' . '<form action="" method="post">' . '<label>' . __('E-mail', $this->translation_domain) . ': <input type="text" name="email" id="email" value="' . $user_email . '" /></label> &nbsp;' . '<input type="hidden" name="post_id" id="post_id" value="' . $post->ID . '" />' . '<input type="submit" name="subscribe" id="subscribe" value="' . __('Notify me of changes', $this->translation_domain) . '" />' . '<input type="hidden" name="_wpnonce" id="_wpnonce" value="' . wp_create_nonce("wiki-subscribe-wiki_{$post->ID}") . '" />' . '</form>' . '</div>';
                     }
                 }
                 $new_content = $btop . '<div class="incsub_wiki_top">' . $top . '</div>' . $new_content;
                 $new_content .= '<div class="incsub_wiki_content">' . $content . '</div>';
                 $new_content .= '<div class="incsub_wiki_bottom">' . $bottom . '</div>';
                 $redirect = false;
         }
         $new_content .= '</div>';
     }
     if (!comments_open()) {
         $new_content .= '<style type="text/css">' . '#comments { display: none; }' . '</style>';
     } else {
         $new_content .= '<style type="text/css">' . '.hentry { margin-bottom: 5px; }' . '</style>';
     }
     // Empty post_type means either malformed object found, or no valid parent was found.
     if (isset($redirect) && !$redirect && empty($post->post_type)) {
         $redirect = 'edit.php';
     }
     if (!empty($redirect)) {
         echo '<script type="text/javascript">' . 'window.location = "' . $redirect . '";' . '</script>';
         exit;
     }
     return $new_content;
 }
예제 #19
0
    private function render_current_element_diff()
    {
        if (!$this->current_element->field_finished && !empty($this->job->prev_version)) {
            $prev_value = '';
            foreach ($this->job->prev_version->elements as $pel) {
                if ($this->current_element->field_type == $pel->field_type) {
                    $prev_value = TranslationManagement::decode_field_data($pel->field_data, $pel->field_format);
                }
            }
            if ($this->current_element->field_format != 'csv_base64') {
                $diff = wp_text_diff($prev_value, TranslationManagement::decode_field_data($this->current_element->field_data, $this->current_element->field_format));
            }
            if (!empty($diff)) {
                ?>
				<div class="wpml_diff_wrapper">
					<p><a href="#" class="wpml_diff_toggle"><?php 
                _e('Show Changes', 'sitepress');
                ?>
</a></p>

					<div class="wpml_diff">
						<?php 
                echo $diff;
                ?>
					</div>
				</div>
			<?php 
            }
        }
    }
function edit_my_calendar_styles()
{
    $dir = plugin_dir_path(__FILE__);
    if (isset($_POST['mc_edit_style'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        $my_calendar_style = isset($_POST['style']) ? stripcslashes($_POST['style']) : false;
        $mc_css_file = stripcslashes($_POST['mc_css_file']);
        $stylefile = mc_get_style_path($mc_css_file);
        $wrote_styles = $my_calendar_style !== false ? mc_write_styles($stylefile, $my_calendar_style) : 'disabled';
        if ($wrote_styles == true) {
            // updates from pre version 1.7.0
            delete_option('mc_file_permissions');
            delete_option('mc_style');
        }
        if ($wrote_styles === 'disabled') {
            $message = "<p>" . __("Styles are disabled, and were not edited.", 'my-calendar') . "</p>";
        } else {
            $message = $wrote_styles == true ? '<p>' . __('The stylesheet has been updated.', 'my-calendar') . '</p>' : '<p><strong>' . __('Write Error! Please verify write permissions on the style file.', 'my-calendar') . '</strong></p>';
        }
        $mc_show_css = empty($_POST['mc_show_css']) ? '' : stripcslashes($_POST['mc_show_css']);
        update_option('mc_show_css', $mc_show_css);
        $use_styles = empty($_POST['use_styles']) ? '' : 'true';
        update_option('mc_use_styles', $use_styles);
        if (!empty($_POST['reset_styles'])) {
            $stylefile = mc_get_style_path();
            $styles = mc_default_style();
            $wrote_old_styles = mc_write_styles($stylefile, $styles);
            if ($wrote_old_styles) {
                $message .= "<p>" . __('Stylesheet reset to default.', 'my-calendar') . "</p>";
            }
        }
        $message .= "<p><strong>" . __('Style Settings Saved', 'my-calendar') . ".</strong></p>";
        echo "<div id='message' class='updated fade'>{$message}</div>";
    }
    if (isset($_POST['mc_choose_style'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        $mc_css_file = stripcslashes($_POST['mc_css_file']);
        update_option('mc_css_file', $mc_css_file);
        $message = '<p><strong>' . __('New theme selected.', 'my-calendar') . '</strong></p>';
        echo "<div id='message' class='updated fade'>{$message}</div>";
    }
    $mc_show_css = get_option('mc_show_css');
    $stylefile = mc_get_style_path();
    if ($stylefile) {
        $f = fopen($stylefile, 'r');
        $file = fread($f, filesize($stylefile));
        $my_calendar_style = $file;
        fclose($f);
        $mc_current_style = mc_default_style();
    } else {
        $mc_current_style = '';
        $my_calendar_style = __('Sorry. The file you are looking for doesn\'t appear to exist. Please check your file name and location!', 'my-calendar');
    }
    ?>
	<div class="wrap jd-my-calendar">
	<?php 
    my_calendar_check_db();
    ?>
	<h2><?php 
    _e('My Calendar Styles', 'my-calendar');
    ?>
</h2>
	<div class="postbox-container jcd-wide">
		<div class="metabox-holder">
			<div class="ui-sortable meta-box-sortables">
				<div class="postbox">
					<h3><?php 
    _e('Calendar Style Settings', 'my-calendar');
    ?>
</h3>

					<div class="inside">

						<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-styles");
    ?>
">
							<div><input type="hidden" name="_wpnonce"
							            value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
"/></div>
							<div><input type="hidden" value="true" name="mc_choose_style"/></div>
							<fieldset>
								<p>
									<label
										for="mc_css_file"><?php 
    _e('Select My Calendar Theme', 'my-calendar');
    ?>
</label>
									<select name="mc_css_file" id="mc_css_file"><?php 
    $custom_directory = str_replace('/my-calendar/', '', $dir) . '/my-calendar-custom/styles/';
    $directory = dirname(__FILE__) . '/styles/';
    $files = @my_csslist($custom_directory);
    if (!empty($files)) {
        echo "<optgroup label='" . __('Your Custom Stylesheets', 'my-calendar') . "'>\n";
        foreach ($files as $value) {
            $filepath = mc_get_style_path($value);
            $path = pathinfo($filepath);
            if ($path['extension'] == 'css') {
                $test = "mc_custom_" . $value;
                $selected = get_option('mc_css_file') == $test ? " selected='selected'" : "";
                echo "<option value='" . esc_attr('mc_custom_' . $value) . "'{$selected}>{$value}</option>\n";
            }
        }
        echo "</optgroup>";
    }
    $files = my_csslist($directory);
    echo "<optgroup label='" . __('Installed Stylesheets', 'my-calendar') . "'>\n";
    foreach ($files as $value) {
        $filepath = mc_get_style_path($value);
        $path = pathinfo($filepath);
        if ($path['extension'] == 'css') {
            $selected = get_option('mc_css_file') == $value ? " selected='selected'" : "";
            echo "<option value='" . esc_attr($value) . "'{$selected}>{$value}</option>\n";
        }
    }
    echo "</optgroup>";
    ?>
									</select>
									<input type="submit" name="save" class="button-secondary"
									       value="<?php 
    _e('Choose Style', 'my-calendar');
    ?>
"/>
								</p>
							</fieldset>
						</form>
						<hr/>
						<form method="post" action="<?php 
    echo admin_url("admin.php?page=my-calendar-styles");
    ?>
">
							<div><input type="hidden" name="_wpnonce"
							            value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
"/></div>
							<div><input type="hidden" value="true" name="mc_edit_style"/>
								<input type="hidden" name="mc_css_file"
								       value="<?php 
    esc_attr_e(get_option('mc_css_file'));
    ?>
"/>
							</div>
							<fieldset style="position:relative;">
								<legend><?php 
    _e('CSS Style Options', 'my-calendar');
    ?>
</legend>
								<p>
									<label
										for="mc_show_css"><?php 
    _e('Apply CSS on these pages (comma separated IDs)', 'my-calendar');
    ?>
</label>
									<input type="text" id="mc_show_css" name="mc_show_css"
									       value="<?php 
    esc_attr_e($mc_show_css);
    ?>
"/>
								</p>

								<p>
									<input type="checkbox" id="reset_styles"
									       name="reset_styles" <?php 
    if (mc_is_custom_style(get_option('mc_css_file'))) {
        echo "disabled='disabled'";
    }
    ?>
 /> <label
										for="reset_styles"><?php 
    _e('Restore My Calendar stylesheet', 'my-calendar');
    ?>
</label>
									<input type="checkbox" id="use_styles"
									       name="use_styles" <?php 
    mc_is_checked('mc_use_styles', 'true');
    ?>
 />
									<label
										for="use_styles"><?php 
    _e('Disable My Calendar Stylesheet', 'my-calendar');
    ?>
</label>
								</p>
								<p>						
								<?php 
    if (mc_is_custom_style(get_option('mc_css_file'))) {
        _e('The editor is not available for custom CSS files. You should edit your custom CSS locally, then upload your changes.', 'my-calendar');
    } else {
        ?>
									<label
										for="style"><?php 
        _e('Edit the stylesheet for My Calendar', 'my-calendar');
        ?>
</label><br/><textarea
										class="style-editor" id="style" name="style" rows="30"
										cols="80"<?php 
        if (get_option('mc_use_styles') == 'true') {
            echo "disabled='disabled'";
        }
        ?>
><?php 
        echo $my_calendar_style;
        ?>
</textarea>

								<?php 
    }
    ?>
								</p>
								<p>
									<input type="submit" name="save" class="button-primary button-adjust"
									       value="<?php 
    _e('Save Changes', 'my-calendar');
    ?>
"/>
								</p>
							</fieldset>
						</form>
						<?php 
    $left_string = normalize_whitespace($my_calendar_style);
    $right_string = normalize_whitespace($mc_current_style);
    if ($right_string) {
        // if right string is blank, there is no default
        if (isset($_GET['diff'])) {
            echo '<div class="wrap jd-my-calendar" id="diff">';
            echo wp_text_diff($left_string, $right_string, array('title' => __('Comparing Your Style with latest installed version of My Calendar', 'my-calendar'), 'title_right' => __('Latest (from plugin)', 'my-calendar'), 'title_left' => __('Current (in use)', 'my-calendar')));
            echo '</div>';
        } else {
            if (trim($left_string) != trim($right_string)) {
                echo '<div class="wrap jd-my-calendar">';
                echo '<div class="updated"><p>' . __('There have been updates to the stylesheet.', 'my-calendar') . ' <a href="' . admin_url("admin.php?page=my-calendar-styles&amp;diff#diff") . '">' . __('Compare Your Stylesheet with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
                echo '</div>';
            } else {
                echo '
						<div class="wrap jd-my-calendar">
							<p>' . __('Your stylesheet matches that included with My Calendar.', 'my-calendar') . '</p>
						</div>';
            }
        }
    }
    ?>
					</div>
				</div>
				<p><?php 
    _e('Resetting your stylesheet will set your stylesheet to the version currently distributed with the plug-in.', 'my-calendar');
    ?>
</p>
			</div>
		</div>
	</div>
	<?php 
    mc_show_sidebar();
    ?>
	</div><?php 
}
function prd_get_revision_diffs($post, $revision)
{
    $previous = prd_break_up_lines($revision->post_content);
    $current = prd_break_up_lines($post->post_content);
    // diff the unfiltered content
    $diffs = wp_text_diff($previous, $current);
    $diffs_title = wp_text_diff($revision->post_title, $post->post_title);
    // add header/footer rows for "parts"
    $diffs = prd_add_diff_header_part(__('Content', 'post-revision-display'), $diffs);
    $diffs_title = prd_add_diff_header_part(__('Title', 'post-revision-display'), $diffs_title);
    $diffs = $diffs_title . $diffs;
    if (empty($diffs)) {
        $diffs = '<p>' . sprintf(__('There are no differences between the %s revision and the current revision. (Maybe only post meta information was changed.)', 'post-revision-display'), wp_post_revision_title($revision, false)) . '</p>';
    } else {
        //rename col class = "content" to less generic class = "diff-content"
        $diffs = prd_rename_diff_content_class($diffs);
        // add top header row for previous and current revision
        // (this has to follow prd_add_diff_header_part calls so will be at top of table)
        $diffs = prd_add_diff_header_revs(wp_post_revision_title($revision, false), __('Current Revision', 'post-revision-display'), $diffs) . "\n<p>" . sprintf(__('%1$sNote:%2$s Spaces may be added to comparison text to allow better line wrapping.', 'post-revision-display'), '<i>', '</i>') . "</p>\n";
    }
    return '<div id="revision-diffs">' . "\n" . prd_get_rev_diffs_header() . "\n{$diffs}\n</div>\n";
}
예제 #22
0
             $table_code .= "<tr id='revision-field-" . $field . "'>\n<th scope='row'>" . $title . "</th>\n<td><div class='pre'>\n" . $content . "\n</div></td></tr>";
         }
     }
 }
 if (is_array($customFields) && !empty($customFields)) {
     foreach ($customFields as $field => $title) {
         $left_field = get_post_meta($left_revision->ID, $field, true);
         if (is_array($left_field)) {
             $left_field = var_export($left_field, true);
         }
         $right_field = get_post_meta($right_revision->ID, $field, true);
         if (is_array($right_field)) {
             $right_field = var_export($right_field, true);
         }
         if ($render == 'wp') {
             if ($content = wp_text_diff($left_field, $right_field)) {
                 $identical = false;
                 $table_code .= "<tr id='revision-field-" . $field . "'>\n<th scope='row'>" . $title . "</th>\n<td><div class='pre'>\n" . $content . "\n</div></td></tr>";
             } else {
                 $table_code .= "<tr id='revision-field-" . $field . "'>\n<th scope='row'>" . $title . "</th><td><div class='pre'>" . htmlentities($left_field) . "</div></td></tr>\n";
             }
         } 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";
             $left_field = explode("\n", $left_field);
             $right_field = explode("\n", $right_field);
             $diff =& new Text_Diff('auto', array($left_field, $right_field));
             if ($diff->isEmpty()) {
                 $table_code .= "<tr id='revision-field-" . $field . "'>\n<th scope='row'>" . $title . "</th><td><div class='pre'>" . htmlentities($left_revision->{$field}) . "</div></td></tr>\n";
             } else {
                 $identical = false;
예제 #23
0
 /**
  * Determines whether left and right revisions are identical.
  *
  * This is cribbed nearly wholesale from wp-admin/revision.php. In the future I would like
  * to clean it up to be less WordPressy and more pluginish.
  *
  * @package BuddyPress Docs
  * @since 1.1
  */
 function setup_is_identical()
 {
     $this->revisions_are_identical = true;
     foreach (_wp_post_revision_fields() as $field => $field_title) {
         if ('diff' == bp_docs_history_action()) {
             $left_content = apply_filters("_wp_post_revision_field_{$field}", $this->left_revision->{$field}, $field);
             $right_content = apply_filters("_wp_post_revision_field_{$field}", $this->right_revision->{$field}, $field);
             if (!($content = wp_text_diff($left_content, $right_content))) {
                 continue;
             }
             // There is no difference between left and right
             $this->revisions_are_identical = false;
         } else {
             if (isset($this->revision) && is_object($this->revision) && isset($this->revision->{$field})) {
                 add_filter("_wp_post_revision_field_{$field}", 'htmlspecialchars');
                 $content = apply_filters("_wp_post_revision_field_{$field}", $this->revision->{$field}, $field);
             }
         }
     }
 }
예제 #24
0
</span>
		<span class="alignright"><?php 
    printf(__('Newer: %s'), wp_post_revision_title($right_revision));
    ?>
</span>
	</th>
</tr>
<?php 
}
// use get_post_to_edit filters?
$identical = true;
foreach (_wp_post_revision_fields() as $field => $field_title) {
    if ('diff' == $action) {
        $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 difference between left and right
        $identical = false;
    } else {
        add_filter("_wp_post_revision_field_{$field}", 'htmlspecialchars');
        $content = apply_filters("_wp_post_revision_field_{$field}", $revision->{$field}, $field);
    }
    ?>

	<tr id="revision-field-<?php 
    echo $field;
    ?>
">
		<th scope="row"><?php 
예제 #25
0
function edit_my_calendar_behaviors()
{
    global $wpdb, $initial_listjs, $initial_caljs, $initial_minijs, $initial_ajaxjs;
    $mcdb = $wpdb;
    if (isset($_POST['mc_caljs'])) {
        $nonce = $_REQUEST['_wpnonce'];
        if (!wp_verify_nonce($nonce, 'my-calendar-nonce')) {
            die("Security check failed");
        }
        $mc_caljs = $_POST['mc_caljs'];
        $mc_listjs = $_POST['mc_listjs'];
        $mc_minijs = $_POST['mc_minijs'];
        $mc_ajaxjs = $_POST['mc_ajaxjs'];
        update_option('mc_calendar_javascript', empty($_POST['calendar_javascript']) ? 0 : 1);
        update_option('mc_list_javascript', empty($_POST['list_javascript']) ? 0 : 1);
        update_option('mc_mini_javascript', empty($_POST['mini_javascript']) ? 0 : 1);
        update_option('mc_ajax_javascript', empty($_POST['ajax_javascript']) ? 0 : 1);
        // set js
        update_option('mc_listjs', $mc_listjs);
        update_option('mc_minijs', $mc_minijs);
        update_option('mc_caljs', $mc_caljs);
        update_option('mc_ajaxjs', $mc_ajaxjs);
        $mc_show_js = $_POST['mc_show_js'] == '' ? '' : $_POST['mc_show_js'];
        update_option('mc_show_js', $mc_show_js);
        if (!empty($_POST['reset_caljs'])) {
            update_option('mc_caljs', $initial_caljs);
        }
        if (!empty($_POST['reset_listjs'])) {
            update_option('mc_listjs', $initial_listjs);
        }
        if (!empty($_POST['reset_minijs'])) {
            update_option('mc_minijs', $initial_minijs);
        }
        if (!empty($_POST['reset_ajaxjs'])) {
            update_option('mc_ajaxjs', $initial_ajaxjs);
        }
        echo "<div class=\"updated\"><p><strong>" . __('Behavior Settings saved', 'my-calendar') . ".</strong></p></div>";
    }
    $mc_listjs = stripcslashes(get_option('mc_listjs'));
    $list_javascript = get_option('mc_list_javascript');
    $mc_caljs = stripcslashes(get_option('mc_caljs'));
    $calendar_javascript = get_option('mc_calendar_javascript');
    $mc_minijs = stripcslashes(get_option('mc_minijs'));
    $mini_javascript = get_option('mc_mini_javascript');
    $mc_ajaxjs = stripcslashes(get_option('mc_ajaxjs'));
    $ajax_javascript = get_option('mc_ajax_javascript');
    $mc_show_js = stripcslashes(get_option('mc_show_js'));
    // Now we render the form
    ?>
<div class="wrap jd-my-calendar">
	<?php 
    my_calendar_check_db();
    ?>
    <h2><?php 
    _e('My Calendar Behaviors', 'my-calendar');
    ?>
</h2>
	<div class="postbox-container jcd-wide">
	<div class="metabox-holder">

	<div class="ui-sortable meta-box-sortables">
	<div class="postbox" id="cdiff">
	
	<h3><?php 
    _e('Calendar Behavior Settings', 'my-calendar');
    ?>
</h3>
	<div class="inside">	
    <form id="my-calendar" method="post" action="<?php 
    echo admin_url('admin.php?page=my-calendar-behaviors');
    ?>
">
	<div><input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" /></div>
	<p>
	<label for="mc_show_js"><?php 
    _e('Insert scripts on these pages (comma separated post IDs)', 'my-calendar');
    ?>
</label> <input type="text" id="mc_show_js" name="mc_show_js" value="<?php 
    echo $mc_show_js;
    ?>
" />
	</p>  
	<fieldset>
	<legend><?php 
    _e('Calendar Behaviors: Grid View', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_caljs" name="reset_caljs" /> <label for="reset_caljs"><?php 
    _e('Restore Grid View JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="calendar_javascript" name="calendar_javascript" value="1"  <?php 
    mc_is_checked('mc_calendar_javascript', 1);
    ?>
/> <label for="calendar_javascript"><?php 
    _e('Disable Grid Javascript', 'my-calendar');
    ?>
</label>
	</p>
	<p>
	<label for="calendar-javascript"><?php 
    _e('Edit jQuery scripts for My Calendar in Grid View', 'my-calendar');
    ?>
</label><br /><textarea id="calendar-javascript" name="mc_caljs" rows="8" cols="80"><?php 
    echo $mc_caljs;
    ?>
</textarea>
	</p>
	<?php 
    $args = array('title' => __('Comparing scripts with latest installed version of My Calendar', 'my-calendar'), 'title_right' => __('Latest (from plugin)', 'my-calendar'), 'title_left' => __('Current (in use)', 'my-calendar'));
    $left_string = normalize_whitespace($mc_caljs);
    $right_string = normalize_whitespace($initial_caljs);
    if (isset($_GET['cdiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the calendar view scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;cdiff#cdiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
	
	<p>
		<input type="submit" name="save" class="button-secondary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>	
	</fieldset>

    <fieldset id="ldiff">
	<legend><?php 
    _e('Calendar Behaviors: List View', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_listjs" name="reset_listjs" /> <label for="reset_listjs"><?php 
    _e('Restore List JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="list_javascript" name="list_javascript" value="1" <?php 
    mc_is_checked('mc_list_javascript', 1);
    ?>
 /> <label for="list_javascript"><?php 
    _e('Disable List JavaScript', 'my-calendar');
    ?>
</label> 
	</p>
	<p>
	<label for="list-javascript"><?php 
    _e('Edit the jQuery scripts for My Calendar in List format', 'my-calendar');
    ?>
</label><br /><textarea id="list-javascript" name="mc_listjs" rows="8" cols="80"><?php 
    echo $mc_listjs;
    ?>
</textarea>
	</p>
	<?php 
    $left_string = normalize_whitespace($mc_listjs);
    $right_string = normalize_whitespace($initial_listjs);
    if (isset($_GET['ldiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the list view scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;ldiff#ldiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
	
	<p>
		<input type="submit" name="save" class="button-secondary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>	
	</fieldset>

   <fieldset id="mdiff">
	<legend><?php 
    _e('Calendar Behaviors: Mini Calendar View', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_minijs" name="reset_minijs" /> <label for="reset_minijs"><?php 
    _e('Restore Mini View JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="mini_javascript" name="mini_javascript" value="1" <?php 
    mc_is_checked('mc_mini_javascript', 1);
    ?>
 /> <label for="mini_javascript"><?php 
    _e('Disable Mini JavaScript', 'my-calendar');
    ?>
</label> 
	</p>
	<p>
	<label for="mini-javascript"><?php 
    _e('Edit jQuery scripts in Mini view', 'my-calendar');
    ?>
</label><br /><textarea id="mini-javascript" name="mc_minijs" rows="8" cols="80"><?php 
    echo $mc_minijs;
    ?>
</textarea>
	</p>
	<?php 
    $left_string = normalize_whitespace($mc_minijs);
    $right_string = normalize_whitespace($initial_minijs);
    if (isset($_GET['mdiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the mini view scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;mdiff#mdiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
	<p>
		<input type="submit" name="save" class="button-secondary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>	
	</fieldset>
	
    <fieldset id="adiff">
	<legend><?php 
    _e('Calendar Behaviors: AJAX', 'my-calendar');
    ?>
</legend>
	<p>
	<input type="checkbox" id="reset_ajaxjs" name="reset_ajaxjs" /> <label for="reset_ajaxjs"><?php 
    _e('Restore AJAX JavaScript', 'my-calendar');
    ?>
</label> <input type="checkbox" id="ajax_javascript" name="ajax_javascript" value="1" <?php 
    mc_is_checked('mc_ajax_javascript', 1);
    ?>
 /> <label for="ajax_javascript"><?php 
    _e('Disable AJAX Navigation', 'my-calendar');
    ?>
</label> 
	</p>
	<p>
	<label for="ajax-javascript"><?php 
    _e('Edit jQuery scripts for AJAX navigation', 'my-calendar');
    ?>
</label><br /><textarea id="ajax-javascript" name="mc_ajaxjs" rows="8" cols="80"><?php 
    echo $mc_ajaxjs;
    ?>
</textarea>
	</p>
	<?php 
    $left_string = normalize_whitespace($mc_ajaxjs);
    $right_string = normalize_whitespace($initial_ajaxjs);
    if (isset($_GET['adiff'])) {
        echo wp_text_diff($left_string, $right_string, $args);
    } else {
        if (trim($left_string) != trim($right_string)) {
            echo '<div class="updated"><p>' . __('There have been updates to the AJAX scripts.', 'my-calendar') . ' <a href="' . admin_url('admin.php?page=my-calendar-behaviors&amp;adiff#adiff') . '">' . __('Compare your scripts with latest installed version of My Calendar.', 'my-calendar') . '</a></p></div>';
        } else {
            _e('Your script matches that included with My Calendar.', 'my-calendar');
        }
    }
    ?>
		
	</fieldset>
	<p>
		<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save', 'my-calendar');
    ?>
" />
	</p>		
  </form>
  </div>
 </div>
</div>
<p><?php 
    _e('Resetting JavaScript will set that script to the version currently distributed with the plug-in.', 'my-calendar');
    ?>
</p>
 </div>
 </div>
 <?php 
    mc_show_sidebar();
    ?>
 </div>
<?php 
}
예제 #26
0
            ?>
]" value="<?php 
            echo base64_encode($translation['string']);
            ?>
" />
                    <input type="hidden" name="name[<?php 
            echo $idx;
            ?>
]" value="<?php 
            echo base64_encode($translation['name']);
            ?>
" />
                </td>
                <td colspan="2">
                    <?php 
            echo wp_text_diff($translation['translation'], $translation['new']);
            ?>
                    <input type="hidden" name="translation[<?php 
            echo $idx;
            ?>
]" value="<?php 
            echo base64_encode($translation['new']);
            ?>
" />
                </td>
            </tr>      
            <?php 
            $idx++;
            ?>
  
        <?php 
예제 #27
0
		<?php 
foreach (_wp_post_revision_fields() as $field => $field_title) {
    ?>
			<?php 
    if ('diff' == bp_docs_history_action()) {
        ?>
				<tr id="revision-field-<?php 
        echo $field;
        ?>
">
					<th scope="row"><?php 
        echo esc_html($field_title);
        ?>
</th>
					<td><div class="pre"><?php 
        echo wp_text_diff(bp_docs_history_post_revision_field('left', $field), bp_docs_history_post_revision_field('right', $field));
        ?>
</div></td>
				</tr>
			<?php 
    } elseif (!bp_docs_history_is_latest()) {
        ?>
				<tr id="revision-field-<?php 
        echo $field;
        ?>
">
					<th scope="row"><?php 
        echo esc_html($field_title);
        ?>
</th>
					<td><div class="pre"><?php 
예제 #28
0
 private function compareText($old, $new)
 {
     $old = normalize_whitespace(strip_tags($old));
     $new = normalize_whitespace(strip_tags($new));
     $args = array('title' => '', 'title_left' => '', 'title_right' => '', 'show_split_view' => true);
     $diff = wp_text_diff($old, $new, $args);
     if (!$diff) {
         $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>{$old}</td><td></td><td>{$new}</td>";
         $diff .= "</tr></tbody></table>";
     }
     return $diff;
 }
    /**
     * Modification history metabox HTML
     */
    function wp_modification_history()
    {
        global $post, $wpdb;
        // Nonce
        wp_nonce_field('modification_history', 'modification_history');
        // Get our modifications
        $mods = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}{$this->table} WHERE `post_id` = " . absint($post->ID) . " ORDER BY `modified`");
        if (!empty($mods)) {
            ?>
		<table>
			<thead>
				<tr style="text-align:left;">
					<th>User</th>
					<th colspan="2">Date</th>
					<th>Modifications</th>
				</tr>
			</thead>
			<tbody>
				<?php 
            $last_user = '';
            $last_time = false;
            foreach ($mods as $mod) {
                // Set the user that made this modification
                $user = get_user_by('id', $mod->user_id);
                $user = $user ? str_replace(' ', '&nbsp;', $user->data->display_name) : '';
                // Build modifications arrays for posts table
                $posts_modified = array('before' => (array) unserialize($mod->posts_before), 'after' => (array) unserialize($mod->posts_after));
                unset($posts_modified['after']['post_modified']);
                unset($posts_modified['after']['post_modified_gmt']);
                // Build modifications arrays for postmeta table
                $postmeta_modified = array('before' => (array) unserialize($mod->postmeta_before), 'after' => (array) unserialize($mod->postmeta_after));
                unset($postmeta_modified['after']['post_modified']);
                unset($postmeta_modified['after']['post_modified_gmt']);
                // Build array of differences for each table modifications array
                $posts_mods = array_diff_assoc($posts_modified['after'], $posts_modified['before']);
                $postmeta_mods = array_diff_assoc($postmeta_modified['after'], $postmeta_modified['before']);
                if (isset($this->settings['unchanged']) && empty($posts_mods) && empty($postmeta_mods)) {
                    // Updated with no modifications
                    echo '<tr>';
                    echo '<td style="vertical-align:top;">' . $user . '</td>';
                    echo '<td style="vertical-align:top;">' . date($this->settings['date_format'], strtotime($mod->modified)) . '</td>';
                    echo '<td style="vertical-align:top;">';
                    echo '<em>Updated with no modifications</em>';
                    echo '</td>';
                    echo '</tr>';
                } else {
                    if (!empty($posts_mods) || !empty($postmeta_mods)) {
                        // Modifications were made
                        echo '<tr>';
                        echo '<td style="vertical-align:top;">' . $user . '</td>';
                        echo '<td style="vertical-align:top;">' . date($this->settings['date_format'], strtotime($mod->modified)) . '</td>';
                        echo '<td style="vertical-align:top;">';
                        if (!empty($posts_mods)) {
                            // Optionally display the time if it's different than the last diff
                            if (date($this->settings['time_format'], strtotime($mod->modified)) != $last_time) {
                                $last_time = date($this->settings['time_format'], strtotime($mod->modified));
                                echo $last_time;
                            }
                            echo '</td><td style="vertical-align:top;width:100%;">';
                            // Display each post modification
                            foreach ($posts_mods as $key => $postmod) {
                                echo '<h4 style="margin:0;padding:0 6px;background:#eee;box-shadow:0 1px 3px 0px rgba(50, 50, 50, 0.25);cursor:pointer;position:relative;" class="togglenext">' . $key . '<div style="color:#aaa;position:absolute;right:0;" class="dashicons dashicons-arrow-down"></div></h4>';
                                echo '<div style="display:none;">' . wp_text_diff($posts_modified['before'][$key], $postmod) . '</div>';
                            }
                        } else {
                            if (date($this->settings['time_format'], strtotime($mod->modified)) != $last_time) {
                                $last_time = date($this->settings['time_format'], strtotime($mod->modified));
                                echo $last_time . '</td><td style="vertical-align:top;width:100%;">';
                            }
                        }
                        if (!empty($postmeta_mods)) {
                            foreach ($postmeta_mods as $key => $metamod) {
                                echo '<h4 style="margin:0;padding:0 6px;background:#eee;box-shadow:0 1px 3px 0px rgba(50, 50, 50, 0.25);cursor:pointer;position:relative;" class="togglenext">' . $key . '<div style="color:#aaa;position:absolute;right:0;" class="dashicons dashicons-arrow-down"></div></h4>';
                                if (!isset($post_modified['before'][$key])) {
                                    echo '<div style="display:none;">Set value to <strong>' . $metamod[0] . '</strong></div>';
                                } else {
                                    $diff = wp_text_diff($postmeta_modified['before'][$key], $metamod);
                                    echo '<div style="display:none;">' . wp_text_diff($postmeta_modified['before'][$key], $metamod) . '</div>';
                                }
                            }
                        } else {
                            $diff = $this->array_diff_meta($postmeta_modified['after'], $postmeta_modified['before']);
                            if (!empty($diff)) {
                                foreach ($diff as $key => $change) {
                                    echo '<h4 style="margin:0;padding:0 6px;background:#eee;box-shadow:0 1px 3px 0px rgba(50, 50, 50, 0.25);cursor:pointer;" class="togglenext">' . $key . '<div style="float:right;color:#aaa;clear:right;" class="dashicons dashicons-arrow-down"></div></h4>';
                                    echo '<div style="display:none;">' . wp_text_diff($postmeta_modified['before'][$key][0], $change) . '</div>';
                                }
                            }
                        }
                        echo '</td>';
                        echo '</tr>';
                    }
                }
                $last_user = $user;
            }
            ?>
			</tbody>
		</table>
		<?php 
        } else {
            echo '<h2>No modification history is available for this post.</h2>';
        }
        ?>

		<script>
			jQuery(document).ready(function($) {
				$('h4.togglenext').on('click', function() {
					$(this).next().stop().slideToggle();
					if ( $(this).children('.dashicons-arrow-down').length ) {
						$(this).children('.dashicons-arrow-down').removeClass('dashicons-arrow-down').addClass('dashicons-arrow-up');
					} else {
						$(this).children('.dashicons-arrow-up').removeClass('dashicons-arrow-up').addClass('dashicons-arrow-down');
					}
				});
			});
		</script>

		<?php 
    }