/** * This was built by MHA by reference. No time to fix just yet, but it works. * @param string $output referenced output variable * @param string $state referenced request stated * @param string $optional referenced optional information */ public static function getOffer(&$output, &$state, &$optional) { $optional['requestCounter'] = $_POST['requestCounter']; // Call the API for prices $options = self::getTranslationOptions(); $library = Core::getInstance()->getLibrary(); $data = $library->getTranslationData($options['post_id'], $options['pattern']); $wrapper = $library->getUserWrapper(); // Call for prices $pricing = $wrapper->getQuote($options['source_lang'], $options['target_lang'], $data); //Check if there are no offers if (empty($pricing['options'])) { $output = __('There are no offers for this translation.', ' polylang-supertext'); $state = 'no_data'; return; } // generate html output $rows = ''; $checked = 'checked="checked"'; foreach ($pricing['options'] as $option) { $itemsCount = count($option['items']); $rows .= '<tr class="firstGroupRow"> <td class="qualityGroupCell" rowspan="' . ($itemsCount + 1) . '"><strong>' . $option['name'] . '</strong></td> <td class="selectionCell"> </td> <td> </td> <td> </td> <td> </td> </tr>'; foreach ($option['items'] as $groupRowNumber => $item) { $radioInputId = $option['id'] . "_" . $item['id']; $radioInputValue = $option['id'] . ":" . $item['id']; $rows .= ' <tr> <td class="selectionCell"> <input type="radio" data-currency="' . $pricing['currency'] . '" name="rad_translation_type" id="rad_translation_type_' . $radioInputId . '" value="' . $radioInputValue . '" ' . $checked . '> </td> <td> <label for="rad_translation_type_' . $radioInputId . '">' . $item['name'] . '</label> </td> <td align="right" class="ti_deadline"> <label for="rad_translation_type_' . $radioInputId . '">' . date_i18n('D, d. F H:i', strtotime($item['date'])) . '</label> </td> <td align="right" class="ti_price"> <label for="rad_translation_type_' . $radioInputId . '">' . $pricing['currency'] . ' ' . String::numberFormat($item['price'], 2) . '</label> </td> </tr> '; $checked = ''; } $rows .= '<tr class="lastGroupRow"></tr>'; } $output .= '<table border="0" cellpadding="2" cellspacing="0"> <thead> <tr> <td> </td> <td class="selectionCell"> </td> <td><strong>' . __('Duration', 'polylang-supertext') . '</strong></td> <td align="right"><strong>' . __('Translation until', 'polylang-supertext') . '</strong></td> <td align="right"><strong>' . __('Price', 'polylang-supertext') . '</strong></td> </tr> </thead> <tbody> ' . $rows . ' </tbody> </table>'; $state = 'success'; }
/** * Inline callback to display an editor * @param array $args the arguments to display the input textfield * @return string HTML code to display the field */ public function displayEditor($args) { $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']; } // Replace in the input field $input = String::getWpEditor($value, $key, array('textarea_rows' => $args['rows'])); $html = str_replace('{input}', $input, $html); return $html; }