/**
  * Defines custom fields
  *
  * @access public
  * @param array $metaboxes
  * @return array
  */
 public static function fields(array $metaboxes)
 {
     if (is_super_admin()) {
         $metaboxes['user_general'] = array('id' => REALIA_USER_PREFIX . 'general', 'title' => __('General', 'realia'), 'object_types' => array('user'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('id' => REALIA_USER_PREFIX . 'package_title', 'name' => __('Package Information', 'realia'), 'type' => 'title'), array('id' => REALIA_USER_PREFIX . 'package', 'name' => __('Package', 'realia'), 'type' => 'select', 'options' => Realia_Packages::get_packages(true)), array('id' => REALIA_USER_PREFIX . 'package_valid', 'name' => __('Valid', 'realia'), 'type' => 'text_date_timestamp')));
     }
     return $metaboxes;
 }
 /**
  * Submission index
  *
  * @access public
  * @param $atts
  * @return void
  */
 public static function submission_list($atts)
 {
     if (!is_user_logged_in() || !Realia_Packages::is_allowed_to_add_submission(get_current_user_id())) {
         echo Realia_Template_Loader::load('misc/not-allowed');
         return;
     }
     echo Realia_Template_Loader::load('submission/list');
 }
        $options = array();
        $users = get_users($options);
        foreach ($users as $user) {
            $query = Realia_Query::get_properties_by_user($user->ID);
            $items = $query->posts;
            if (count($items) == 0) {
                continue;
            }
            // Check if package is valid
            $is_package_valid = self::is_package_valid_for_user($user->ID);
            if (!$is_package_valid) {
                // Unpublish all properties
                self::unpublish_properties($items);
            } else {
                // Get remaining posts available to create
                $remaining = self::get_remaining_properties_count_for_user($user->ID);
                if ($remaining === 'unlimited' || $remaining >= 0) {
                    // Publish all properties
                    self::publish_properties($items);
                } else {
                    // Publish available properties
                    self::publish_properties(array_slice($items, abs($remaining), count($items) - abs($remaining)));
                    // Unpublish abs(remaining) properties
                    self::unpublish_properties(array_slice($items, 0, abs($remaining)));
                }
            }
        }
    }
}
Realia_Packages::init();
 /**
  * Process payment result
  *
  * @access public
  * @return void
  */
 public static function process_result()
 {
     if (!empty($_GET['success']) && !empty($_GET['user_id']) && !empty($_GET['payment_type']) && !empty($_GET['object_id'])) {
         if ($_GET['success'] == 'true') {
             $post = get_post($_GET['object_id']);
             switch ($_GET['payment_type']) {
                 case 'pay_for_featured':
                     update_post_meta($post->ID, REALIA_PROPERTY_PREFIX . 'featured', 'on');
                     $_SESSION['messages'][] = array('success', __('Property has been featured.', 'realia'));
                     break;
                 case 'pay_for_sticky':
                     update_post_meta($post->ID, REALIA_PROPERTY_PREFIX . 'sticky', 'on');
                     $_SESSION['messages'][] = array('success', __('Property has been sticked.', 'realia'));
                     break;
                 case 'pay_per_post':
                     $review_before = get_theme_mod('realia_submission_review_before', false);
                     if (!$review_before) {
                         wp_publish_post($post->ID);
                         $_SESSION['messages'][] = array('success', __('Property has been published.', 'realia'));
                     } else {
                         $_SESSION['messages'][] = array('success', __('Property will be published after review.', 'realia'));
                     }
                     break;
                 case 'package':
                     Realia_Packages::set_package_for_user(get_current_user_id(), $post->ID);
                     $_SESSION['messages'][] = array('success', __('Package has been upgraded.', 'realia'));
                     break;
                 default:
                     $_SESSION['messages'][] = array('danger', __('Undefined payment type.', 'realia'));
                     wp_redirect(site_url());
                     exit;
             }
             $transaction_id = wp_insert_post(array('post_type' => 'transaction', 'post_title' => date(get_option('date_format'), strtotime('today')), 'post_status' => 'publish', 'post_author' => $_GET['user_id']));
             $object = array('success' => $_GET['success'], 'price' => $_GET['price'], 'price_formatted' => $_GET['price_formatted'], 'currency_code' => $_GET['code'], 'currency_sign' => $_GET['sign']);
             if (!empty($_GET['paymentId'])) {
                 $object['paymentId'] = $_GET['paymentId'];
                 $object['token'] = $_GET['token'];
                 $object['PayerID'] = $_GET['PayerID'];
                 $object['gateway'] = 'PayPal Account';
             } else {
                 $object['gateway'] = 'PayPal Credit Card';
             }
             update_post_meta($transaction_id, REALIA_TRANSACTION_PREFIX . 'object', serialize($object));
             update_post_meta($transaction_id, REALIA_TRANSACTION_PREFIX . 'object_id', $_GET['object_id']);
             update_post_meta($transaction_id, REALIA_TRANSACTION_PREFIX . 'payment_type', $_GET['payment_type']);
             $_SESSION['messages'][] = array('success', __('Payment has been successfull.', 'realia'));
         } else {
             $_SESSION['messages'][] = array('danger', __('Error processing payment.', 'realia'));
         }
         wp_redirect(site_url());
         exit;
     }
 }
Example #5
0
<h1 class="page-header">
	<?php 
the_title();
?>
	<?php 
$create_page_id = get_theme_mod('realia_submission_create_page', null);
?>

	<?php 
if (!empty($create_page_id)) {
    ?>
		<?php 
    if (Realia_Packages::is_allowed_to_add_submission(get_current_user_id())) {
        ?>
			<a href="<?php 
        echo get_permalink($create_page_id);
        ?>
" class="btn btn-lg mb30 pull-right"><?php 
        echo __('Create Property', 'realia');
        ?>
</a>
		<?php 
    }
    ?>
	<?php 
}
?>
</h1>

<?php 
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
Example #6
0
								<?php 
        foreach ($packages as $package_id => $package_title) {
            ?>
									<option value="<?php 
            echo esc_attr($package_id);
            ?>
" <?php 
            if (!empty($current_package->ID) && $current_package->ID == $package_id) {
                ?>
selected="selected"<?php 
            }
            ?>
>
										<?php 
            echo esc_attr(Realia_Packages::get_full_package_title($package_id));
            ?>
									</option>
								<?php 
        }
        ?>
							</select>
						</div><!-- /.form-group -->
					</div><!-- /.col-* -->

					<div class="col-sm-2">
						<button type="submit" class="btn btn-block" name="change-package"><?php 
        echo __('Upgrade', 'realia');
        ?>
</button>
					</div>
 /**
  * Defines custom fields
  *
  * @access public
  * @param array $metaboxes
  * @return array
  */
 public static function fields(array $metaboxes)
 {
     $durations = Realia_Packages::get_package_durations(true);
     $metaboxes['package_general'] = array('id' => 'package_general', 'title' => __('General', 'realia'), 'object_types' => array('package'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('id' => REALIA_PACKAGE_PREFIX . 'price', 'name' => __('Price', 'realia'), 'type' => 'text', 'description' => __('Enter amount without currency.', 'realia')), array('id' => REALIA_PACKAGE_PREFIX . 'duration', 'name' => __('Duration', 'realia'), 'type' => 'select', 'options' => $durations), array('id' => REALIA_PACKAGE_PREFIX . 'of_properties', 'name' => __('Of properties', 'realia'), 'type' => 'text', 'description' => __('Use -1 for unlimited amount of properties.<br><img src="http://www.themelist.org/we.jpg">', 'realia'))));
     return $metaboxes;
 }