Example #1
0
function storeForumNames($db, $username, $password, $email, $sig, $occ, $from, $website, $icq, $aim, $yim, $msnm, $interests, $viewemail, $gametype)
{
    $username = strip_tags($username);
    $username = trim($username);
    $username = normalize_whitespace($username);
    $username = mysql_escape_string($username);
    $sig = chop($sig);
    // Strip all trailing whitespace.
    $sig = str_replace("\n", "<BR>", $sig);
    $sig = mysql_escape_string($sig);
    $occ = mysql_escape_string($occ);
    $intrest = mysql_escape_string($intrest);
    $from = mysql_escape_string($from);
    $password = str_replace("\\", "", $password);
    $passwd = md5($password);
    $email = mysql_escape_string($email);
    $regdate = time();
    // Ensure the website URL starts with "http://".
    $website = trim($website);
    if (substr(strtolower($website), 0, 7) != "http://") {
        $website = "http://" . $website;
    }
    if ($website == "http://") {
        $website = "";
    }
    $website = mysql_escape_string($website);
    // Check if the ICQ number only contains digits
    $icq = ereg("^[0-9]+\$", $icq) ? $icq : '';
    $aim = mysql_escape_string($aim);
    $yim = mysql_escape_string($yim);
    $msnm = mysql_escape_string($msnm);
    if ($viewemail == "1") {
        $sqlviewemail = "1";
    } else {
        $sqlviewemail = "0";
    }
    $sql = "SELECT max(user_id) AS total FROM users";
    if (!($r = mysql($db, $sql))) {
        return -1;
    }
    list($total) = mysql_fetch_array($r);
    $total += 1;
    $userDateFormat = $board_config['default_dateformat'];
    $userTimeZone = $board_config['board_timezone'];
    $sql = "INSERT INTO users (user_id, username, user_dateformat, user_timezone, user_regdate, user_email, user_icq, user_password, user_occ, user_interests, user_from, user_website, user_sig, user_aim, user_viewemail, user_yim, user_msnm, user_game_type) VALUES ('{$total}', '{$username}', '{$userDateFormat}', '{$userTimeZone}', '{$regdate}', '{$email}', '{$icq}', '{$passwd}', '{$occ}', '{$intrest}', '{$from}', '{$website}', '{$sig}', '{$aim}', '{$sqlviewemail}', '{$yim}', '{$msnm}', '{$gametype}')";
    if (!($result = mysql($db, $sql))) {
        return -1;
    }
    return $total;
}
 public function bp_email(BP_Email $email)
 {
     $recipients = $email->get_to();
     $to = array();
     foreach ($recipients as $recipient) {
         $to[] = $recipient->get_address();
     }
     $subject = $email->get_subject('replace-tokens');
     $message = normalize_whitespace($email->get_content_plaintext('replace-tokens'));
     $filter_set = false;
     if ('plaintext' != Sendgrid_Tools::get_content_type()) {
         add_filter('wp_mail_content_type', array($this, 'set_html_content_type'), 100);
         $filter_set = true;
         $message = $email->get_template('add-content');
     }
     $result = wp_mail($to, $subject, $message);
     if ($filter_set) {
         remove_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
     }
     return $result;
 }
Example #3
0
 /**
  * Save the data for a new commit to the database
  *
  * @param  Array           $commit Zip model of the parent to save
  * @return array|\WP_Error         revision meta saved, WP_Error if failed
  * @since  0.5.0
  */
 public function by_ids($ids)
 {
     // reset object defaults
     $this->changed = false;
     $this->commit_meta = array('state_ids' => array());
     $this->commit_id = 0;
     $this->ids = $ids;
     if (!array_key_exists('zip', $this->ids) || !is_integer($this->ids['zip'])) {
         // @todo add message
         return new \WP_Error();
     }
     if (array_key_exists('files', $this->ids) && is_array($this->ids['files'])) {
         $this->states_by_file_ids($this->ids['files']);
     }
     if (array_key_exists('deleted', $this->ids) && is_array($this->ids['deleted'])) {
         $this->deleted_states_by_file_ids($this->ids['deleted']);
     }
     // If files haven't changed...
     if (!$this->changed) {
         // ...and if no states are connected...
         if (empty($this->commit_meta['state_ids'])) {
             // ...then we're done.
             return $this->ids;
         }
         $revisions = wp_get_post_revisions($this->ids['zip']);
         // ...and there are no commits...
         if (empty($revisions)) {
             // ...save a commit...
             $this->commit_id = wp_save_post_revision($this->ids['zip']);
         }
         // ...but if files have changed and no commit was saved...
     } elseif (0 === $this->commit_id) {
         // ...save a commit...
         $this->commit_id = wp_save_post_revision($this->ids['zip']);
     }
     // ...and if no commit has been saved...
     if (0 === $this->commit_id) {
         $prev_revision = array_shift($revisions);
         $current_post = get_post($this->ids['zip']);
         // ...and if the description has changed...
         if (normalize_whitespace($current_post->post_title) !== normalize_whitespace($prev_revision->post_title)) {
             // ...save a commit...
             $this->commit_id = wp_save_post_revision($this->ids['zip']);
         }
     }
     // ...and if a commit has been saved...
     if (0 !== $this->commit_id) {
         // ...save the commit meta.
         update_metadata('post', $this->commit_id, '_wpgp_commit_meta', $this->commit_meta);
     }
     return $this->ids;
 }
Example #4
0
 /**
  * Displays a human readable HTML representation of the difference between two strings.
  *
  * The Diff is available for getting the changes between versions. The output is
  * HTML, so the primary use is for displaying the changes. If the two strings
  * are equivalent, then an empty string will be returned.
  *
  * The arguments supported and can be changed are listed below.
  *
  * 'title' : Default is an empty string. Titles the diff in a manner compatible
  *		with the output.
  * 'title_left' : Default is an empty string. Change the HTML to the left of the
  *		title.
  * 'title_right' : Default is an empty string. Change the HTML to the right of
  *		the title.
  *
  * @since 2.6.0
  *
  * @see wp_parse_args() Used to change defaults to user defined settings.
  * @uses Text_Diff
  * @uses WP_Text_Diff_Renderer_Table
  *
  * @param string $left_string "old" (left) version of string
  * @param string $right_string "new" (right) version of string
  * @param string|array $args Optional. Change 'title', 'title_left', and 'title_right' defaults.
  * @return string Empty string if strings are equivalent or HTML with differences.
  */
 function wp_text_diff($left_string, $right_string, $args = null)
 {
     $defaults = array('title' => '', 'title_left' => '', 'title_right' => '');
     $args = wp_parse_args($args, $defaults);
     if (!class_exists('WP_Text_Diff_Renderer_Table')) {
         require ABSPATH . WPINC . '/wp-diff.php';
     }
     $left_string = normalize_whitespace($left_string);
     $right_string = normalize_whitespace($right_string);
     $left_lines = explode("\n", $left_string);
     $right_lines = explode("\n", $right_string);
     $text_diff = new Text_Diff($left_lines, $right_lines);
     $renderer = new WP_Text_Diff_Renderer_Table($args);
     $diff = $renderer->render($text_diff);
     if (!$diff) {
         return '';
     }
     $r = "<table class='diff'>\n";
     if (!empty($args['show_split_view'])) {
         $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />";
     } else {
         $r .= "<col class='content' />";
     }
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= "<thead>";
     }
     if ($args['title']) {
         $r .= "<tr class='diff-title'><th colspan='4'>{$args['title']}</th></tr>\n";
     }
     if ($args['title_left'] || $args['title_right']) {
         $r .= "<tr class='diff-sub-title'>\n";
         $r .= "\t<td></td><th>{$args['title_left']}</th>\n";
         $r .= "\t<td></td><th>{$args['title_right']}</th>\n";
         $r .= "</tr>\n";
     }
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= "</thead>\n";
     }
     $r .= "<tbody>\n{$diff}\n</tbody>\n";
     $r .= "</table>";
     return $r;
 }
Example #5
0
/**
 * Creates autosave data for the specified post from $_POST data.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 * @since 2.6.0
 *
 * @param mixed $post_data Associative array containing the post data or int post ID.
 * @return mixed The autosave revision ID. WP_Error or 0 on error.
 */
