/**
  * Show supertext log information, if there are entries for the current post
  */
 public function addLogInfoMetabox()
 {
     $postId = intval($_GET['post']);
     $logEntries = Core::getInstance()->getLog()->getLogEntries($postId);
     // Show info if valid post and there are entries
     if ($postId > 0 && count($logEntries) > 0) {
         // Reverse entries, so that the newest is on top
         $logEntries = array_reverse($logEntries);
         // Create an html element to display the entries
         $html = '';
         foreach ($logEntries as $entry) {
             $datetime = '
       ' . Date::getTime(Date::EU_DATE, $entry['datetime']) . ',
       ' . Date::getTime(Date::EU_TIME, $entry['datetime']) . '
     ';
             $html .= '<p><strong>' . $datetime . '</strong>: ' . $entry['message'] . '</p>';
         }
         $helper = Metabox::get('post');
         // Add a new metabox to show log entries
         $helper->addMetabox(Log::META_LOG, __('Supertext Plugin Log', 'polylang-supertext'), 'side', 'low');
         $helper->addHtml('info', Log::META_LOG, $html);
     }
 }
예제 #2
0
 /**
  * Inline callback to display a date textfield with jquery date selector
  * @param array $args the arguments to display the input textfield
  * @return string HTML code to display the field
  */
 public function displayDateField($args)
 {
     // Make sure to load the jquery datepicker
     wp_enqueue_style('jquery-ui-datepicker-css', get_bloginfo('wpurl') . '/wp-content/plugins/blogwerk/css/ui.datepicker.css', array(), '1.0');
     wp_enqueue_script('jquery-ui-datepicker', get_bloginfo('wpurl') . '/wp-content/plugins/blogwerk/js/ui.datepicker.js', array('jquery', 'jquery-ui-core'));
     $key = $args['post']->ID . '_' . $args['key'];
     $html = $this->getTemplate($args, $key);
     // Get the current value
     $value = get_post_meta($args['post']->ID, $args['key'], true);
     if (strlen($value) == 0 && isset($args['default'])) {
         $value = $args['default'];
     }
     $attr = '';
     if (isset($args['required']) && $args['required']) {
         $attr .= ' required="required"';
     }
     // Convert the configured format to the display format EU_DATE
     if (strlen($value) > 0) {
         $value = Date::convert_date($args['format'], Date::EU_DATE, $value);
     }
     // Replace in the input field and add the js to use a picker
     $input = '
   <input type="text" id="' . $key . '" name="' . $key . '" class="mbh-datefield" value="' . esc_attr($value) . '"' . $attr . ' />
   <script type="text/javascript">
     jQuery(function() {
       jQuery("#' . $key . '").datepicker({
         dateFormat : "dd.mm.yy",
         dayNames : ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
         dayNamesMin : ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
         dayNamesShort : ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
         monthNames : ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
         monthNamesShort : ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
         firstDay : 1
       });
     });
   </script>
 ';
     $html = str_replace('{input}', $input, $html);
     return $html;
 }