/**
  * Determines template and renders it
  *
  *
  */
 public function get_template($template, $data, $output = true)
 {
     $name = apply_filters($this->id . '_template_name', array($template), $this);
     /* Set possible pathes where templates could be stored. */
     $path = apply_filters($this->id . '_template_path', array(ud_get_wp_property()->path('static/views', 'dir')));
     $path = \UsabilityDynamics\Utility::get_template_part($name, $path, array('load' => false));
     if ($output) {
         extract($data);
         include $path;
     } else {
         ob_start();
         extract($data);
         include $path;
         return ob_get_clean();
     }
 }
 /**
  *
  *
  */
 private static function _prepare_post_type($key, $args = array())
 {
     $args = wp_parse_args($args, array('label' => \UsabilityDynamics\Utility::de_slug($key), 'exclude_from_search' => false));
     return $args;
 }
Esempio n. 3
0
 /**
  * Constructor
  * Sets default data.
  *
  *
  * @todo For the love of god, only apply the defaults on installation. - potanin@UD
  * @param bool $args
  */
 public function __construct($args = false)
 {
     global $wp_properties;
     //** STEP 1. Default */
     parent::__construct($args);
     //** STEP 2. */
     $data = array();
     //** This slug will be used to display properties on the front-end.  Most likely overwriten by get_option('wpp_settings'); */
     $data['configuration'] = array('autoload_css' => 'true', 'automatically_insert_overview' => 'true', 'base_slug' => 'property', 'currency_symbol' => '$', 'address_attribute' => 'location', 'google_maps_localization' => 'en', 'display_address_format' => '[city], [state]');
     //** Default setings for [property_overview] shortcode */
     $data['configuration']['property_overview'] = array('thumbnail_size' => 'tiny_thumb', 'fancybox_preview' => 'true', 'display_slideshow' => 'false', 'show_children' => 'true');
     $data['configuration']['single_property_view'] = array('map_image_type' => 'tiny_thumb', 'gm_zoom_level' => '13');
     //** Default setings for admin UI */
     $data['configuration']['admin_ui'] = array('overview_table_thumbnail_size' => 'tiny_thumb');
     $data['default_coords']['latitude'] = '57.7973333';
     $data['default_coords']['longitude'] = '12.0502107';
     //** Geo type attributes are predefined and should not be editable on property adding/updating */
     // @notice All these fields are automatically added as post_meta on revalidation.
     $data['geo_type_attributes'] = array('formatted_address', 'street_number', 'route', 'district', 'city', 'county', 'state', 'state_code', 'country', 'country_code', 'postal_code');
     //** Image URLs. */
     $data['images']['map_icon_shadow'] = WPP_URL . "images/map_icon_shadow.png";
     $data['configuration']['google_maps']['infobox_settings'] = array('show_direction_link' => true, 'show_property_title' => true);
     //** Default attribute label descriptions for the back-end */
     $data['descriptions'] = array('descriptions' => array('property_type' => sprintf(__('The %s type will determine the layout.', ud_get_wp_property()->domain), \WPP_F::property_label()), 'custom_attribute_overview' => __('Customize what appears in search results in the attribute section.  For example: 1bed, 2baths, area varies slightly.', ud_get_wp_property()->domain), 'tagline' => __('Will appear on overview pages and on top of every listing page.', ud_get_wp_property()->domain)));
     $_stored_settings = $this->get();
     //** Merge with default data. */
     $this->set(\UsabilityDynamics\Utility::extend($data, $this->get()));
     // Check if settings have or have been upated. (we determine if configuration is good)
     // @todo Add a better _version_ check.
     if (isset($_stored_settings['_updated']) && isset($_stored_settings['version']) && $_stored_settings['version'] === '2.0.0') {
         return $wp_properties = $this->get();
     }
     // Continue on to load/enforce defaults.
     //** STEP 3. */
     //** Setup default property types to be used. */
     $d = $this->get('property_types', false);
     // Should only be set on install, not added on every request. These literally can not be removed from settings... -potanin@UD
     // It is adding these defaults only if types are empty (install) - korotkov@UD
     if (empty($d) || !is_array($d)) {
         $this->set('property_types', array('building' => __('Building', ud_get_wp_property()->domain), 'floorplan' => __('Floorplan', ud_get_wp_property()->domain), 'single_family_home' => __('Single Family Home', ud_get_wp_property()->domain)));
     }
     //** Setup property types to be used. */
     $d = !$this->get('property_inheritance', false);
     if (!$d || !is_array($d)) {
         $this->set('property_inheritance', array('floorplan' => array('street_number', 'route', 'state', 'postal_code', 'location', 'display_address', 'address_is_formatted')));
     }
     //** Property stats. Can be searchable, displayed as input boxes on editing page. */
     $d = $this->get('property_stats', false);
     if (!$d || !is_array($d)) {
         $this->set('property_stats', array('location' => __('Address', ud_get_wp_property()->domain), 'price' => __('Price', ud_get_wp_property()->domain), 'deposit' => __('Deposit', ud_get_wp_property()->domain), 'area' => __('Area', ud_get_wp_property()->domain), 'phone_number' => __('Phone Number', ud_get_wp_property()->domain)));
     }
     //** Property meta.  Typically not searchable, displayed as textarea on editing page. */
     $d = $this->get('property_meta', false);
     if (!$d || !is_array($d)) {
         $this->set('property_meta', array('lease_terms' => __('Lease Terms', ud_get_wp_property()->domain), 'pet_policy' => __('Pet Policy', ud_get_wp_property()->domain), 'school' => __('School', ud_get_wp_property()->domain), 'tagline' => __('Tagline', ud_get_wp_property()->domain)));
     }
     //** On property editing page - determines which fields to hide for a particular property type */
     $d = $this->get('hidden_attributes', false);
     if (!is_array($d)) {
         $this->set('hidden_attributes', array('floorplan' => array('location', 'parking', 'school'), 'building' => array('price', 'bedrooms', 'bathrooms', 'area', 'deposit'), 'single_family_home' => array('deposit', 'lease_terms', 'pet_policy')));
     }
     //** Determines property types that have addresses. */
     $d = $this->get('location_matters', false);
     if (!is_array($d)) {
         $this->set('location_matters', array('building', 'single_family_home'));
     }
     //** Determine which property types should actually be searchable. */
     $d = $this->get('searchable_property_types', false);
     if (!is_array($d)) {
         $this->set('searchable_property_types', array('floorplan', 'single_family_home'));
     }
     //** Attributes to use in searching. */
     $d = $this->get('searchable_attributes', false);
     if (!is_array($d)) {
         $this->set('searchable_attributes', array('area', 'deposit', 'bedrooms', 'bathrooms', 'city', 'price'));
     }
     //** Convert phrases to searchable values.  Converts string stats into numeric values for searching and filtering. */
     $d = $this->get('search_conversions', false);
     if (!is_array($d)) {
         $this->set('search_conversions', array('bedrooms' => array(__('Studio', ud_get_wp_property()->domain) => '0.5')));
     }
     //** Don't load defaults if settings exist in db */
     $d = $this->get('image_sizes', false);
     if (!is_array($d)) {
         $this->set('image_sizes', array('map_thumb' => array('width' => '75', 'height' => '75'), 'tiny_thumb' => array('width' => '100', 'height' => '100'), 'sidebar_wide' => array('width' => '195', 'height' => '130'), 'slideshow' => array('width' => '640', 'height' => '235')));
     }
     $d = $this->get('configuration.google_maps.infobox_attributes', false);
     if (!is_array($d)) {
         $this->set('configuration.google_maps.infobox_attributes', array('bedrooms', 'bathrooms', 'price'));
     }
     //** STEP 4. */
     $wp_properties = $this->get();
 }
 /**
  * Content for the "status" column.
  *
  * @param  array  $item The current item.
  * @since  1.0.0
  * @return string       The content of this column.
  */
 public function column_product_status($item)
 {
     $response = '';
     if ('active' == $item['product_status']) {
         $deactivate_url = wp_nonce_url(\UsabilityDynamics\Utility::current_url(array('action' => 'deactivate-product', 'filepath' => urlencode($item['product_file_path']))), 'bulk-licenses');
         //$deactivate_url = wp_nonce_url( add_query_arg( 'action', 'deactivate-product', add_query_arg( 'filepath', $item['product_file_path'], add_query_arg( 'page', $this->page, network_admin_url( 'index.php' ) ) ) ), 'bulk-licenses' );
         $response = '<a href="' . esc_url($deactivate_url) . '" onclick="return confirm(\'' . __('Are you sure you want to deactivate the license?', $this->domain) . '\');">' . __('Deactivate', $this->domain) . '</a>' . "\n";
     } else {
         $response .= '<ul>' . "\n";
         $response .= '<li><input name="products[' . esc_attr($item['product_file_path']) . '][license_key]" id="license_key-' . esc_attr($item['product_file_path']) . '" type="text" value="" size="37" aria-required="true" placeholder="' . esc_attr(__('Place License Key here', $this->domain)) . '" /><li>' . "\n";
         if (!$this->activation_email) {
             $response .= '</ul>' . "\n";
             $response .= '<input name="products[' . esc_attr($item['product_file_path']) . '][activation_email]" type="hidden" value="" />' . "\n";
         } else {
             $response .= '<li><input name="products[' . esc_attr($item['product_file_path']) . '][activation_email]" id="activation_email-' . esc_attr($item['product_file_path']) . '" type="text" value="" size="37" aria-required="true" placeholder="' . esc_attr(__('Place Activation Email here', $this->domain)) . '" /></li>' . "\n";
             $response .= '</ul>' . "\n";
         }
     }
     return $response;
 }
