Ejemplo n.º 1
0
    /**
     * Render the release view.
     */
    public function render()
    {
        if (!$this->release) {
            return;
        }
        $df = str_replace('F', 'M', get_option('date_format'));
        $tf = get_option('time_format');
        $dtf = "{$df} {$tf}";
        if ($this->release->get_status() == Release::STATUS_DRAFT) {
            $click_edit = ' title="' . __("Click to Edit", Plugin::SLUG) . '"';
        } else {
            $click_edit = '';
        }
        ?>

		<div id="release-details">
			<div class="spacing-wrapper bottom-border header-block">

				<div class="status status-<?php 
        echo esc_attr($this->release->get_status());
        ?>
">
					<span data-value="<?php 
        echo esc_attr($this->release->get_status());
        ?>
"<?php 
        echo $click_edit;
        ?>
>
						<?php 
        echo $this->release->get_status(true);
        ?>
					</span>
				</div>

				<div class="name-block">
					<h2 class="product-name"><?php 
        echo $this->release->get_product()->post_title;
        ?>
</h2>

					<h2 class="version-name"><?php 
        echo $this->release->get_version();
        ?>
</h2>
				</div>
			</div>

			<div class="spacing-wrapper bottom-border third-row misc-block">
				<div class="third type">
					<h4><?php 
        _e("Type", Plugin::SLUG);
        ?>
</h4>

					<h3 data-value="<?php 
        echo $this->release->get_type();
        ?>
"<?php 
        echo $click_edit;
        ?>
>
						<?php 
        echo $this->release->get_type(true);
        ?>
					</h3>
				</div>
				<div class="third release-date">
					<h4><?php 
        _e("Released", Plugin::SLUG);
        ?>
</h4>

					<h3>
						<?php 
        if (null === $this->release->get_start_date()) {
            ?>
							<?php 
            echo '&mdash;';
            ?>
						<?php 
        } else {
            ?>
							<?php 
            echo \ITELIC\convert_gmt_to_local($this->release->get_start_date())->format($df);
            ?>
						<?php 
        }
        ?>
					</h3>
				</div>
				<div class="third version">
					<h4><?php 
        _e("Version", Plugin::SLUG);
        ?>
</h4>

					<h3 data-value="<?php 
        echo $this->release->get_version();
        ?>
"<?php 
        echo $click_edit;
        ?>
>
						<?php 
        echo $this->release->get_version();
        ?>
					</h3>
				</div>
			</div>

			<?php 
        if (get_post_meta($this->release->get_product()->ID, '_itelic_first_release', true) == $this->release->get_pk()) {
            ?>

				<div class="spacing-wrapper">
					<p class="initial-release-notice">
						<?php 
            printf(__("Congratulations on releasing %s; there isn't any data to display for your first release, though.", Plugin::SLUG), $this->release->get_product()->post_title);
            ?>
					</p>
				</div>

				</div>

				<?php 
            return;
            ?>
			<?php 
        }
        ?>

			<?php 
        if ($this->release->get_status() == Release::STATUS_DRAFT) {
            ?>

				<?php 
            $this->render_replace_file_section();
            ?>

			<?php 
        }
        ?>

			<?php 
        $this->render_security_message();
        $this->render_upgrades_bar();
        $this->render_whats_changed();
        if ($this->release->get_status() != Release::STATUS_ARCHIVED) {
            $this->render_notification_editor();
        }
        $this->render_progress_line_chart();
        $this->render_versions_pie_chart();
        $this->render_notify_button_section();
        ?>
		</div>

		<?php 
        /**
         * Fires after the main single release screen.
         *
         * @since 1.0
         *
         * @param Release $release
         */
        do_action('itelic_single_release_screen_after', $this->release);
    }
 /**
  * Set the current version installed on this location.
  *
  * @since 1.0
  *
  * @param Release $release
  */
 public function set_release(Release $release)
 {
     $this->release = $release;
     $this->update('release_id', $this->release->get_pk());
 }
Ejemplo n.º 3
0
 /**
  * Update a release's property.
  *
  * @since 1.0
  *
  * @param Release $release
  * @param string  $prop
  * @param string  $val
  * @param string  $nonce
  *
  * @return Release
  */
 public function do_update(Release $release, $prop, $val, $nonce)
 {
     if (!wp_verify_nonce($nonce, "itelic-update-release-{$release->get_pk()}")) {
         throw new \InvalidArgumentException(__("Sorry, this page has expired. Please refresh and try again.", Plugin::SLUG));
     }
     if (!current_user_can('manage_options')) {
         throw new \InvalidArgumentException(__("Sorry, you don't have permission to do this.", Plugin::SLUG));
     }
     switch ($prop) {
         case 'status':
             $release->set_status($val);
             break;
         case 'type':
             $release->set_type($val);
             break;
         case 'version':
             $release->set_version(sanitize_text_field($val));
             break;
         case 'download':
             $release->set_download(intval($val));
             break;
         case 'changelog':
             $val = stripslashes($val);
             if (!current_user_can('unfiltered_html')) {
                 $val = wp_kses($val, wp_kses_allowed_html());
             }
             $release->set_changelog($val);
             break;
         case 'security-message':
             $val = stripslashes($val);
             if (!current_user_can('unfiltered_html')) {
                 $val = wp_kses($val, wp_kses_allowed_html());
             }
             $release->update_meta('security-message', $val);
             break;
         default:
             throw new \InvalidArgumentException("Invalid prop.");
     }
     return $release;
 }