Plugin Directory

Changeset 2681832


Ignore:
Timestamp:
02/19/2022 07:44:32 PM (4 years ago)
Author:
codents
Message:

Adds last edition

Location:
custom-help/trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • custom-help/trunk/assets/css/custom-help-admin.css

    r2681551 r2681832  
    8080  display: inline-block;
    8181  background-color: #00afa4;
    82   border-color: #00afa4;
     82  border: 1px solid rgba(0, 0, 0, .25);
    8383  color: #fff;
    8484  text-decoration: none;
     
    9595  display: block;
    9696}
     97#custom-help-content-last-edition {
     98  margin-top: 1rem;
     99  font-size: .75rem;
     100  opacity: .5;
     101  font-style: italic;
     102}
     103#custom-help-content-last-edition[data-hidden="true"] {
     104  display: none;
     105}
     106#custom-help-content-last-edition > span {
     107  font-weight: bold;
     108}
  • custom-help/trunk/assets/scripts/custom-help-admin.js

    r2681551 r2681832  
    5555    document.querySelector('#custom-help-content').innerHTML = response.data.content;
    5656    document.querySelector('#custom-help-form [name="id"]').value = response.data.id;
     57    document.querySelector('#custom-help-content-last-edition').setAttribute('data-hidden', 'false');
     58    document.querySelector('#custom-help-content-last-edition span:first-of-type').innerHTML = response.data.editor;
     59    document.querySelector('#custom-help-content-last-edition span:last-of-type').innerHTML = response.data.date_updated;
    5760  }).catch((error) => {
    5861    document.querySelector('#custom-help-form').setAttribute('data-loading', 'false');
  • custom-help/trunk/includes/class-custom-help-admin.php

    r2681551 r2681832  
    1616
    1717        public function enqueue_scripts() {
    18             wp_register_script($this->name, plugin_dir_url(__FILE__) . '../assets/scripts/custom-help-admin.js', array(), $this->version, false);
     18            wp_register_script($this->name, plugin_dir_url(__FILE__) . '../assets/scripts/custom-help-admin.min.js', array(), $this->version, false);
    1919            wp_localize_script($this->name, $this->short_term, array(
    2020                'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php',
     
    2525
    2626        public function enqueue_styles() {
    27             wp_enqueue_style($this->name, plugin_dir_url(__FILE__) . '../assets/css/custom-help-admin.css', array(), $this->version, 'all');
     27            wp_enqueue_style($this->name, plugin_dir_url(__FILE__) . '../assets/css/custom-help-admin.min.css', array(), $this->version, 'all');
    2828        }
    2929
     
    3636                $content = $documentation['content'];
    3737                $content_parsed = $this->format_content($documentation['content'], $is_markdown);
    38                 $date_created = $documentation['date_created'];
    3938                $date_updated = $documentation['date_updated'];
    40                 $author = $documentation['author'];
    41                 $editor = $documentation['editor'];
     39                $editor = get_user_by('id', $documentation['editor'])
     40                    ? get_user_by('id', $documentation['editor'])->display_name : '';
    4241            }
    4342            ob_start();
     
    5251                'CONTENT' => isset($content) ? $content : '',
    5352                'CONTENT_PARSED' => isset($content_parsed) ? $content_parsed : '',
    54                 'DATE_CREATED' => isset($date_created) ? $date_created : '',
    55                 'DATE_UPDATED' => isset($date_updated) ? $date_updated : '',
    56                 'AUTHOR' => isset($author) ? $author : '',
    57                 'EDITOR' => isset($editor) ? $editor : '',
     53                'LAST_EDITION' => sprintf(
     54                    __('Last edition by <span>%s</span> at <span>%s</span>.', $this->slug),
     55                    isset($editor) ? $editor : '',
     56                    isset($date_updated) ? $date_updated : '',
     57                ),
     58                'HIDE_LAST_EDITION' => !isset($id) || !$id ? 'true' : 'false',
    5859                'DOCUMENTATION_NOT_FOUND' => __('No documentation found related to this page.', $this->slug),
    5960                'DOCUMENTATION_EMPTY' => __('Documentation found is empty.', $this->slug),
     
    126127            $id = isset($_POST['id']) ? sanitize_text_field($_POST['id']) : null;
    127128            $is_markdown = isset($_POST['is_markdown']) && $_POST['is_markdown'] === 'true';
    128             $content = isset($_POST['content']) ? wp_kses_post($_POST['content']) : '';
     129            $content = isset($_POST['content']) ? stripslashes($_POST['content']) : '';
    129130            $params = array(
    130131                'is_markdown' => $is_markdown,
     
    149150                wp_send_json_success(array(
    150151                    'content' => $this->format_content($content, $is_markdown),
    151                     'id' => $id ? $id : $wpdb->insert_id
     152                    'id' => $id ? $id : $wpdb->insert_id,
     153                    'date_updated' => current_time('mysql'),
     154                    'editor' => wp_get_current_user()->display_name
    152155                ));
    153156            } else {
  • custom-help/trunk/templates/help_tab_content.php

    r2681551 r2681832  
    6262      <?php } ?>
    6363    </div>
     64    <div id="custom-help-content-last-edition" data-hidden="<?php echo esc_attr($template_vars['HIDE_LAST_EDITION']); ?>">
     65      <?php echo wp_kses_post($template_vars['LAST_EDITION']); ?>
     66    </div>
    6467  </div>
    6568</div>
Note: See TracChangeset for help on using the changeset viewer.