Esempio n. 5
0
 /**
  * Process the action for the admin screen.
  * @since  1.0.0
  * @return  void
  */
 public function process_request()
 {
     add_action('admin_notices', array($this, 'admin_notices'));
     $supported_actions = array('activate-products', 'deactivate-product');
     if (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], $supported_actions) || !check_admin_referer('bulk-' . 'licenses')) {
         return null;
     }
     $response = false;
     $status = 'false';
     $type = $_REQUEST['action'];
     switch ($type) {
         case 'activate-products':
             $products = array();
             if (isset($_POST['products']) && 0 < count($_POST['products'])) {
                 foreach ($_POST['products'] as $k => $v) {
                     if (!empty($v['license_key'])) {
                         $products[$k] = $v;
                     }
                 }
             }
             if (0 < count($products)) {
                 //echo "<pre>"; print_r( $products ); echo "</pre>"; die();
                 $response = $this->activate_products($products);
             } else {
                 $response = false;
                 $type = 'no-license-keys';
             }
             break;
         case 'deactivate-product':
             if (isset($_GET['filepath']) && '' != $_GET['filepath']) {
                 $response = $this->deactivate_product($_GET['filepath']);
             }
             break;
         default:
             break;
     }
     if ($response == true) {
         $status = 'true';
     }
     $redirect_url = \UsabilityDynamics\Utility::current_url(array('type' => urlencode($type), 'status' => urlencode($status)), array('action', 'filepath', '_wpnonce'));
     wp_safe_redirect($redirect_url);
     exit;
 }
Esempio n. 6
0
 /**
  * Returns specific schema from composer.json file.
  *
  * @param string $file Path to file
  * @author peshkov@UD
  * @return mixed array or false
  */
 public function get_schema($key = '')
 {
     if ($this->schema === null) {
         if (!empty($this->schema_path) && file_exists($this->schema_path)) {
             $this->schema = (array) \UsabilityDynamics\Utility::l10n_localize(json_decode(file_get_contents($this->schema_path), true), (array) $this->get_localization());
         }
     }
     //** Break if composer.json does not exist */
     if (!is_array($this->schema)) {
         return false;
     }
     //** Resolve dot-notated key. */
     if (strpos($key, '.')) {
         $current = $this->schema;
         $p = strtok($key, '.');
         while ($p !== false) {
             if (!isset($current[$p])) {
                 return false;
             }
             $current = $current[$p];
             $p = strtok('.');
         }
         return $current;
     } else {
         return isset($this->schema[$key]) ? $this->schema[$key] : false;
     }
 }