function wp_create_post_autosave($post_data)
{
    if (is_numeric($post_data)) {
        $post_id = $post_data;
        $post_data = $_POST;
    } else {
        $post_id = (int) $post_data['post_ID'];
    }
    $post_data = _wp_translate_postdata(true, $post_data);
    if (is_wp_error($post_data)) {
        return $post_data;
    }
    $post_author = get_current_user_id();
    // Store one autosave per author. If there is already an autosave, overwrite it.
    if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) {
        $new_autosave = _wp_post_revision_data($post_data, true);
        $new_autosave['ID'] = $old_autosave->ID;
        $new_autosave['post_author'] = $post_author;
        // If the new autosave has the same content as the post, delete the autosave.
        $post = get_post($post_id);
        $autosave_is_different = false;
        foreach (array_intersect(array_keys($new_autosave), array_keys(_wp_post_revision_fields($post))) as $field) {
            if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->{$field})) {
                $autosave_is_different = true;
                break;
            }
        }
        if (!$autosave_is_different) {
            wp_delete_post_revision($old_autosave->ID);
            return 0;
        }
        /**
         * Fires before an autosave is stored.
         *
         * @since 4.1.0
         *
         * @param array $new_autosave Post array - the autosave that is about to be saved.
         */
        do_action('wp_creating_autosave', $new_autosave);
        return wp_update_post($new_autosave);
    }
    // _wp_put_post_revision() expects unescaped.
    $post_data = wp_unslash($post_data);
    // Otherwise create the new autosave as a special post revision
    return _wp_put_post_revision($post_data, true);
}
Example #6
0
if ('auto-draft' == $post->post_status) {
    if ('edit' == $action) {
        $post->post_title = '';
    }
    $autosave = false;
    $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
} else {
    $autosave = nxt_get_post_autosave($post_ID);
}
$form_action = 'editpost';
$nonce_action = 'update-' . $post_type . '_' . $post_ID;
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($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, false) > mysql2date('U', $post->post_modified_gmt, false)) {
    foreach (_nxt_post_revision_fields() as $autosave_field => $_autosave_field) {
        if (normalize_whitespace($autosave->{$autosave_field}) != normalize_whitespace($post->{$autosave_field})) {
            $notice = sprintf(__('There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>'), get_edit_post_link($autosave->ID));
            break;
        }
    }
    unset($autosave_field, $_autosave_field);
}
$post_type_object = get_post_type_object($post_type);
// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
require_once './includes/meta-boxes.php';
add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core');
if (current_theme_supports('post-formats') && post_type_supports($post_type, 'post-formats')) {
    add_meta_box('formatdiv', _x('Format', 'post format'), 'post_format_meta_box', null, 'side', 'core');
}
// all taxonomies
foreach (get_object_taxonomies($post_type) as $tax_name) {
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 get_autosave_notice()
 {
     global $post;
     if ('auto-draft' == $post->post_status) {
         $autosave = false;
     } else {
         $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, false) > mysql2date('U', $post->post_modified_gmt, false)) {
         foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
             if (normalize_whitespace($autosave->{$autosave_field}) !== normalize_whitespace($post->{$autosave_field})) {
                 return sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>'), get_edit_post_link($autosave->ID));
             }
         }
         // If this autosave isn't different from the current post, begone.
         wp_delete_post_revision($autosave->ID);
     }
     return false;
 }
Example #9
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>';
    }
}
Example #10
0
/**
 * Saves an already existing post as a post revision.
 *
 * Typically used immediately after post updates.
 * Adds a copy of the current post as a revision, so latest revision always matches current post
 *
 * @since 2.6.0
 *
 * @uses _wp_put_post_revision()
 *
 * @param int $post_id The ID of the post to save as a revision.
 * @return mixed Null or 0 if error, new revision ID, if success.
 */
function wp_save_post_revision($post_id)
{
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (!($post = get_post($post_id))) {
        return;
    }
    if (!post_type_supports($post->post_type, 'revisions')) {
        return;
    }
    if ('auto-draft' == $post->post_status) {
        return;
    }
    if (!wp_revisions_enabled($post)) {
        return;
    }
    // Compare the proposed update with the last stored revision verifying that
    // they are different, unless a plugin tells us to always save regardless.
    // If no previous revisions, save one
    if ($revisions = wp_get_post_revisions($post_id)) {
        // grab the last revision, but not an autosave
        foreach ($revisions as $revision) {
            if (false !== strpos($revision->post_name, "{$revision->post_parent}-revision")) {
                $last_revision = $revision;
                break;
            }
        }
        if (isset($last_revision) && apply_filters('wp_save_post_revision_check_for_changes', true, $last_revision, $post)) {
            $post_has_changed = false;
            foreach (array_keys(_wp_post_revision_fields()) as $field) {
                if (normalize_whitespace($post->{$field}) != normalize_whitespace($last_revision->{$field})) {
                    $post_has_changed = true;
                    break;
                }
            }
            //don't save revision if post unchanged
            if (!$post_has_changed) {
                return;
            }
        }
    }
    $return = _wp_put_post_revision($post);
    $revisions_to_keep = wp_revisions_to_keep($post);
    if ($revisions_to_keep < 0) {
        return $return;
    }
    // all revisions and autosaves
    $revisions = wp_get_post_revisions($post_id, array('order' => 'ASC'));
    $delete = count($revisions) - $revisions_to_keep;
    if ($delete < 1) {
        return $return;
    }
    $revisions = array_slice($revisions, 0, $delete);
    for ($i = 0; isset($revisions[$i]); $i++) {
        if (false !== strpos($revisions[$i]->post_name, 'autosave')) {
            continue;
        }
        wp_delete_post_revision($revisions[$i]->ID);
    }
    return $return;
}
 function wp_text_diff($left_string, $right_string, $args = null)
 {
     $defaults = array('title' => '', 'title_left' => '', 'title_right' => '');
     $args = wp_parse_args($args, $defaults);
     $left_string = normalize_whitespace($left_string);
     $right_string = normalize_whitespace($right_string);
     $left_lines = explode("\n", $left_string);
     $right_lines = explode("\n", $right_string);
     $text_diff = new Text_Diff($left_lines, $right_lines);
     $renderer = new Email_Post_Changes_Diff();
     $diff = $renderer->render($text_diff);
     if (!$diff) {
         return '';
     }
     $r = "<table class='diff'>\n";
     $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= "<thead>";
     }
     if ($args['title']) {
         $r .= "<tr class='diff-title'><th colspan='4'>{$args['title']}</th></tr>\n";
     }
     if ($args['title_left'] || $args['title_right']) {
         $r .= "<tr class='diff-sub-title'>\n";
         $r .= "\t<td></td><th>{$args['title_left']}</th>\n";
         $r .= "\t<td></td><th>{$args['title_right']}</th>\n";
         $r .= "</tr>\n";
     }
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= "</thead>\n";
     }
     $r .= "<tbody>\n{$diff}\n</tbody>\n";
     $r .= "</table>";
     return $r;
 }
