Example #1
0
function likeThisCheckHeaders()
{
    if (isset($_POST["likepost"])) {
        $id = $_POST["likepost"];
        $direction = $_POST["direction"];
        likeThis($id, 'update', $direction);
        $resp = array("element" => generateLikeString($id, $direction > 0), "add" => $direction == 1, "id" => $id);
        header('Content-type: application/json');
        $out = json_encode($resp);
        die(print $out);
    }
    //if
}
Example #2
0
 function dt_sc_gallery_item($attrs, $content = "")
 {
     extract(shortcode_atts(array('id' => '', 'space' => '', 'image_size' => ''), $attrs));
     $out = "";
     if (!empty($id)) {
         $p = get_post($id);
         if ($p->post_type === "dt_galleries") {
             $permalink = get_permalink($id);
             $gallery_item_meta = get_post_meta($id, '_gallery_settings', TRUE);
             $gallery_item_meta = is_array($gallery_item_meta) ? $gallery_item_meta : array();
             $items_id_exists = array_key_exists('items_id', $gallery_item_meta) ? true : false;
             $space = $space == "yes" ? "with-space" : "no-space";
             $out .= "<div id='dt_galleries-{$id}' class='dt-gallery gallery {$space}'>";
             $out .= '	<figure>';
             $popup = "http://placehold.it/1060x795&text=DesignThemes";
             if (array_key_exists('items_name', $gallery_item_meta)) {
                 $item = $gallery_item_meta['items_name'][0];
                 $popup = $gallery_item_meta['items'][0];
                 if ("video" === $item) {
                     $items = array_diff($gallery_item_meta['items_name'], array("video"));
                     if (!empty($items)) {
                         if ($items_id_exists) {
                             $id = $gallery_item_meta['items_id'][key($items)];
                             $img = wp_get_attachment_image_src($id, $image_size);
                             $out .= "<img src='" . $img[0] . "' width='" . $img[1] . "' height='" . $img[2] . "' alt=''/>";
                         } else {
                             echo "<img src='" . $gallery_item_meta['items'][key($items)] . "' width='1060' height='795' alt='' />";
                         }
                     } else {
                         $out .= '<img src="http://placehold.it/1060x795&text=DesignThemes" width="1060" height="795" alt="">';
                     }
                 } else {
                     if ($items_id_exists) {
                         $id = $gallery_item_meta['items_id'][0];
                         $img = wp_get_attachment_image_src($id, $image_size);
                         $out .= "<img src='" . $img[0] . "' width='" . $img[1] . "' height='" . $img[2] . "' alt=''/>";
                     } else {
                         echo "<img src='" . $gallery_item_meta['items'][0] . "' width='1060' height='795' alt=''/>";
                     }
                 }
             } else {
                 $out .= "<img src='{$popup}'/>";
             }
             $out .= '		<div class="image-overlay">';
             $out .= '			<div class="image-overlay-details">';
             $out .= "\t\t\t\t<h5><a href='{$permalink}'>{$p->post_title}</a></h5>";
             $out .= '				<div class="links">';
             $out .= "              \t\t<a href='{$popup}' data-gal='prettyPhoto[gallery]'> <span class='fa fa-search-plus'> </span> </a>";
             $out .= "\t\t\t\t\t<a href='{$permalink}'> <span class='fa fa-external-link'> </span> </a>";
             if (dttheme_is_plugin_active('roses-like-this/likethis.php')) {
                 $out .= "<div class='views'> <span class='fa fa-heart'> </span> " . generateLikeString($id, isset($_COOKIE["like_" . $id])) . '</div>';
             }
             $out .= '				</div>';
             $out .= '			</div>';
             $out .= '			<a class="close-overlay hidden"> x </a>';
             $out .= '		</div>';
             $out .= '	</figure>';
             if ($space == "with-space") {
                 $out .= '<div class="dt-gallery-details">';
                 $out .= '	<div class="dt-gallery-details-inner">';
                 $out .= "\t<h5><a href='{$permalink}'>{$p->post_title}</a></h5>";
                 if (array_key_exists("sub-title", $gallery_item_meta)) {
                     $out .= "<h6>{$gallery_item_meta['sub-title']}</h6>";
                 }
                 $out .= '	</div>';
                 $out .= '</div>';
             }
             $out .= "</div>";
         } else {
             $out .= "<p>" . __("There is no gallery item with id :", "dt_themes") . $id . "</p>";
         }
     } else {
         $out .= "<p>" . __("Please give gallery post id", "dt_themes") . "</p>";
     }
     return $out;
 }