/** * Outputs a deactivation link. * * @since 1.0 * * @param array $options * * @return string */ public function deactivate_link($options = array()) { $defaults = array('format' => 'html', 'label' => __('Deactivate', ITELIC\Plugin::SLUG), 'working' => __("Deactivating", ITELIC\Plugin::SLUG)); if (!$this->activation) { return ''; } $options = ITUtility::merge_defaults($options, $defaults); $label = $options['label']; $id = $this->activation->get_id(); $nonce = wp_create_nonce("itelic-deactivate-{$id}"); $working = $options['working']; $link = "<a href=\"javascript:\" class=\"deactivate-location\" data-id=\"{$id}\" data-nonce=\"{$nonce}\" data-working=\"{$working}\">"; $link .= $label; $link .= "</a>"; return $link; }
/** * Create an Upgrade record. * * @since 1.0 * * @param Activation $activation * @param Release $release * @param \DateTime $update_date * @param string $previous_version * * @return Update|null * @throws DB_Exception */ public static function create(Activation $activation, Release $release, \DateTime $update_date = null, $previous_version = '') { if ($update_date === null) { $update_date = make_date_time(); } if (empty($previous_version) && $activation->get_release()) { $previous_version = $activation->get_release()->get_version(); } $data = array('activation' => $activation->get_id(), 'release_id' => $release->get_ID(), 'update_date' => $update_date->format("Y-m-d H:i:s"), 'previous_version' => $previous_version); $db = Manager::make_simple_query_object('itelic-updates'); $ID = $db->insert($data); $update = self::get($ID); if ($update) { $activation->set_release($release); /** * Fires when an update record is created. * * @since 1.0 * * @param Update $update */ do_action('itelic_create_update', $update); Cache::add($update); } return $update; }
/** * Get the activation row HTML. * * @since 1.0 * * @param Activation $activation * * @return string */ public function get_activation_row_html(Activation $activation) { $n_deactivate = wp_create_nonce('itelic-remote-deactivate-' . $activation->get_id()); $n_delete = wp_create_nonce('itelic-remote-delete-' . $activation->get_id()); ob_start(); ?> <tr> <td data-title="<?php _e("Location", Plugin::SLUG); ?> "> <?php echo $activation->get_location(); ?> </td> <td data-title="<?php _e("Status", Plugin::SLUG); ?> "> <?php echo $activation->get_status(true); ?> </td> <td data-title="<?php _e("Activation", Plugin::SLUG); ?> "> <?php echo \ITELIC\convert_gmt_to_local($activation->get_activation())->format($this->get_short_df()); ?> </td> <td data-title="<?php _e("Deactivation", Plugin::SLUG); ?> "> <?php if (null === ($d = $activation->get_deactivation())) { ?> <a href="javascript:" data-id="<?php echo esc_attr($activation->get_id()); ?> " data-nonce="<?php echo $n_deactivate; ?> " class="deactivate"> <?php _e("Deactivate", Plugin::SLUG); ?> </a> <?php } else { ?> <?php echo \ITELIC\convert_gmt_to_local($d)->format($this->get_short_df()); ?> <?php } ?> </td> <td data-title="<?php _e("Version", Plugin::SLUG); ?> "> <?php if (null === ($r = $activation->get_release())) { ?> <?php _e("Unknown", Plugin::SLUG); ?> <?php } else { ?> <?php printf('v%s', $r->get_version()); ?> <?php } ?> </td> <td data-title="<?php _e("Delete", Plugin::SLUG); ?> "> <button data-id="<?php echo esc_attr($activation->get_id()); ?> " class="remove-item" data-nonce="<?php echo $n_delete; ?> "> × </button> </td> </tr> <?php return ob_get_clean(); }
/** * Get data to display for a single key. * * @param \ITELIC\Activation $activation * @param bool $raw * * @return array */ protected function get_fields_for_object(\ITELIC\Activation $activation, $raw = false) { if ($activation->get_deactivation()) { $deactivated = $activation->get_deactivation()->format(DateTime::ISO8601); } else { $deactivated = '-'; } return array('id' => $activation->get_id(), 'key' => $activation->get_key()->get_key(), 'location' => $activation->get_location(), 'status' => $activation->get_status(!$raw), 'activated' => $activation->get_activation()->format(DateTime::ISO8601), 'deactivated' => $deactivated, 'version' => $activation->get_release() ? $activation->get_release()->get_version() : 'Unknown', 'track' => $activation->get_meta('track', true) ? $activation->get_meta('track', true) : 'stable'); }