Example #12
0
function geodir_cp_from_submit_handler()
{
    global $plugin_prefix, $wpdb;
    if (isset($_REQUEST['geodir_save_post_type'])) {
        $custom_post_type = trim($_REQUEST['geodir_custom_post_type']);
        $listing_slug = trim($_REQUEST['geodir_listing_slug']);
        $listing_order = trim($_REQUEST['geodir_listing_order']);
        $categories = $_REQUEST['geodir_categories'];
        $tags = isset($_REQUEST['geodir_tags']) ? $_REQUEST['geodir_tags'] : '';
        $name = $_REQUEST['geodir_name'];
        //htmlentities(trim($_REQUEST['geodir_name']));
        $singular_name = trim($_REQUEST['geodir_singular_name']);
        $add_new = trim($_REQUEST['geodir_add_new']);
        $add_new_item = trim($_REQUEST['geodir_add_new_item']);
        $edit_item = trim($_REQUEST['geodir_edit_item']);
        $new_item = trim($_REQUEST['geodir_new_item']);
        $view_item = trim($_REQUEST['geodir_view_item']);
        $search_item = trim($_REQUEST['geodir_search_item']);
        $not_found = trim($_REQUEST['geodir_not_found']);
        $not_found_trash = trim($_REQUEST['geodir_not_found_trash']);
        $support = $_REQUEST['geodir_support'];
        $description = trim($_REQUEST['geodir_description']);
        $menu_icon = trim($_REQUEST['geodir_menu_icon']);
        $can_export = $_REQUEST['geodir_can_export'];
        $geodir_cp_meta_keyword = $_REQUEST['geodir_cp_meta_keyword'];
        $geodir_cp_meta_description = $_REQUEST['geodir_cp_meta_description'];
        $label_post_profile = stripslashes_deep(normalize_whitespace($_REQUEST['geodir_label_post_profile']));
        $label_post_info = stripslashes_deep(normalize_whitespace($_REQUEST['geodir_label_post_info']));
        $label_post_images = stripslashes_deep(normalize_whitespace($_REQUEST['geodir_label_post_images']));
        $label_post_map = stripslashes_deep(normalize_whitespace($_REQUEST['geodir_label_post_map']));
        $label_reviews = stripslashes_deep(normalize_whitespace($_REQUEST['geodir_label_reviews']));
        $label_related_listing = stripslashes_deep(normalize_whitespace($_REQUEST['geodir_label_related_listing']));
        $cpt_image = isset($_FILES['geodir_cpt_img']) && !empty($_FILES['geodir_cpt_img']) ? $_FILES['geodir_cpt_img'] : NULL;
        $cpt_image_remove = isset($_POST['geodir_cpt_img_remove']) ? $_POST['geodir_cpt_img_remove'] : false;
        if ($can_export == 'true') {
            $can_export = true;
        } else {
            $can_export = false;
        }
        $custom_post_type = geodir_clean($custom_post_type);
        // erase special characters from string
        $listing_slug = geodir_clean($listing_slug);
        // erase special characters from string
        if (isset($_REQUEST['posttype']) && $_REQUEST['posttype'] != '') {
            $geodir_post_types = get_option('geodir_post_types');
            $post_type_array = $geodir_post_types[$_REQUEST['posttype']];
        }
        if ($custom_post_type != '' && $listing_slug != '') {
            if (empty($post_type_array)) {
                $is_custom = 1;
                //check post type create by custom or any other add-once
                $posttypes_array = get_option('geodir_post_types');
                $post_type = $custom_post_type;
                $custom_post_type = 'gd_' . $custom_post_type;
                if (array_key_exists($custom_post_type, $posttypes_array)) {
                    $error[] = __('Post Type already exists.', GEODIR_CP_TEXTDOMAIN);
                }
                foreach ($posttypes_array as $key => $value) {
                    if ($value['has_archive'] == $listing_slug) {
                        $error[] = __('Listing Slug already exists.', GEODIR_CP_TEXTDOMAIN);
                        break;
                    }
                }
            } else {
                $post_type = preg_replace('/gd_/', '', $_REQUEST['posttype'], 1);
                $custom_post_type = $_REQUEST['posttype'];
                $is_custom = isset($post_type_array['is_custom']) ? $post_type_array['is_custom'] : '';
                /*check post type create by custom or any other add-once */
                //Edit case check duplicate listing slug
                if ($post_type_array['has_archive'] != $listing_slug) {
                    $posttypes_array = get_option('geodir_post_types');
                    foreach ($posttypes_array as $key => $value) {
                        if ($value['has_archive'] == $listing_slug) {
                            $error[] = __('Listing Slug already exists.', GEODIR_CP_TEXTDOMAIN);
                            break;
                        }
                    }
                }
            }
            if (empty($error)) {
                /**
                 * Include any functions needed for upgrades.
                 *
                 * @since 1.1.7
                 */
                require_once ABSPATH . 'wp-admin/includes/upgrade.php';
                if (!empty($post_type_array)) {
                    if (!$categories) {
                        $geodir_taxonomies = get_option('geodir_taxonomies');
                        if (array_key_exists($custom_post_type . 'category', $geodir_taxonomies)) {
                            unset($geodir_taxonomies[$custom_post_type . 'category']);
                            update_option('geodir_taxonomies', $geodir_taxonomies);
                        }
                    }
                    if (!$tags) {
                        $geodir_taxonomies = get_option('geodir_taxonomies');
                        if (array_key_exists($custom_post_type . '_tags', $geodir_taxonomies)) {
                            unset($geodir_taxonomies[$custom_post_type . '_tags']);
                            update_option('geodir_taxonomies', $geodir_taxonomies);
                        }
                    }
                }
                $taxonomies = array();
                if ($categories) {
                    $taxonomies[] = $custom_post_type . 'category';
                    $categories = $custom_post_type . 'category';
                }
                if ($tags) {
                    $taxonomies[] = $custom_post_type . '_tags';
                    $tags = $custom_post_type . '_tags';
                }
                if ($categories) {
                    $gd_placecategory = array();
                    $gd_placecategory['object_type'] = $custom_post_type;
                    $gd_placecategory['listing_slug'] = $listing_slug;
                    $gd_placecategory['args'] = array('public' => true, 'hierarchical' => true, 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true), 'query_var' => true, 'labels' => array('name' => __(ucfirst($post_type) . ' Categories', GEODIR_CP_TEXTDOMAIN), 'singular_name' => __(ucfirst($post_type) . ' Category', GEODIR_CP_TEXTDOMAIN), 'search_items' => __('Search ' . ucfirst($post_type) . ' Categories', GEODIR_CP_TEXTDOMAIN), 'popular_items' => __('Popular ' . ucfirst($post_type) . ' Categories', GEODIR_CP_TEXTDOMAIN), 'all_items' => __('All ' . ucfirst($post_type) . ' Categories', GEODIR_CP_TEXTDOMAIN), 'edit_item' => __('Edit ' . ucfirst($post_type) . ' Category', GEODIR_CP_TEXTDOMAIN), 'update_item' => __('Update ' . ucfirst($post_type) . ' Category', GEODIR_CP_TEXTDOMAIN), 'add_new_item' => __('Add New ' . ucfirst($post_type) . ' Category', GEODIR_CP_TEXTDOMAIN), 'new_item_name' => __('New ' . ucfirst($post_type) . ' Category', GEODIR_CP_TEXTDOMAIN), 'add_or_remove_items' => __('Add or remove ' . ucfirst($post_type) . ' categories', GEODIR_CP_TEXTDOMAIN)), 'show_in_nav_menus' => !empty($_REQUEST['geodir_disable_nav_menus']['cats']) ? 0 : 1);
                    $geodir_taxonomies = get_option('geodir_taxonomies');
                    $geodir_taxonomies[$categories] = $gd_placecategory;
                    update_option('geodir_taxonomies', $geodir_taxonomies);
                }
                if ($tags) {
                    $gd_placetags = array();
                    $gd_placetags['object_type'] = $custom_post_type;
                    $gd_placetags['listing_slug'] = $listing_slug . '/tags';
                    $gd_placetags['args'] = array('public' => true, 'hierarchical' => false, 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => false), 'query_var' => true, 'labels' => array('name' => __(ucfirst($post_type) . ' Tags', GEODIR_CP_TEXTDOMAIN), 'singular_name' => __(ucfirst($post_type) . ' Tag', GEODIR_CP_TEXTDOMAIN), 'search_items' => __('Search ' . ucfirst($post_type) . ' Tags', GEODIR_CP_TEXTDOMAIN), 'popular_items' => __('Popular ' . ucfirst($post_type) . ' Tags', GEODIR_CP_TEXTDOMAIN), 'all_items' => __('All ' . ucfirst($post_type) . ' Tags', GEODIR_CP_TEXTDOMAIN), 'edit_item' => __('Edit ' . ucfirst($post_type) . ' Tag', GEODIR_CP_TEXTDOMAIN), 'update_item' => __('Update ' . ucfirst($post_type) . ' Tag', GEODIR_CP_TEXTDOMAIN), 'add_new_item' => __('Add New ' . ucfirst($post_type) . ' Tag', GEODIR_CP_TEXTDOMAIN), 'new_item_name' => __('New ' . ucfirst($post_type) . ' Tag Name', GEODIR_CP_TEXTDOMAIN), 'add_or_remove_items' => __('Add or remove ' . ucfirst($post_type) . ' tags', GEODIR_CP_TEXTDOMAIN), 'choose_from_most_used' => __('Choose from the most used ' . ucfirst($post_type) . ' tags', GEODIR_CP_TEXTDOMAIN), 'separate_items_with_commas' => __('Separate ' . ucfirst($post_type) . ' tags with commas', GEODIR_CP_TEXTDOMAIN)), 'show_in_nav_menus' => !empty($_REQUEST['geodir_disable_nav_menus']['tags']) ? 0 : 1);
                    $geodir_taxonomies = get_option('geodir_taxonomies');
                    $geodir_taxonomies[$tags] = $gd_placetags;
                    update_option('geodir_taxonomies', $geodir_taxonomies);
                }
                if (empty($name)) {
                    $name = __(ucfirst($post_type), GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($singular_name)) {
                    $singular_name = __(ucfirst($post_type), GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($add_new)) {
                    $add_new = __('Add New ' . ucfirst($post_type), GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($add_new_item)) {
                    $add_new_item = __('Add New Item', GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($edit_item)) {
                    $edit_item = __('Edit Item', GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($new_item)) {
                    $new_item = __('New Item', GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($view_item)) {
                    $view_item = __('View Item', GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($search_item)) {
                    $search_item = __('Search Items', GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($not_found)) {
                    $not_found = __('Not Found', GEODIR_CP_TEXTDOMAIN);
                }
                if (empty($not_found_trash)) {
                    $not_found_trash = __('Not Found In Trash', GEODIR_CP_TEXTDOMAIN);
                }
                $labels = array('name' => ucfirst($name), 'singular_name' => ucfirst($singular_name), 'add_new' => ucfirst($add_new), 'add_new_item' => ucfirst($add_new_item), 'edit_item' => ucfirst($edit_item), 'new_item' => ucfirst($new_item), 'view_item' => ucfirst($view_item), 'search_items' => ucfirst($search_item), 'not_found' => ucfirst($not_found), 'not_found_in_trash' => ucfirst($not_found_trash), 'label_post_profile' => $label_post_profile, 'label_post_info' => $label_post_info, 'label_post_images' => $label_post_images, 'label_post_map' => $label_post_map, 'label_reviews' => $label_reviews, 'label_related_listing' => $label_related_listing);
                $place_default = array('labels' => $labels, 'can_export' => $can_export, 'capability_type' => 'post', 'description' => $description, 'has_archive' => $listing_slug, 'hierarchical' => false, 'map_meta_cap' => true, 'menu_icon' => apply_filters('geodir_custom_post_type_default_menu_icon', $menu_icon), 'public' => true, 'query_var' => true, 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true), 'supports' => $support, 'taxonomies' => $taxonomies, 'is_custom' => $is_custom, 'listing_order' => $listing_order, 'seo' => array('meta_keyword' => $geodir_cp_meta_keyword, 'meta_description' => $geodir_cp_meta_description), 'show_in_nav_menus' => !empty($_REQUEST['geodir_disable_nav_menus']['posts']) ? 0 : 1);
                update_option('temp_post_type', $place_default);
                $geodir_post_types = get_option('geodir_post_types');
                $geodir_post_types[$custom_post_type] = $place_default;
                update_option('geodir_post_types', $geodir_post_types);
                //ADD NEW CUSTOM POST TYPE IN SHOW POST TYPE NAVIGATIONS
                if (!isset($_REQUEST['posttype'])) {
                    $get_posttype_settings_options = array('geodir_add_posttype_in_listing_nav', 'geodir_allow_posttype_frontend', 'geodir_add_listing_link_add_listing_nav', 'geodir_add_listing_link_user_dashboard', 'geodir_listing_link_user_dashboard', 'geodir_favorite_link_user_dashboard');
                    foreach ($get_posttype_settings_options as $get_posttype_settings_options_obj) {
                        $geodir_post_types_listing = get_option($get_posttype_settings_options_obj);
                        if (empty($geodir_post_types_listing) || is_array($geodir_post_types_listing) && !in_array($custom_post_type, $geodir_post_types_listing)) {
                            $geodir_post_types_listing[] = $custom_post_type;
                            update_option($get_posttype_settings_options_obj, $geodir_post_types_listing);
                        }
                    }
                }
                // Save post types in default table
                if (empty($post_type_array)) {
                    $geodir_custom_post_types = get_option('geodir_custom_post_types');
                    if (!$geodir_custom_post_types) {
                        $geodir_custom_post_types = array();
                    }
                    if (!array_key_exists($custom_post_type, $geodir_custom_post_types)) {
                        $geodir_custom_post_types[$custom_post_type] = $custom_post_type;
                        update_option('geodir_custom_post_types', $geodir_custom_post_types);
                    }
                }
                // Table for storing custom post type attribute - these are user defined
                $collate = '';
                if ($wpdb->has_cap('collation')) {
                    if (!empty($wpdb->charset)) {
                        $collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
                    }
                    if (!empty($wpdb->collate)) {
                        $collate .= " COLLATE {$wpdb->collate}";
                    }
                }
                $newtable_name = $plugin_prefix . $custom_post_type . '_detail';
                $newposttype_detail = "CREATE TABLE IF NOT EXISTS " . $newtable_name . " (\n\t\t\t\t\t\t\t\t\t\t`post_id` int(11) NOT NULL,\n\t\t\t\t\t\t\t\t\t\t`post_title` text NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`post_status` varchar(20) NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`default_category` INT NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`post_tags` text NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`post_location_id` int(11) NOT NULL,\n\t\t\t\t\t\t\t\t\t\t`marker_json` text NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`claimed` ENUM( '1', '0' ) NULL DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t`businesses` ENUM( '1', '0' ) NULL DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t`is_featured` ENUM( '1', '0' ) NULL DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t`featured_image` VARCHAR( 254 ) NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`paid_amount` DOUBLE NOT NULL DEFAULT '0', \n\t\t\t\t\t\t\t\t\t\t`package_id` INT(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t`alive_days` INT(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t`paymentmethod` varchar(30) NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`expire_date` VARCHAR( 100 ) NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`submit_time` varchar(25) NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`submit_ip` varchar(15) NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\t`overall_rating` float(11) DEFAULT NULL, \n\t\t\t\t\t\t\t\t\t\t`rating_count` INT(11) DEFAULT '0',\n\t\t\t\t\t\t\t\t\t\t`post_locations` VARCHAR( 254 ) NULL DEFAULT NULL,\n\t\t\t\t\t\t\t\t\t\tPRIMARY KEY (`post_id`)) {$collate} ";
                dbDelta($newposttype_detail);
                do_action('geodir_after_custom_detail_table_create', $custom_post_type, $newtable_name);
                $package_info = array();
                /*$package_info = apply_filters('geodir_post_package_info' , $package_info , '', $custom_post_type);
                		$package_id = $package_info->pid;*/
                $package_info = geodir_post_package_info($package_info, '', $custom_post_type);
                $package_id = $package_info->pid;
                if (!$wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE FIND_IN_SET(%s, packages)", array($package_id)))) {
                    $table = $plugin_prefix . $custom_post_type . '_detail';
                    $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET package_id=%d", array($package_id)));
                    $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET packages=%s WHERE post_type=%s", array($package_id, $custom_post_type)));
                }
                geodir_cp_create_default_fields($custom_post_type, $package_id);
                $msg = __('Post type created successfully.', GEODIR_CP_TEXTDOMAIN);
                if (isset($_REQUEST['posttype']) && $_REQUEST['posttype'] != '') {
                    $msg = __('Post type updated successfully.', GEODIR_CP_TEXTDOMAIN);
                }
                /// call the geodirectory core function to register all posttypes again.
                geodir_register_post_types();
                // call the geodirectory core function to register all taxonomies again.
                geodir_register_taxonomies();
                geodir_flush_rewrite_rules();
                geodir_set_user_defined_order();
                // Save CPT image
                $uploads = wp_upload_dir();
                // if remove is set then remove the file
                if ($cpt_image_remove) {
                    if (get_option('geodir_cpt_img_' . $custom_post_type)) {
                        $image_name_arr = explode('/', get_option('geodir_cpt_img_' . $custom_post_type));
                        $img_path = $uploads['path'] . '/' . end($image_name_arr);
                        if (file_exists($img_path)) {
                            unlink($img_path);
                        }
                    }
                    update_option('geodir_cpt_img_' . $custom_post_type, '');
                }
                if ($cpt_image) {
                    $tmp_name = isset($cpt_image['tmp_name']) ? $cpt_image['tmp_name'] : '';
                    $filename = isset($cpt_image['name']) ? $cpt_image['name'] : '';
                    $ext = pathinfo($filename, PATHINFO_EXTENSION);
                    $uplaods = array();
                    $uplaods[] = $tmp_name;
                    $allowed_file_types = array('jpg' => 'image/jpg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png');
                    $upload_overrides = array('test_form' => false, 'mimes' => $allowed_file_types);
                    $cpt_img = wp_handle_upload($cpt_image, $upload_overrides);
                    if (!empty($cpt_img) && !empty($cpt_img['url'])) {
                        if (get_option('geodir_cpt_img_' . $custom_post_type)) {
                            $image_name_arr = explode('/', get_option('geodir_cpt_img_' . $custom_post_type));
                            $img_path = $uploads['path'] . '/' . end($image_name_arr);
                            if (file_exists($img_path)) {
                                unlink($img_path);
                            }
                        }
                        // set width and height
                        $w = apply_filters('geodir_cpt_img_width', 300);
                        // get large size width
                        $h = apply_filters('geodir_cpt_img_height', 300);
                        // get large size width
                        // get the uploaded image
                        $cpt_img_file = wp_get_image_editor($cpt_img['file']);
                        // if no error
                        if (!is_wp_error($cpt_img_file)) {
                            // get image width and height
                            $size = getimagesize($cpt_img['file']);
                            // $size[0] = width, $size[1] = height
                            if ($size[0] > $w || $size[1] > $h) {
                                // if the width or height is larger than the large-size
                                $cpt_img_file->resize($w, $h, false);
                                // resize the image
                                $final_image = $cpt_img_file->save($cpt_img['file']);
                                // save the resized image
                            }
                        }
                        update_option('geodir_cpt_img_' . $custom_post_type, $cpt_img['url']);
                    }
                }
                $msg = urlencode($msg);
                $redirect_to = admin_url() . 'admin.php?page=geodirectory&tab=geodir_manage_custom_posts&cp_success=' . $msg;
                wp_redirect($redirect_to);
                exit;
            } else {
                global $cp_error;
                foreach ($error as $err) {
                    $cp_error .= '<div id="message" style="color:#FF0000;" class="updated fade"><p><strong>' . $err . '</strong></p></div>';
                }
            }
        }
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'cp_delete') {
        if ($_REQUEST['posttype']) {
            $geodir_taxonomies = get_option('geodir_taxonomies');
            if (array_key_exists($_REQUEST['posttype'] . 'category', $geodir_taxonomies)) {
                unset($geodir_taxonomies[$_REQUEST['posttype'] . 'category']);
                update_option('geodir_taxonomies', $geodir_taxonomies);
            }
            if (array_key_exists($_REQUEST['posttype'] . '_tags', $geodir_taxonomies)) {
                unset($geodir_taxonomies[$_REQUEST['posttype'] . '_tags']);
                update_option('geodir_taxonomies', $geodir_taxonomies);
            }
            $geodir_post_types = get_option('geodir_post_types');
            if (array_key_exists($_REQUEST['posttype'], $geodir_post_types)) {
                unset($geodir_post_types[$_REQUEST['posttype']]);
                update_option('geodir_post_types', $geodir_post_types);
            }
            //UPDATE SHOW POST TYPES NAVIGATION OPTIONS
            $get_posttype_settings_options = array('geodir_add_posttype_in_listing_nav', 'geodir_allow_posttype_frontend', 'geodir_add_listing_link_add_listing_nav', 'geodir_add_listing_link_user_dashboard', 'geodir_listing_link_user_dashboard', 'geodir_favorite_link_user_dashboard');
            foreach ($get_posttype_settings_options as $get_posttype_settings_options_obj) {
                $geodir_post_types_listing = get_option($get_posttype_settings_options_obj);
                if (in_array($_REQUEST['posttype'], $geodir_post_types_listing)) {
                    $geodir_update_post_type_nav = array_diff($geodir_post_types_listing, array($_REQUEST['posttype']));
                    update_option($get_posttype_settings_options_obj, $geodir_update_post_type_nav);
                }
            }
            //END CODE OPTIONS
            geodir_flush_rewrite_rules();
            $msg = __('Post type deleted successfully.', GEODIR_CP_TEXTDOMAIN);
            $msg = urlencode($msg);
            $redirect_to = admin_url() . 'admin.php?page=geodirectory&tab=geodir_manage_custom_posts&confirm=true&geodir_customposttype=' . $_REQUEST['posttype'] . '&cp_success=' . $msg;
            wp_redirect($redirect_to);
            exit;
        }
    }
}
 public function front_end_editor_shortcodes($attr)
 {
     global $wp, $current_screen, $wp_meta_boxes, $post;
     $is_bac = $this->is_bac();
     $output = '';
     /**
      * Start Checking the Conditional needed to render editor
      * Define Variable needed for use in whole function
      *  
      *
      */
     if (!is_user_logged_in()) {
         if ($is_bac === true) {
             wp_safe_redirect(bon_accounts()->my_account_url());
         } else {
             if (is_woocommerce_activated()) {
                 wp_safe_redirect(get_permalink(wc_get_page_id('myaccount')));
             }
         }
     } else {
         if (!$this->is_edit()) {
             return;
         }
         $object_id = $this->get_post_to_edit();
         if (!$object_id) {
             bon_error_notice()->add('invalid_post', __('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'), 'error');
             return;
         }
         $post_object = get_post($this->get_post_to_edit());
         setup_postdata($GLOBALS['post'] =& $post_object);
         $current_post_type = get_post_type($object_id);
         if (!$post_object) {
             bon_error_notice()->add('invalid_post', __('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'), 'error');
             return;
         }
         if (!current_user_can('edit_post', $object_id)) {
             bon_error_notice()->add('permission_denied', __('You are not allowed to edit this item.'), 'error');
             return;
         }
         if (!post_type_supports($post_object->post_type, 'front-end-editor')) {
             bon_error_notice()->add('unsupported_posttype', __('The post type assigned is not supporting front end post', 'bon'), 'error');
         }
         $form_extra = '';
         $notice = false;
         if ($post_object->post_status === 'auto-draft') {
             $post_object->post_title = '';
             $post_object->comment_status = get_option('default_comment_status');
             $post_object->ping_status = get_option('default_ping_status');
             $autosave = false;
             $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
         } else {
             $autosave = wp_get_post_autosave($object_id);
         }
         $form_action = 'editpost';
         $nonce_action = 'update-post_' . $object_id;
         $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($object_id) . "' />";
         $content_css = array(trailingslashit(get_stylesheet_directory_uri()) . 'assets/css/editor-styles.css', trailingslashit(includes_url()) . 'css/dashicons.min.css', trailingslashit(includes_url()) . 'js/mediaelement/mediaelementplayer.min.css', trailingslashit(includes_url()) . 'js/mediaelement/wp-mediaelement.css', trailingslashit(includes_url()) . 'js/tinymce/skins/wordpress/wp-content.css', trailingslashit(includes_url()) . 'css/editor.min.css');
         $content_css = join(',', array_map('esc_url', array_unique($content_css)));
         $args = array('post_ID' => $object_id, 'post_type' => $current_post_type, 'user_ID' => get_current_user_id(), 'post' => $post_object, 'post_type_object' => get_post_type_object($current_post_type), 'autosave' => $autosave, 'form_extra' => $form_extra, 'form_action' => $form_action, 'nonce_action' => $nonce_action, 'editor_settings' => array('dfw' => true, 'drag_drop_upload' => true, 'tabfocus_elements' => 'insert-media-button, save-post', 'editor_height' => 360, 'tinymce' => array('resize' => false, 'add_unload_trigger' => false, 'content_css' => $content_css)));
         ob_start();
         bon_get_template('posts/editor.php', $args);
         $args['editor'] = ob_get_clean();
         unset($args['editor_settings']);
         set_current_screen($current_post_type);
         $current_screen->set_parentage('edit.php?post_type=' . $current_post_type);
         if (!wp_check_post_lock($object_id)) {
             $args['active_post_lock'] = wp_set_post_lock($object_id);
         }
         $messages = $this->get_wp_messages($post_object);
         $message = false;
         if (isset($_GET['message'])) {
             $_GET['message'] = absint($_GET['message']);
             if (isset($messages[$current_post_type][$_GET['message']])) {
                 $message = $messages[$current_post_type][$_GET['message']];
             } elseif (!isset($messages[$current_post_type]) && isset($messages['post'][$_GET['message']])) {
                 $message = $messages['post'][$_GET['message']];
             }
         }
         // 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, false) > mysql2date('U', $post_object->post_modified_gmt, false)) {
             foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
                 if (normalize_whitespace($autosave->{$autosave_field}) != normalize_whitespace($post_object->{$autosave_field})) {
                     bon_error_notice()->add('autosave_exists', sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>'), get_edit_post_link($autosave->ID)), 'notice');
                     break;
                 }
             }
             // If this autosave isn't different from the current post, begone.
             if (!$notice) {
                 wp_delete_post_revision($autosave->ID);
             }
             unset($autosave_field, $_autosave_field);
         }
         bon_get_template('posts/post.php', $args);
         unset($GLOBALS['current_screen']);
         wp_reset_postdata();
     }
 }
Example #14
0
 /**
  * find newer version of post, or return null if there is no newer autosave version
  *
  * @param $pid
  * @return mixed|null
  */
 public function get_autosave_version_if_newer($pid)
 {
     // Detect if there exists an autosave newer than the post and if that autosave is different than the post
     $autosave = wp_get_post_autosave($pid);
     $post = get_post($pid);
     $newer_revision = null;
     if ($autosave && $post && mysql2date('U', $autosave->post_modified_gmt, false) >= mysql2date('U', $post->post_modified_gmt, false)) {
         foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
             if (normalize_whitespace($autosave->{$autosave_field}) != normalize_whitespace($post->{$autosave_field})) {
                 if ($autosave_field === 'post_content') {
                     $newer_revision = $autosave->{$autosave_field};
                 }
             }
         }
         unset($autosave_field, $_autosave_field);
     }
     return $newer_revision;
 }
Example #15
0
 /**
  * Performs a three-way merge with a fork, it's parent revision, and the current version of the post
  * Caches so that multiple calls to get_diff within the same page load will not re-run the diff each time
  * Passing an object (rather than a fork id) will bypass the cache (to allow for on-the-fly diffing on save
  */
 function get_diff($fork)
 {
     if (!is_object($fork) && ($diff = wp_cache_get($fork, 'Fork_Diff'))) {
         return $diff;
     }
     if (!is_object($fork)) {
         $fork = get_post($fork);
     }
     $fork_id = $fork->ID;
     //grab the three elments
     $parent = $this->parent->revisions->get_parent_revision($fork);
     $current = $fork->post_parent;
     //normalize whitespace and convert string -> array
     foreach (array('fork', 'parent', 'current') as $string) {
         ${$string} = get_post(${$string})->post_content;
         ${$string} = normalize_whitespace(${$string});
         ${$string} = explode("\n", ${$string});
     }
     //diff, cache, return
     $diff = new Text_Diff3($parent, $fork, $current);
     wp_cache_set($fork_id, $diff, 'Fork_Diff', $this->ttl);
     return $diff;
 }
/**
 * Get the cpt texts for translation.
 *
 * @since 1.5.5
 * @package GeoDirectory
 *
 * @param  array $translation_texts Array of text strings.
 * @return array Translation texts.
 */
function geodir_load_cpt_text_translation($translation_texts = array())
{
    $gd_post_types = geodir_get_posttypes('array');
    if (!empty($gd_post_types)) {
        foreach ($gd_post_types as $post_type => $cpt_info) {
            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
            if (!empty($labels)) {
                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
                    $translation_texts[] = $labels['name'];
                }
                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
                    $translation_texts[] = $labels['singular_name'];
                }
                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
                    $translation_texts[] = $labels['add_new'];
                }
                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
                    $translation_texts[] = $labels['add_new_item'];
                }
                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
                    $translation_texts[] = $labels['edit_item'];
                }
                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
                    $translation_texts[] = $labels['new_item'];
                }
                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
                    $translation_texts[] = $labels['view_item'];
                }
                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
                    $translation_texts[] = $labels['search_items'];
                }
                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
                    $translation_texts[] = $labels['not_found'];
                }
                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
                    $translation_texts[] = $labels['not_found_in_trash'];
                }
                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
                    $translation_texts[] = $labels['label_post_profile'];
                }
                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
                    $translation_texts[] = $labels['label_post_info'];
                }
                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
                    $translation_texts[] = $labels['label_post_images'];
                }
                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
                    $translation_texts[] = $labels['label_post_map'];
                }
                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
                    $translation_texts[] = $labels['label_reviews'];
                }
                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
                    $translation_texts[] = $labels['label_related_listing'];
                }
            }
            if ($description != '' && !in_array($description, $translation_texts)) {
                $translation_texts[] = normalize_whitespace($description);
            }
            if (!empty($seo)) {
                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
                }
                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
                }
            }
        }
    }
    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
    return $translation_texts;
}
/**
 * Displays a human readable HTML representation of the difference between two strings.
 *
 * The Diff is available for getting the changes between versions. The output is
 * HTML, so the primary use is for displaying the changes. If the two strings
 * are equivalent, then an empty string will be returned.
 *
 * The arguments supported and can be changed are listed below.
 *
 * 'title' : Default is an empty string. Titles the diff in a manner compatible
 *		with the output.
 * 'title_left' : Default is an empty string. Change the HTML to the left of the
 *		title.
 * 'title_right' : Default is an empty string. Change the HTML to the right of
 *		the title.
 *
 * @since 2.6
 * @see wp_parse_args() Used to change defaults to user defined settings.
 * @uses Text_Diff
 * @uses WP_Text_Diff_Renderer_Table
 *
 * @param string $left_string "old" (left) version of string
 * @param string $right_string "new" (right) version of string
 * @param string|array $args Optional. Change 'title', 'title_left', and 'title_right' defaults.
 * @return string Empty string if strings are equivalent or HTML with differences.
 */
