コード例 #1
0
 /**
  * Custom admin columns implementation
  *
  * @access public
  * @param string $column
  * @return array
  */
 public static function custom_columns_manage($column)
 {
     switch ($column) {
         case 'thumbnail':
             if (has_post_thumbnail()) {
                 the_post_thumbnail('thumbnail', array('class' => 'attachment-thumbnail attachment-thumbnail-small'));
             } else {
                 echo '-';
             }
             break;
         case 'price':
             $price = Realia_Price::get_property_price(get_the_ID());
             if (!empty($price)) {
                 echo wp_kses($price, wp_kses_allowed_html('post'));
             } else {
                 echo '-';
             }
             break;
         case 'location':
             $terms = get_the_terms(get_the_ID(), 'locations');
             if (!empty($terms)) {
                 $location = array_shift($terms);
                 echo sprintf('<a href="?post_type=property&location=%s">%s</a>', $location->slug, $location->name);
             } else {
                 echo '-';
             }
             break;
         case 'type':
             $terms = get_the_terms(get_the_ID(), 'property_types');
             if (is_array($terms)) {
                 $property_type = array_shift($terms);
                 echo sprintf('<a href="?post_type=property&property_type=%s">%s</a>', $property_type->slug, $property_type->name);
             } else {
                 echo '-';
             }
             break;
         case 'contract':
             $terms = get_the_terms(get_the_ID(), 'contracts');
             if (!empty($terms)) {
                 $contract_type = array_shift($terms);
                 echo sprintf('<a href="?post_type=property&contract=%s">%s</a>', $contract_type->slug, $contract_type->name);
             } else {
                 echo '-';
             }
             break;
         case 'sticky':
             $sticky = get_post_meta(get_the_ID(), REALIA_PROPERTY_PREFIX . 'sticky', true);
             if (!empty($sticky)) {
                 echo '<div class="dashicons-before dashicons-yes green"></div>';
             } else {
                 echo '<div class="dashicons-before dashicons-no red"></div>';
             }
             break;
         case 'featured':
             $featured = get_post_meta(get_the_ID(), REALIA_PROPERTY_PREFIX . 'featured', true);
             if (!empty($featured)) {
                 echo '<div class="dashicons-before dashicons-yes green"></div>';
             } else {
                 echo '<div class="dashicons-before dashicons-no red"></div>';
             }
             break;
         case 'reduced':
             $featured = get_post_meta(get_the_ID(), REALIA_PROPERTY_PREFIX . 'reduced', true);
             if (!empty($featured)) {
                 echo '<div class="dashicons-before dashicons-yes green"></div>';
             } else {
                 echo '<div class="dashicons-before dashicons-no red"></div>';
             }
             break;
         case 'views':
             echo __('Total', 'realia') . ': ' . Realia_Statistics::property_views_get_total() . '<br>';
             echo __('Weekly', 'realia') . ': ';
             $progress = Realia_Statistics::property_views_get_weekly_progress();
             if ($progress < 0) {
                 echo '<span class="red">' . $progress . '%</span>';
             } elseif ($progress > 0) {
                 echo '<span class="green">' . $progress . '%</span>';
             } else {
                 echo '<span>' . $progress . '%</span>';
             }
             break;
         case 'paid':
             $paid = Realia_Query::is_property_paid();
             if ($paid) {
                 echo '<div class="dashicons-before dashicons-yes green"></div>';
             } else {
                 echo '<div class="dashicons-before dashicons-no red"></div>';
             }
             break;
     }
 }
コード例 #2
0
                                YEAR(created) = YEAR( current_date );';
        $last_week_results = $wpdb->get_results($last_week_sql);
        $last_week_count = 0;
        if (is_array($last_week_results) && count($last_week_results) > 0) {
            $last_week_count = $last_week_results[0]->count;
        }
        // Two weeks ago
        $two_weeks_ago_sql = 'SELECT `key`, COUNT(*) as count FROM wp_property_stats
                        WHERE   `key` = "' . $post_id . '" AND
                                WEEK(created) = WEEK( current_date ) - 2 AND
                                YEAR(created) = YEAR( current_date );';
        $two_weeks_ago_results = $wpdb->get_results($two_weeks_ago_sql);
        if (is_array($two_weeks_ago_results) && count($two_weeks_ago_results) > 0) {
            $two_weeks_ago_count = $two_weeks_ago_results[0]->count;
        }
        if ($two_weeks_ago_count == 0 && $last_week_count > 0) {
            return 100;
        } elseif ($two_weeks_ago_count == 0 && $last_week_count == 0) {
            return 0;
        } elseif ($two_weeks_ago_count > 0 && $last_week_count == 0) {
            return -100;
        } elseif ($two_weeks_ago_count == $last_week_count) {
            return 0;
        } elseif ($two_weeks_ago_count > 0 && $last_week_count > 0) {
            return round(100 / $two_weeks_ago_count * $last_week_count - 100, 2);
        }
        return 0;
    }
}
Realia_Statistics::init();
コード例 #3
0
ファイル: property-views.php プロジェクト: jhonrsalcedo/sitio
        ?>
</td>
                        </tr>
                    <?php 
    }
    ?>
                    </tbody>
                </table>
            <?php 
}
?>
        </div><!-- /.one-half -->

        <div class="one-half">
            <?php 
$locations = Realia_Statistics::property_views_get_popular_locations();
?>

            <?php 
if (!empty($locations) && is_array($locations)) {
    ?>
                <table class="table">
                    <thead>
                    <th colspan="2" class="center">
                        <?php 
    echo __('10 most popular locations', 'realia');
    ?>
                    </th>
                    </thead>

                    <tbody>