function backfill_attachment_urls()
 {
     global $wpdb;
     // TFUSE: mai intii procesam optiunile din framework
     $this->tfuse_process_options();
     $rows = $wpdb->get_results($wpdb->prepare("SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key='%s'", TF_THEME_PREFIX . '_tfuse_post_options'));
     foreach ($rows as $row) {
         $new_val = tfuse_unpk($row->meta_value);
         if ($new_val === false) {
             $new_val = $row->meta_value;
         }
         if (is_array($new_val)) {
             array_walk_recursive($new_val, array($this, 'tfuse_change_link'));
         }
         tf_update_post_meta($row->post_id, TF_THEME_PREFIX . '_tfuse_post_options', $new_val);
         $this->tfuse_post_options[$row->post_id] = $new_val;
     }
     $this->url_remap[$this->base_url] = network_home_url();
     // make sure we do the longest urls first, in case one is a substring of another
     uksort($this->url_remap, array($this, 'cmpr_strlen'));
     // append this to the end of array to be executed last (after 'cmpr_strlen' that changes the order)
     if ($this->wrong_replace) {
         $this->url_remap[$this->wrong_replace] = network_home_url();
     }
     foreach ($this->url_remap as $from_url => $to_url) {
         // remap urls in post_content
         $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url));
         // remap enclosure urls
         $result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url));
     }
 }
Ejemplo n.º 2
0
 function reservation_details()
 {
     $resId = $this->request->GET('id');
     $this->redirect_if_reservation_id_invalid($resId);
     $this->common_html();
     $inputs = $this->get->ext_config('RESERVATIONFORM', 'base');
     $inputs = $inputs['input_types'];
     $post = get_post($resId);
     $the_post = tfuse_unpk($post->post_content);
     $the_form = wp_get_post_terms($resId, 'reservations');
     if (count($the_form) == 0) {
         $the_form = $the_post['form'];
     } else {
         $the_form = unserialize($the_form[0]->description);
     }
     $post_statuses = array('publish' => __('Approved', 'tfuse'), 'draft' => 'Rejected', 'private' => __('Pending', 'tfuse'));
     $options = array('tabs' => array(array('name' => apply_filters('res_details_name', __('Reservation Details', 'tfuse')), 'id' => TF_THEME_PREFIX . 'res_details', 'headings' => array(array('name' => __('Details', 'tfuse'), 'id' => 'res_details', 'options' => array(array('name' => __('Status', 'tfuse'), 'type' => 'raw', 'id' => '', 'html' => '<div class="rf_post_status_' . $post->post_status . '">' . $post_statuses[$post->post_status] . '</div>', 'value' => '', 'divider' => true)))))));
     foreach ($the_form['input'] as $key => $input) {
         if (!isset($the_post[TF_THEME_PREFIX . '_' . $input['shortcode']])) {
             $the_post[TF_THEME_PREFIX . '_' . $input['shortcode']] = '-';
         }
         if ($input['type'] == 'res_email') {
             $html = '<a  class="res_mailto" href="mailto:' . urldecode($the_post[TF_THEME_PREFIX . '_' . $input['shortcode']]) . '">' . urldecode($the_post[TF_THEME_PREFIX . '_' . $input['shortcode']]) . '</a>';
         } else {
             $html = !in_array($input['type'], array('date_in', 'date_out')) && $inputs[$input['type']]['name'] == 'Email' ? '<a  class="res_mailto" href="mailto:' . urldecode($the_post[TF_THEME_PREFIX . '_' . $input['shortcode']]) . '">' . urldecode($the_post[TF_THEME_PREFIX . '_' . $input['shortcode']]) . '</a>' : urldecode($the_post[TF_THEME_PREFIX . '_' . $input['shortcode']]);
         }
         $option = array();
         $option['name'] = apply_filters('res_input_name_' . TF_THEME_PREFIX . '_' . $input['shortcode'], __(urldecode($input['label']), 'tfuse'));
         $option['desc'] = '';
         $option['id'] = TF_THEME_PREFIX . '_' . $input['shortcode'];
         $option['type'] = 'raw';
         $option['html'] = '<div class="res_det_messages">' . (in_array($input['type'], array('date_in', 'date_out')) ? date_i18n(get_option('date_format'), strtotime($the_post[TF_THEME_PREFIX . '_' . $input['shortcode']])) : urldecode($html)) . '</div>';
         $option['value'] = '';
         end($the_form['input']);
         $k = key($the_form['input']);
         if ($k == $key) {
             $option['divider'] = true;
         }
         $options['tabs'][0]['headings'][0]['options'][] = $option;
     }
     if (isset($the_post['sent_messages'])) {
         foreach ($the_post['sent_messages'] as $sent_message) {
             $option = array();
             $option['name'] = date_i18n(get_option('date_format'), strtotime($sent_message['date']));
             $option['desc'] = __('Message sent by you to the user that made the reservation', 'tfuse');
             $option['id'] = '';
             $option['type'] = 'raw';
             $option['html'] = '<div class="res_det_messages">' . urldecode($sent_message['message']) . '</div>';
             $option['value'] = '';
             $options['tabs'][0]['headings'][0]['options'][] = $option;
         }
     }
     $mess_option = array('name' => __('Message', 'tfuse'), 'desc' => __('This message will overwrite the message template from form settings', 'tfuse'), 'id' => TF_THEME_PREFIX . '_email_message', 'type' => 'textarea', 'value' => '');
     $options['tabs'][0]['headings'][0]['options'][] = $mess_option;
     foreach ($options['tabs'] as $tab) {
         $headings = $tab['headings'];
         unset($tab['headings']);
         foreach ($headings as $heading) {
             $options[$tab['id']][$heading['name']] = '';
             foreach ($heading['options'] as $option) {
                 $options[$tab['id']][$heading['name']] .= $this->interface->meta_box_row_template($option);
             }
         }
     }
     echo '<div style="clear:both;height:20px;"> </div>';
     $this->create_form_meta_box($options);
     $approve_button = '<a href="#" id="tf_rf_confirm_reservation" class="button">' . __('Approve', 'tfuse') . '</a>';
     $reject_button = ' <a id="tf_rf_reject_reservation" href="#" class="button reset-button">' . __('Reject', 'tfuse') . '</a>';
     $message_button = ' <a id="tf_rf_send_message_reservation" href="#" class="button">' . __('Send message', 'tfuse') . '</a>';
     if (in_array($post->post_status, array('private', 'draft'))) {
         echo $approve_button;
     } else {
         echo $message_button;
     }
     if (in_array($post->post_status, array('private', 'publish'))) {
         echo $reject_button;
     } else {
         echo $message_button;
     }
 }