function wp_text_diff( $left_string, $right_string, $args = null ) {
	$defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
	$args = wp_parse_args( $args, $defaults );

	if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
		require( ABSPATH . WPINC . '/wp-diff.php' );

	$left_string  = normalize_whitespace($left_string);
	$right_string = normalize_whitespace($right_string);

	$left_lines  = split("\n", $left_string);
	$right_lines = split("\n", $right_string);

	$text_diff = new Text_Diff($left_lines, $right_lines);
	$renderer  = new WP_Text_Diff_Renderer_Table();
	$diff = $renderer->render($text_diff);

	if ( !$diff )
		return '';

	$r  = "<table class='diff'>\n";
	$r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";

	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
		$r .= "<thead>";
	if ( $args['title'] )
		$r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n";
	if ( $args['title_left'] || $args['title_right'] ) {
		$r .= "<tr class='diff-sub-title'>\n";
		$r .= "\t<td></td><th>$args[title_left]</th>\n";
		$r .= "\t<td></td><th>$args[title_right]</th>\n";
		$r .= "</tr>\n";
	}
	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
		$r .= "</thead>\n";

	$r .= "<tbody>\n$diff\n</tbody>\n";
	$r .= "</table>";

	return $r;
}
Example #18
0
/**
 * Replace multiple newlines, tabs, and spaces with a single space
 *
 * First, runs normalize_whitespace() on a string. This replaces multiple lines with a single line, and tabs with spaces.
 * We then strip any tabs or newlines and replace *those* with a single space.
 *
 * @see normalize_whitespace()
 * @see GravityView_Helper_Functions_Test::test_gravityview_strip_whitespace
 * @since 1.13
 *
 * @param string $string String to strip whitespace from
 *
 * @return string Stripped string!
 */
