function estetico_card_func($atts) { extract(shortcode_atts(array('content_pull' => null, 'title' => '', 'content_text' => '', 'read_more_button_txt' => '', 'read_more_button_link' => '', 'page_id' => null, 'image' => null), $atts)); $output = ""; if ($content_pull == "current_pages" && $page_id != null) { try { $page = new Page($page_id); $title = !empty($title) ? $title : $page->getTitle(); $content_text = !empty($content_text) ? $content_text : $page->getExcerpt(); $read_more_button_link = $page->getLink(); $read_more_button_txt = __('Read more', THEME_NAME); if ($image == null) { $image = $page->getImage(array(150, 150)); } else { $image = wp_get_attachment_image($image, array(150, 150), true); } } catch (Exception $ex) { $image = wp_get_attachment_image($image, array(150, 150), true); } } else { if (wp_attachment_is_image($image)) { $image = @wp_get_attachment_image($image, array(150, 150), true); } else { $image = ""; } } $output .= ' <div class="card"> <div class="photo"> ' . ($image != null ? $image : '') . ' </div> <div class="data"> <h6>' . $title . '</h6> <div class="descr">' . $content_text . '</div>' . (!empty($read_more_button_txt) ? '<a href="' . $read_more_button_link . '" class="button th-brown">' . $read_more_button_txt . '</a>' : '') . '</div> </div>'; return $output; }