public static function getPortfolioWithId($pid) { if (!$pid) { return null; } global $wpdb; $portfolio = null; $query = @$wpdb->prepare("SELECT * FROM " . CRP_TABLE_PORTFOLIOS . " WHERE id='{$pid}'"); $res = $wpdb->get_results($query, OBJECT); if (count($res)) { $portfolio = $res[0]; $query = @$wpdb->prepare("SELECT * FROM " . CRP_TABLE_PROJECTS . " WHERE pid='{$pid}'"); $res = $wpdb->get_results($query, OBJECT); $projects = array(); foreach ($res as $project) { $project->pics = explode(',', $project->pics); $project->categories = explode(',', $project->categories); $projects[$project->id] = $project; } $portfolio->projects = $projects; $portfolio->corder = explode(',', $portfolio->corder); if ($portfolio->options && !empty($portfolio->options)) { $portfolio->options = json_decode(base64_decode($portfolio->options), true); } else { $portfolio->options = json_decode(base64_decode(CRPHelper::getPortfolioDefaultOptions()), true); } } return $portfolio; }
private function initializeTables() { global $wpdb; //Insert demo portfolio $wpdb->insert($this->tablePortfolios, array('title' => '', 'corder' => '', 'options' => CRPHelper::getPortfolioDefaultOptions())); $pid = $wpdb->insert_id; //Add demo project $wpdb->insert($this->tableProjects, array('pid' => $pid, 'title' => '', 'description' => "")); }
foreach ($crp_portfolio->projects as $crp_project) { ?> <div id="crp-tile-<?php echo $crp_project->id; ?> " class="tile"> <?php $coverInfo = json_decode(base64_decode($crp_project->cover)); ?> <a id="<?php echo $crp_project->id; ?> " class="tile-inner"> <img class="item" src="<?php echo CRPHelper::thumbWithQuality($coverInfo, $crp_portfolio->options[CRPOption::kThumbnailQuality]); ?> " /> <div class="caption"> </div> </a> <ul id="crp-light-gallery-<?php echo $crp_project->id; ?> " class="crp-light-gallery" style="display: none;" data-sub-html=" <?php if (isset($crp_project->title) && $crp_project->title !== '' || isset($crp_project->description) && $crp_project->description !== '') { ?> <div class='lg-info'>
function crp_include_inline_scripts() { ?> <script type="text/javascript"> <?php $crp_shortcodes = CRPHelper::tcButtonShortcodes(); ?> crp_shortcodes = []; <?php foreach ($crp_shortcodes as $crp_shortcode) { ?> crp_shortcodes.push({ "id" : "<?php echo $crp_shortcode->id; ?> ", "title" : "<?php echo $crp_shortcode->title; ?> ", "shortcode" : "<?php echo $crp_shortcode->shortcode; ?> " }); <?php } ?> jQuery(document).ready(function() { }); </script> <?php }
function fetchData() { global $wpdb; $query = @$wpdb->prepare("SELECT * FROM " . CRP_TABLE_PORTFOLIOS); $results = $wpdb->get_results($query, ARRAY_A); for ($i = 0; $i < count($results); $i++) { $pid = $results[$i]["id"]; $results[$i]["pcount"] = $wpdb->get_var("SELECT COUNT(*) FROM " . CRP_TABLE_PROJECTS . " WHERE pid='{$pid}'"); $results[$i]["shortcode"] = CRPHelper::shortcodeWithPID($pid); //Build row actions $actions = array('options' => sprintf('<a href="#" style="float: right; margin-right: 5px; margin-top: 2px; cursor: not-allowed !important;"><i class="fa fa-cog fa-fw" style="font-size: 17px; color: #2980b9"></i></a>', $_REQUEST['page'], 'options', $pid), 'edit' => sprintf('<a href="?page=%s&action=%s&id=%s" style="float: right; margin-right: 7px; margin-top: 2px;"><i class="fa fa-pencil-square-o" style="font-size: 17px; color: #2980b9"></i></a>', $_REQUEST['page'], 'edit', $pid), 'delete' => sprintf('<a href="?page=%s&action=%s&id=%s" style="float: right; margin-right: 10px; margin-top: 0px;"><i class="fa fa-times" style="font-size: 19px; color: #c0392b"></i></a>', $_REQUEST['page'], 'delete', $pid)); $results[$i]["options"] = $actions['delete'] . $actions['options'] . $actions['edit']; } return $results; }