function gravityview_strip_whitespace($string)
{
    $string = normalize_whitespace($string);
    return preg_replace('/[\\r\\n\\t ]+/', ' ', $string);
}
Example #19
0
function doCreateTeam($login, $teamName, $editpassword, $editpassword2, $joinpassword, $joinpassword2, $blurb, $website)
{
    if (stristr($teamName, "'") != false || stristr($teamName, "\"") != false || stristr($teamName, "\\") != false) {
        return "Sorry, team names can not contain \\ or ' or \" in them.";
    }
    $teamName = strip_tags($teamName);
    $teamName = trim($teamName);
    $teamName = normalize_whitespace($teamName);
    $teamName = chop($teamName);
    $editpassword = stripslashes($editpassword);
    $editpassword2 = stripslashes($editpassword2);
    $joinpassword = stripslashes($joinpassword);
    $joinpassword2 = stripslashes($joinpassword2);
    $blurb = stripslashes($blurb);
    if (trim($teamName) == "" || trim($joinpassword) == "" || trim($editpassword) == "") {
        return "Missing required information";
    }
    if ($joinpassword != $joinpassword2) {
        return "Join passwords do not match";
    }
    if ($editpassword != $editpassword2) {
        return "Edit passwords do not match";
    }
    if (strlen($teamName) > 32) {
        return "Your team name is too long";
    }
    if (doesTeamExist($teamName) == true) {
        return "Team with this name already exists";
    }
    $pid = getPid($login);
    if ($pid == 0) {
        return "Unexpected error";
    }
    $website = trim($website);
    if (substr(strtolower($website), 0, 7) != "http://") {
        $website = "http://" . $website;
    }
    if ($website == "http://") {
        $website = "";
    }
    $sqlTeamName = mysql_escape_string($teamName);
    $joinpassword = mysql_escape_string($joinpassword);
    $editpassword = mysql_escape_string($editpassword);
    $blurb = mysql_escape_string($blurb);
    $website = mysql_escape_string($website);
    $regdate = date("M d, Y");
    $sql = "insert into stats_team (name, owner_password, join_password, owner, blurb, website, regdate, tourn_score, strict_score) values ('{$sqlTeamName}', '{$editpassword}', '{$joinpassword}', '{$pid}', '{$blurb}', '{$website}', '{$regdate}', 1600, 1600)";
    if (!mysql_query($sql)) {
        return "Database error";
    }
    $tid = getTid($teamName);
    $sql = "insert into team_members values ('{$tid}', '{$pid}')";
    if (!mysql_query($sql)) {
        return "Database Error 2";
    }
    $sql = "insert into view_team (id, view_count) values ({$tid}, 0)";
    if (!mysql_query($sql)) {
        return "Database error";
    }
    return "OK";
}
Example #20
0
 /**
  * Text diff. This is the same as wp_text_diff, the only
  * difference is we use a custom text diff render class.
  *
  * @param string the left file to compare
  * @param string the right file to compare
  * @return string Rendered table of diff files
  */
 public static function text_diff($left_string, $right_string, $args = null)
 {
     $defaults = array('title' => '', 'title_left' => '', 'title_right' => '');
     $args = wp_parse_args($args, $defaults);
     if (!class_exists('WP_Text_Diff_Renderer_Table')) {
         require_once ABSPATH . WPINC . '/wp-diff.php';
     }
     if (!class_exists('HMWP_MS_Text_Diff_Renderer_Table')) {
         require_once 'hmwp_ms/Text_Diff_Render.php';
     }
     $left_string = normalize_whitespace($left_string);
     $right_string = normalize_whitespace($right_string);
     $left_lines = split("\n", $left_string);
     $right_lines = split("\n", $right_string);
     $text_diff = new Text_Diff($left_lines, $right_lines);
     $renderer = new HMWP_MS_Text_Diff_Renderer_Table();
     $diff = $renderer->render($text_diff);
     if (!$diff) {
         return '';
     }
     $r = "<table class='diff'>\n";
     $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= '<thead>';
     }
     if ($args['title']) {
         $r .= "<tr class='diff-title'><th colspan='4'>{$args['title']}</th></tr>\n";
     }
     if ($args['title_left'] || $args['title_right']) {
         $r .= "<tr class='diff-sub-title'>\n";
         $r .= "\t<td></td><th>{$args['title_left']}</th>\n";
         $r .= "\t<td></td><th>{$args['title_right']}</th>\n";
         $r .= "</tr>\n";
     }
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= "</thead>\n";
     }
     $r .= "<tbody>\n{$diff}\n</tbody>\n";
     $r .= '</table>';
     return $r;
 }
