function handle_shortcode($atts, $content = null, $code = "")
 {
     extract(shortcode_atts(array('width' => '0', 'columns' => false, 'class' => '', 'post_types' => false, 'calendarized_only' => '0'), $atts));
     global $post;
     $out = '';
     if (property_exists($post, 'ID') && $post->ID > 0) {
         if ($calendarized_only == '1') {
             if ('' == trim(get_post_meta($post->ID, 'fc_start', true))) {
                 return '';
             }
         }
         if (false !== $post_types) {
             $arr = explode(',', str_replace(' ', '', $post_types));
             if (is_array($arr) && count($arr) > 0) {
                 if (!in_array($post->post_type, $arr)) {
                     return '';
                 }
             }
         }
         $out = rhc_post_info_shortcode::render($post->ID, intval($width), $class, $columns);
     }
     return $out;
 }
 function wp_ajax_get_postinfo()
 {
     foreach (array('post_ID' => 0, 'postinfo_boxes_id' => '') as $field => $default) {
         ${$field} = isset($_POST[$field]) ? $_POST[$field] : $default;
     }
     if (!empty($post_ID) && !empty($postinfo_boxes_id)) {
         $response = (object) array('R' => 'OK', 'DATA' => rhc_post_info_shortcode::get_post_extra_info($post_ID, $postinfo_boxes_id));
         die(json_encode($response));
     } else {
         $response = (object) array('R' => 'ERR', 'MSG' => __('Missing parameter.', 'rhc'));
         die(json_encode($response));
     }
 }
 public static function render($post_ID, $width, $class = '', $columns = false, $frontend = true, $container_span = '6', $s)
 {
     if (false === $columns) {
         $columns = $s->columns;
         $columns = $columns < 0 ? $columns = 1 : $columns;
     }
     $data = $s->data;
     $out = '';
     if (false == $frontend || is_array($data) && count($data) > 0) {
         //back compat fill in the blanks.
         foreach ($data as $i => $cell) {
             $arr = (array) $cell;
             if (!property_exists($cell, 'column') || '' == $cell->column) {
                 $j = $i;
                 $cell->column = fmod($j, $columns);
                 $cell->span = 12;
                 $cell->offset = 0;
                 $data[$i] = $cell;
             }
         }
         $style = "";
         //$style = $width=='0'?'width:100%;':"width:{$width}px;";
         $have_image = false;
         $attachment_holder_class = '';
         $thumbnail = rhc_post_info_shortcode::get_attachment($post_ID, $frontend, $s, $have_image, $attachment_holder_class);
         $container_span = $have_image ? $container_span : '12';
         $out .= "<div class=\"rhc fe-extrainfo-container {$class} fe-have-image-" . ($have_image ? '1' : '0') . "\" style=\"{$style}\">";
         $out .= "<div class=\"fe-extrainfo-container2 row-fluid\">";
         $out .= "<div class=\"fe-extrainfo-holder fe-extrainfo-col{$columns} span{$container_span}\">";
         $columnas_arr = array();
         for ($a = 0; $a < $columns; $a++) {
             $columnas_arr[$a] = array();
             foreach ($data as $index => $cell) {
                 if ($cell->column != $a) {
                     continue;
                 }
                 $cell->index = $index;
                 $columnas_arr[$a][] = $cell;
             }
         }
         if (!$frontend) {
             //fill in empty
             for ($a = 0; $a < $columns; $a++) {
                 if (!isset($columnas_arr[$a]) || empty($columnas_arr[$a])) {
                     $columnas_arr[$a] = array();
                     $columnas_arr[$a][] = (object) array('type' => 'empty');
                 }
             }
         }
         $out .= "<div class=\"row-fluid\">";
         $span = 12 / count($columnas_arr);
         foreach ($columnas_arr as $i => $cells) {
             $out .= sprintf("<div class=\"span%s fe-maincol fe-maincol-%s\" data-column_index=\"%s\">", $span, $i, $i);
             if (!empty($cells)) {
                 //--
                 $pending_close = false;
                 $cols = 0;
                 foreach ($cells as $cell) {
                     $c = new rhc_post_info_field((array) $cell);
                     if ($cols == 0) {
                         $out .= "<div class=\"row-fluid fe-sortable\">";
                         $pending_close = true;
                     }
                     $out .= sprintf("<div class=\"%s%s\">%s</div>", $c->span > 0 ? 'span' . $c->span : '', $c->offset > 0 ? 'offset' . $c->offset : '', $c->render($frontend));
                     $cols = $cols + $c->span + $c->offset;
                     if ($cols >= 12) {
                         $out .= "</div>";
                         $cols = 0;
                         $pending_close = false;
                     }
                 }
                 if ($pending_close) {
                     $out .= "</div>";
                     //this closes an open div on the previous foreach.
                 }
                 //--
             }
             $out .= "</div>";
         }
         $out .= "</div>";
         $out .= "</div>";
         //-----
         if ($have_image) {
             $out .= sprintf("<div class=\"%s span%s\">", $attachment_holder_class, abs(12 - $container_span));
             $out .= $thumbnail;
             $out .= "</div>";
         }
         //-----
         $out .= "</div>";
         $out .= "</div>";
     }
     return do_shortcode($out);
 }
 //back compat fill in the blanks.
 foreach ($data as $i => $cell) {
     $arr = (array) $cell;
     if (!property_exists($cell, 'column') || '' == $cell->column) {
         $j = $i;
         $cell->column = fmod($j, $columns);
         $cell->span = 12;
         $cell->offset = 0;
         $data[$i] = $cell;
     }
 }
 $style = "";
 //$style = $width=='0'?'width:100%;':"width:{$width}px;";
 $have_image = false;
 $attachment_holder_class = '';
 $thumbnail = rhc_post_info_shortcode::get_attachment($post_ID, $frontend, $s, $have_image, $attachment_holder_class);
 $container_span = $have_image ? $container_span : '12';
 $out .= "<div class=\"rhc fe-extrainfo-container {$class} fe-have-image-" . ($have_image ? '1' : '0') . "\" style=\"{$style}\">";
 $out .= "<div class=\"fe-extrainfo-container2 row-fluid\">";
 $out .= "<div class=\"fe-extrainfo-holder fe-extrainfo-col{$columns} span{$container_span}\">";
 $columnas_arr = array();
 for ($a = 0; $a < $columns; $a++) {
     $columnas_arr[$a] = array();
     foreach ($data as $index => $cell) {
         if ($cell->column != $a) {
             continue;
         }
         $cell->index = $index;
         $columnas_arr[$a][] = $cell;
     }
 }
Пример #5
0
 function handle_postinfo($atts, $template = '', $code = "")
 {
     return rhc_post_info_shortcode::handle_shortcode($atts, $template, $code);
 }
 function extended_details()
 {
     global $post;
     $output = '<div>';
     $ids = isset($_REQUEST['ids']) && is_array($_REQUEST['ids']) ? $_REQUEST['ids'] : array();
     if (!empty($ids)) {
         foreach ($ids as $id) {
             $arr = explode('-', $id);
             if (count($arr) == '2') {
                 if (defined('RHP_PATH')) {
                     $post = get_post($arr[0]);
                     //social panel needs the real thing loaded.
                 } else {
                     $post = (object) array('ID' => $arr[0], 'post_type' => $arr[1]);
                 }
                 $output .= rhc_post_info_shortcode::handle_shortcode(array('class' => 'se-dbox ' . $id));
             }
         }
     }
     $output .= '</div>';
     //sleep(3);
     $this->send_response($output, 'html');
 }