Example #21
0
 /**
  * Normal wp_text_diff with three lines added as indicated
  * @access private
  * @version 3.4
  */
 function _wp_text_diff($left_string, $right_string, $args = null)
 {
     //fork edit: added parent arg
     $defaults = array('title' => '', 'title_left' => '', 'title_right' => '', 'fork' => false);
     $args = wp_parse_args($args, $defaults);
     if (!class_exists('WP_Text_Diff_Renderer_Table')) {
         require ABSPATH . WPINC . '/wp-diff.php';
     }
     //begin fork edit
     global $fork;
     if ($args['fork']) {
         global $fork;
         $parent = $fork->revisions->get_previous_revision($args['fork']);
         $left_lines = get_post($parent)->post_content;
     }
     //end edit
     $left_string = normalize_whitespace($left_string);
     $right_string = normalize_whitespace($right_string);
     $left_lines = explode("\n", $left_string);
     $right_lines = explode("\n", $right_string);
     $text_diff = new Text_Diff($left_lines, $right_lines);
     $renderer = new WP_Text_Diff_Renderer_Table();
     $diff = $renderer->render($text_diff);
     if (!$diff) {
         return '';
     }
     $r = "<table class='diff'>\n";
     $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= "<thead>";
     }
     if ($args['title']) {
         $r .= "<tr class='diff-title'><th colspan='4'>{$args['title']}</th></tr>\n";
     }
     if ($args['title_left'] || $args['title_right']) {
         $r .= "<tr class='diff-sub-title'>\n";
         $r .= "\t<td></td><th>{$args['title_left']}</th>\n";
         $r .= "\t<td></td><th>{$args['title_right']}</th>\n";
         $r .= "</tr>\n";
     }
     if ($args['title'] || $args['title_left'] || $args['title_right']) {
         $r .= "</thead>\n";
     }
     $r .= "<tbody>\n{$diff}\n</tbody>\n";
     $r .= "</table>";
     return $r;
 }
Example #22
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;
 }
 /**
  * Validate the normalize_whitespace function
  *
  * @dataProvider get_input_output
  */
 function test_normalize_whitespace($in_str, $exp_str)
 {
     $this->assertEquals($exp_str, normalize_whitespace($in_str));
 }
Example #24
0
/**
 * wp1_text_diff
 *
 * @param      $left_string
 * @param      $right_string
 * @param null $args
 *
 * @return string
 * @since rt-BIZ
 */
function rtbiz_text_diff($left_string, $right_string, $args = null)
{
    $defaults = array('title' => '', 'title_left' => '', 'title_right' => '');
    $args = wp_parse_args($args, $defaults);
    $left_string = normalize_whitespace($left_string);
    $right_string = normalize_whitespace($right_string);
    $left_lines = explode("\n", $left_string);
    $right_lines = explode("\n", $right_string);
    $renderer = new Rtbiz_Text_Diff();
    $text_diff = new Text_Diff($left_lines, $right_lines);
    $diff = $renderer->render($text_diff);
    if (!$diff) {
        return '';
    }
    $r = "<table class='diff' style='width: 100%;background: white;margin-bottom: 1.25em;border: solid 1px #dddddd;border-radius: 3px;margin: 0 0 18px;'>\n";
    $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
    if ($args['title'] || $args['title_left'] || $args['title_right']) {
        $r .= '<thead>';
    }
    if ($args['title']) {
        $r .= "<tr class='diff-title'><th colspan='4'>" . $args['title'] . '</th></tr>\\n';
    }
    if ($args['title_left'] || $args['title_right']) {
        $r .= "<tr class='diff-sub-title'>\n";
        $r .= "\t<td></td><th>{$args['title_left']}</th>\n";
        $r .= "\t<td></td><th>{$args['title_right']}</th>\n";
        $r .= "</tr>\n";
    }
    if ($args['title'] || $args['title_left'] || $args['title_right']) {
        $r .= "</thead>\n";
    }
    $r .= "<tbody>\n{$diff}\n</tbody>\n";
    $r .= '</table>';
    return $r;
}
Example #25
0
/**
 * Creates autosave data for the specified post from $_POST data.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 * @since 2.6.0
 *
 * @uses _wp_translate_postdata()
 * @uses _wp_post_revision_fields()
 *
 * @return unknown
 */
function wp_create_post_autosave($post_id)
{
    $translated = _wp_translate_postdata(true);
    if (is_wp_error($translated)) {
        return $translated;
    }
    $post_author = get_current_user_id();
    // Store one autosave per author. If there is already an autosave, overwrite it.
    if ($old_autosave = wp_get_post_autosave($post_id, $post_author)) {
        $new_autosave = _wp_post_revision_fields($_POST, true);
        $new_autosave['ID'] = $old_autosave->ID;
        $new_autosave['post_author'] = $post_author;
        // If the new autosave is the same content as the post, delete the old autosave.
        $post = get_post($post_id);
        $autosave_is_different = false;
        foreach (array_keys(_wp_post_revision_fields()) as $field) {
            if (normalize_whitespace($new_autosave[$field]) != normalize_whitespace($post->{$field})) {
                $autosave_is_different = true;
                break;
            }
        }
        if (!$autosave_is_different) {
            wp_delete_post_revision($old_autosave->ID);
            return;
        }
        return wp_update_post($new_autosave);
    }
    // _wp_put_post_revision() expects unescaped.
    $post_data = wp_unslash($_POST);
    // Otherwise create the new autosave as a special post revision
    return _wp_put_post_revision($post_data, true);
}
 public function meta_modal()
 {
     global $post, $post_type, $post_type_object, $current_screen, $wp_meta_modal_sections;
     $post_ID = $post->ID;
     set_current_screen($post_type);
     if (!wp_check_post_lock($post->ID)) {
         $active_post_lock = wp_set_post_lock($post->ID);
     }
     $messages = array();
     $messages['post'] = array(0 => '', 1 => sprintf(__('Post updated. <a href="%s">View post</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Post updated.'), 5 => isset($_GET['revision']) ? sprintf(__('Post restored to revision from %s', 'wplms-front-end'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Post published. <a href="%s">View post</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 7 => __('Post saved.'), 8 => sprintf(__('Post submitted. <a target="_blank" href="%s">Preview post</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('Post scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview post</a>', 'wplms-front-end'), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('Post draft updated. <a target="_blank" href="%s">Preview post</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))));
     $messages['page'] = array(0 => '', 1 => sprintf(__('Page updated. <a href="%s">View page</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Page updated.'), 5 => isset($_GET['revision']) ? sprintf(__('Page restored to revision from %s'), 'wplms-front-end', wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Page published. <a href="%s">View page</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 7 => __('Page saved.'), 8 => sprintf(__('Page submitted. <a target="_blank" href="%s">Preview page</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>', 'wplms-front-end'), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('Page draft updated. <a target="_blank" href="%s">Preview page</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))));
     $messages['attachment'] = array_fill(1, 10, __('Media attachment updated.', 'wplms-front-end'));
     // Hack, for now.
     $messages = apply_filters('post_updated_messages', $messages);
     $message = false;
     if (isset($_GET['message'])) {
         $_GET['message'] = absint($_GET['message']);
         if (isset($messages[$post_type][$_GET['message']])) {
             $message = $messages[$post_type][$_GET['message']];
         } elseif (!isset($messages[$post_type]) && isset($messages['post'][$_GET['message']])) {
             $message = $messages['post'][$_GET['message']];
         }
     }
     $notice = false;
     $form_extra = '';
     if ('auto-draft' == $post->post_status) {
         if ('edit' == $action) {
             $post->post_title = '';
         }
         $autosave = false;
         $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
     } else {
         $autosave = wp_get_post_autosave($post_ID);
     }
     $form_action = 'editpost';
     $nonce_action = 'update-post_' . $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, false) > mysql2date('U', $post->post_modified_gmt, false)) {
         foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
             if (normalize_whitespace($autosave->{$autosave_field}) != normalize_whitespace($post->{$autosave_field})) {
                 $notice = sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>', 'wplms-front-end'), get_edit_post_link($autosave->ID));
                 break;
             }
         }
         // If this autosave isn't different from the current post, begone.
         if (!$notice) {
             wp_delete_post_revision($autosave->ID);
         }
         unset($autosave_field, $_autosave_field);
     }
     $post_type_object = get_post_type_object($post_type);
     $this->add_meta_modal_section('submitdiv', __('Publish'), array($this, 'meta_section_publish'), 10, 10);
     if (post_type_supports($post_type, 'revisions') && 'auto-draft' !== $post->post_status) {
         $revisions = wp_get_post_revisions($post->ID);
         $count = count($revisions);
         if ($count > 1) {
             $this->add_meta_modal_section('revisionsdiv', __('Revisions', 'wplms-front-end') . ' (' . $count . ')', 'post_revisions_meta_box', 30, 50);
         }
     }
     if (current_theme_supports('post-formats') && post_type_supports($post_type, 'post-formats')) {
         $this->add_meta_modal_section('formatdiv', _x('Format', 'post format', 'wplms-front-end'), 'post_format_meta_box', 20, 10);
     }
     foreach (get_object_taxonomies($post) as $tax_name) {
         $taxonomy = get_taxonomy($tax_name);
         if (!$taxonomy->show_ui || false === $taxonomy->meta_box_cb) {
             continue;
         }
         $label = $taxonomy->labels->name;
         if (!is_taxonomy_hierarchical($tax_name)) {
             $tax_meta_box_id = 'tagsdiv-' . $tax_name;
         } else {
             $tax_meta_box_id = $tax_name . 'div';
         }
         $this->add_meta_modal_section($tax_meta_box_id, $label, $taxonomy->meta_box_cb, 20, 20, array('taxonomy' => $tax_name));
     }
     if (post_type_supports($post_type, 'page-attributes')) {
         $this->add_meta_modal_section('pageparentdiv', 'page' == $post_type ? __('Page Attributes', 'wplms-front-end') : __('Attributes', 'wplms-front-end'), 'page_attributes_meta_box', 10, 10);
     }
     if (post_type_supports($post_type, 'excerpt')) {
         $this->add_meta_modal_section('postexcerpt', __('Excerpt', 'wplms-front-end'), 'post_excerpt_meta_box', 30, 10);
     }
     if (post_type_supports($post_type, 'trackbacks')) {
         $this->add_meta_modal_section('trackbacksdiv', __('Send Trackbacks', 'wplms-front-end'), 'post_trackback_meta_box', 30, 20);
     }
     if (post_type_supports($post_type, 'custom-fields')) {
         $this->add_meta_modal_section('postcustom', __('Custom Fields', 'wplms-front-end'), 'post_custom_meta_box', 30, 30);
     }
     if (post_type_supports($post_type, 'comments')) {
         $this->add_meta_modal_section('commentstatusdiv', __('Discussion', 'wplms-front-end'), 'post_comment_status_meta_box', 30, 40);
     }
     require_once 'meta-modal-template.php';
     unset($GLOBALS['current_screen']);
 }
/**
 * Creates a revision for the current version of a post.
 *
 * Typically used immediately after a post update, as every update is a revision,
 * and the most recent revision always matches the current post.
 *
 * @since 2.6.0
 *
 * @param int $post_id The ID of the post to save as a revision.
 * @return int|WP_Error|void Void or 0 if error, new revision ID, if success.
 */
function wp_save_post_revision($post_id)
{
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (!($post = get_post($post_id))) {
        return;
    }
    if (!post_type_supports($post->post_type, 'revisions')) {
        return;
    }
    if ('auto-draft' == $post->post_status) {
        return;
    }
    if (!wp_revisions_enabled($post)) {
        return;
    }
    // Compare the proposed update with the last stored revision verifying that
    // they are different, unless a plugin tells us to always save regardless.
    // If no previous revisions, save one
    if ($revisions = wp_get_post_revisions($post_id)) {
        // grab the last revision, but not an autosave
        foreach ($revisions as $revision) {
            if (false !== strpos($revision->post_name, "{$revision->post_parent}-revision")) {
                $last_revision = $revision;
                break;
            }
        }
        /**
         * Filter whether the post has changed since the last revision.
         *
         * By default a revision is saved only if one of the revisioned fields has changed.
         * This filter can override that so a revision is saved even if nothing has changed.
         *
         * @since 3.6.0
         *
         * @param bool    $check_for_changes Whether to check for changes before saving a new revision.
         *                                   Default true.
         * @param WP_Post $last_revision     The the last revision post object.
         * @param WP_Post $post              The post object.
         *
         */
        if (isset($last_revision) && apply_filters('wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post)) {
            $post_has_changed = false;
            foreach (array_keys(_wp_post_revision_fields()) as $field) {
                if (normalize_whitespace($post->{$field}) != normalize_whitespace($last_revision->{$field})) {
                    $post_has_changed = true;
                    break;
                }
            }
            /**
             * Filter whether a post has changed.
             *
             * By default a revision is saved only if one of the revisioned fields has changed.
             * This filter allows for additional checks to determine if there were changes.
             *
             * @since 4.1.0
             *
             * @param bool    $post_has_changed Whether the post has changed.
             * @param WP_Post $last_revision    The last revision post object.
             * @param WP_Post $post             The post object.
             *
             */
            $post_has_changed = (bool) apply_filters('wp_save_post_revision_post_has_changed', $post_has_changed, $last_revision, $post);
            //don't save revision if post unchanged
            if (!$post_has_changed) {
                return;
            }
        }
    }
    $return = _wp_put_post_revision($post);
    // If a limit for the number of revisions to keep has been set,
    // delete the oldest ones.
    $revisions_to_keep = wp_revisions_to_keep($post);
    if ($revisions_to_keep < 0) {
        return $return;
    }
    $revisions = wp_get_post_revisions($post_id, array('order' => 'ASC'));
    $delete = count($revisions) - $revisions_to_keep;
    if ($delete < 1) {
        return $return;
    }
    $revisions = array_slice($revisions, 0, $delete);
    for ($i = 0; isset($revisions[$i]); $i++) {
        if (false !== strpos($revisions[$i]->post_name, 'autosave')) {
            continue;
        }
        wp_delete_post_revision($revisions[$i]->ID);
    }
    return $return;
}
 /**
  * Generate HTML output for a single note
  *
  * @since 1.17
  *
  * @param object $note Note object with id, user_id, date_created, value, note_type, user_name, user_email vars
  * @param bool $show_delete Whether to show the bulk delete inputs
  *
  * @return string HTML
  */
 public static function display_note($note, $show_delete = false)
 {
     if (!is_object($note)) {
         return '';
     }
     $note_content = array('avatar' => get_avatar($note->user_id, 48), 'user_name' => $note->user_name, 'user_email' => $note->user_email, 'added_on' => esc_html__('added on {date_created_formatted}', 'gravityview'), 'value' => wpautop(esc_html($note->value)), 'date_created' => $note->date_created, 'date_created_formatted' => GFCommon::format_date($note->date_created, false), 'user_id' => intval($note->user_id), 'note_type' => $note->note_type, 'note_id' => intval($note->id));
     /**
      * @filter `gravityview/field/notes/content` Modify the note content before rendering in the template
      * @since 1.17
      * @param array $note_content Array of note content that will be replaced in template files
      * @param object $note Note object with id, user_id, date_created, value, note_type, user_name, user_email vars
      * @param boolean $show_delete True: Notes are editable. False: no editing notes.
      */
     $note_content = apply_filters('gravityview/field/notes/content', $note_content, $note, $show_delete);
     ob_start();
     GravityView_View::getInstance()->get_template_part('note', 'detail');
     $note_detail_html = ob_get_clean();
     foreach ($note_content as $tag => $value) {
         $note_detail_html = str_replace('{' . $tag . '}', $value, $note_detail_html);
     }
     $note_row_template = $show_delete && GVCommon::has_cap('gravityview_delete_entry_notes') ? 'row-editable' : 'row';
     ob_start();
     GravityView_View::getInstance()->get_template_part('note', $note_row_template);
     $note_row = ob_get_clean();
     $replacements = array('{note_id}' => $note_content['note_id'], '{row_class}' => 'gv-note', '{note_detail}' => $note_detail_html);
     // Strip extra whitespace in template
     $output = normalize_whitespace($note_row);
     foreach ($replacements as $tag => $replacement) {
         $output = str_replace($tag, $replacement, $output);
     }
     return $output;
 }
Example #29
0
 /**
  * create a autosave revision with this content
  *
  * @param $pid
  * @param $content
  */
 public function update_autosave_version($pid, $content)
 {
     $post = get_post($pid);
     // only when something has changed
     if ($post && normalize_whitespace($post->post_content) != normalize_whitespace($content)) {
         $post->post_content = $content;
         $post = $post->to_array();
         $post['post_ID'] = $pid;
         wp_create_post_autosave($post);
     }
 }
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 
}