From b2ef17f8722f64820ea040f89d0d6162cba2eb71 Mon Sep 17 00:00:00 2001
From: Brandon Hubbard
Date: Fri, 16 Nov 2018 14:31:41 -0800
Subject: [PATCH] WP Enforcer & Auto Fixes
Installed WP Enforcer and ran PHP Code Beautifier and Fixer.
---
.gitignore | 3 +
composer.lock | 153 ++++++
includes/ReCaptcha/ReCaptcha.php | 117 ++---
includes/ReCaptcha/RequestMethod.php | 18 +-
includes/ReCaptcha/RequestParameters.php | 128 ++---
includes/ReCaptcha/Response.php | 120 +++--
includes/class-admin-notice.php | 36 +-
includes/class-featured-listings-widget.php | 135 ++---
includes/class-listing-import.php | 523 ++++++++++---------
includes/class-listing-template.php | 34 +-
includes/class-listings-search-widget.php | 67 ++-
includes/class-listings.php | 300 ++++++-----
includes/class-taxonomies.php | 546 +++++++++++---------
includes/functions.php | 148 +++---
includes/helpers.php | 120 ++---
includes/recaptcha.php | 63 ++-
includes/shortcodes.php | 84 +--
includes/views/agentevo-metabox.php | 2 +-
includes/views/archive-listing.php | 115 +++--
includes/views/create-tax.php | 24 +-
includes/views/edit-tax.php | 4 +-
includes/views/idx-metabox.php | 2 +-
includes/views/listing-details-metabox.php | 132 ++---
includes/views/listing-features-metabox.php | 15 +-
includes/views/reorder-tax.php | 47 +-
includes/views/single-listing.php | 465 +++++++++--------
includes/views/wp-listings-settings.php | 258 ++++-----
includes/wp-api.php | 198 +++----
phpcs.xml | 24 +
plugin.php | 143 ++---
uninstall.php | 54 +-
31 files changed, 2270 insertions(+), 1808 deletions(-)
create mode 100644 composer.lock
create mode 100644 phpcs.xml
diff --git a/.gitignore b/.gitignore
index 0b9fec5..0d75da9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -233,3 +233,6 @@ pip-log.txt
#Composer
composer.json
+
+
+vendor/*
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..14623b4
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,153 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "81ff4fd6aed1d08f491e16f206291a67",
+ "packages": [],
+ "packages-dev": [
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "3.3.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+ "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e",
+ "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+ },
+ "bin": [
+ "bin/phpcs",
+ "bin/phpcbf"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "lead"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "http://www.squizlabs.com/php-codesniffer",
+ "keywords": [
+ "phpcs",
+ "standards"
+ ],
+ "time": "2018-09-23T23:08:17+00:00"
+ },
+ {
+ "name": "stevegrunwell/wp-enforcer",
+ "version": "v0.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/stevegrunwell/wp-enforcer.git",
+ "reference": "6d583588d06346982b5819066f14675ddc8004d7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/stevegrunwell/wp-enforcer/zipball/6d583588d06346982b5819066f14675ddc8004d7",
+ "reference": "6d583588d06346982b5819066f14675ddc8004d7",
+ "shasum": ""
+ },
+ "require": {
+ "wp-coding-standards/wpcs": "*"
+ },
+ "bin": [
+ "bin/wp-enforcer"
+ ],
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Steve Grunwell",
+ "email": "steve@stevegrunwell.com",
+ "homepage": "https://stevegrunwell.com"
+ }
+ ],
+ "description": "Git hooks to encourage well-written WordPress.",
+ "keywords": [
+ "PHP_CodeSniffer",
+ "coding standards",
+ "git hooks",
+ "wordpress"
+ ],
+ "time": "2017-05-28T18:44:13+00:00"
+ },
+ {
+ "name": "wp-coding-standards/wpcs",
+ "version": "1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
+ "reference": "7aa217ab38156c5cb4eae0f04ae376027c407a9b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/7aa217ab38156c5cb4eae0f04ae376027c407a9b",
+ "reference": "7aa217ab38156c5cb4eae0f04ae376027c407a9b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3",
+ "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
+ },
+ "require-dev": {
+ "phpcompatibility/php-compatibility": "^9.0"
+ },
+ "suggest": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
+ },
+ "type": "phpcodesniffer-standard",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
+ "keywords": [
+ "phpcs",
+ "standards",
+ "wordpress"
+ ],
+ "time": "2018-11-12T10:13:12+00:00"
+ }
+ ],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": [],
+ "platform-dev": []
+}
diff --git a/includes/ReCaptcha/ReCaptcha.php b/includes/ReCaptcha/ReCaptcha.php
index c157dc9..1ca431d 100755
--- a/includes/ReCaptcha/ReCaptcha.php
+++ b/includes/ReCaptcha/ReCaptcha.php
@@ -29,70 +29,71 @@
/**
* reCAPTCHA client.
*/
-class ReCaptcha
-{
- /**
- * Version of this client library.
- * @const string
- */
- const VERSION = 'php_1.1.2';
+class ReCaptcha {
- /**
- * Shared secret for the site.
- * @var string
- */
- private $secret;
+ /**
+ * Version of this client library.
+ *
+ * @const string
+ */
+ const VERSION = 'php_1.1.2';
- /**
- * Method used to communicate with service. Defaults to POST request.
- * @var RequestMethod
- */
- private $requestMethod;
+ /**
+ * Shared secret for the site.
+ *
+ * @var string
+ */
+ private $secret;
- /**
- * Create a configured instance to use the reCAPTCHA service.
- *
- * @param string $secret shared secret between site and reCAPTCHA server.
- * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
- * @throws \RuntimeException if $secret is invalid
- */
- public function __construct($secret, RequestMethod $requestMethod = null)
- {
- if (empty($secret)) {
- throw new \RuntimeException('No secret provided');
- }
+ /**
+ * Method used to communicate with service. Defaults to POST request.
+ *
+ * @var RequestMethod
+ */
+ private $requestMethod;
- if (!is_string($secret)) {
- throw new \RuntimeException('The provided secret must be a string');
- }
+ /**
+ * Create a configured instance to use the reCAPTCHA service.
+ *
+ * @param string $secret shared secret between site and reCAPTCHA server.
+ * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
+ * @throws \RuntimeException if $secret is invalid
+ */
+ public function __construct( $secret, RequestMethod $requestMethod = null ) {
+ if ( empty( $secret ) ) {
+ throw new \RuntimeException( 'No secret provided' );
+ }
- $this->secret = $secret;
+ if ( ! is_string( $secret ) ) {
+ throw new \RuntimeException( 'The provided secret must be a string' );
+ }
- if (!is_null($requestMethod)) {
- $this->requestMethod = $requestMethod;
- } else {
- $this->requestMethod = new RequestMethod\Post();
- }
- }
+ $this->secret = $secret;
- /**
- * Calls the reCAPTCHA siteverify API to verify whether the user passes
- * CAPTCHA test.
- *
- * @param string $response The value of 'g-recaptcha-response' in the submitted form.
- * @param string $remoteIp The end user's IP address.
- * @return Response Response from the service.
- */
- public function verify($response, $remoteIp = null)
- {
- // Discard empty solution submissions
- if (empty($response)) {
- $recaptchaResponse = new Response(false, array('missing-input-response'));
- return $recaptchaResponse;
- }
+ if ( ! is_null( $requestMethod ) ) {
+ $this->requestMethod = $requestMethod;
+ } else {
+ $this->requestMethod = new RequestMethod\Post();
+ }
+ }
- $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
- $rawResponse = $this->requestMethod->submit($params);
- return Response::fromJson($rawResponse);
- }
+ /**
+ * Calls the reCAPTCHA siteverify API to verify whether the user passes
+ * CAPTCHA test.
+ *
+ * @param string $response The value of 'g-recaptcha-response' in the submitted form.
+ * @param string $remoteIp The end user's IP address.
+ * @return Response Response from the service.
+ */
+ public function verify( $response, $remoteIp = null ) {
+ // Discard empty solution submissions
+ if ( empty( $response ) ) {
+ $recaptchaResponse = new Response( false, array( 'missing-input-response' ) );
+ return $recaptchaResponse;
+ }
+
+ $params = new RequestParameters( $this->secret, $response, $remoteIp, self::VERSION );
+ $rawResponse = $this->requestMethod->submit( $params );
+ return Response::fromJson( $rawResponse );
+ }
}
diff --git a/includes/ReCaptcha/RequestMethod.php b/includes/ReCaptcha/RequestMethod.php
index fc4dde5..78fa249 100755
--- a/includes/ReCaptcha/RequestMethod.php
+++ b/includes/ReCaptcha/RequestMethod.php
@@ -29,14 +29,14 @@
/**
* Method used to send the request to the service.
*/
-interface RequestMethod
-{
+interface RequestMethod {
- /**
- * Submit the request with the specified parameters.
- *
- * @param RequestParameters $params Request parameters
- * @return string Body of the reCAPTCHA response
- */
- public function submit(RequestParameters $params);
+
+ /**
+ * Submit the request with the specified parameters.
+ *
+ * @param RequestParameters $params Request parameters
+ * @return string Body of the reCAPTCHA response
+ */
+ public function submit( RequestParameters $params);
}
diff --git a/includes/ReCaptcha/RequestParameters.php b/includes/ReCaptcha/RequestParameters.php
index cb66f26..9d47b58 100755
--- a/includes/ReCaptcha/RequestParameters.php
+++ b/includes/ReCaptcha/RequestParameters.php
@@ -29,75 +29,79 @@
/**
* Stores and formats the parameters for the request to the reCAPTCHA service.
*/
-class RequestParameters
-{
- /**
- * Site secret.
- * @var string
- */
- private $secret;
+class RequestParameters {
- /**
- * Form response.
- * @var string
- */
- private $response;
+ /**
+ * Site secret.
+ *
+ * @var string
+ */
+ private $secret;
- /**
- * Remote user's IP address.
- * @var string
- */
- private $remoteIp;
+ /**
+ * Form response.
+ *
+ * @var string
+ */
+ private $response;
- /**
- * Client version.
- * @var string
- */
- private $version;
+ /**
+ * Remote user's IP address.
+ *
+ * @var string
+ */
+ private $remoteIp;
- /**
- * Initialise parameters.
- *
- * @param string $secret Site secret.
- * @param string $response Value from g-captcha-response form field.
- * @param string $remoteIp User's IP address.
- * @param string $version Version of this client library.
- */
- public function __construct($secret, $response, $remoteIp = null, $version = null)
- {
- $this->secret = $secret;
- $this->response = $response;
- $this->remoteIp = $remoteIp;
- $this->version = $version;
- }
+ /**
+ * Client version.
+ *
+ * @var string
+ */
+ private $version;
- /**
- * Array representation.
- *
- * @return array Array formatted parameters.
- */
- public function toArray()
- {
- $params = array('secret' => $this->secret, 'response' => $this->response);
+ /**
+ * Initialise parameters.
+ *
+ * @param string $secret Site secret.
+ * @param string $response Value from g-captcha-response form field.
+ * @param string $remoteIp User's IP address.
+ * @param string $version Version of this client library.
+ */
+ public function __construct( $secret, $response, $remoteIp = null, $version = null ) {
+ $this->secret = $secret;
+ $this->response = $response;
+ $this->remoteIp = $remoteIp;
+ $this->version = $version;
+ }
- if (!is_null($this->remoteIp)) {
- $params['remoteip'] = $this->remoteIp;
- }
+ /**
+ * Array representation.
+ *
+ * @return array Array formatted parameters.
+ */
+ public function toArray() {
+ $params = array(
+ 'secret' => $this->secret,
+ 'response' => $this->response,
+ );
- if (!is_null($this->version)) {
- $params['version'] = $this->version;
- }
+ if ( ! is_null( $this->remoteIp ) ) {
+ $params['remoteip'] = $this->remoteIp;
+ }
- return $params;
- }
+ if ( ! is_null( $this->version ) ) {
+ $params['version'] = $this->version;
+ }
- /**
- * Query string representation for HTTP request.
- *
- * @return string Query string formatted parameters.
- */
- public function toQueryString()
- {
- return http_build_query($this->toArray(), '', '&');
- }
+ return $params;
+ }
+
+ /**
+ * Query string representation for HTTP request.
+ *
+ * @return string Query string formatted parameters.
+ */
+ public function toQueryString() {
+ return http_build_query( $this->toArray(), '', '&' );
+ }
}
diff --git a/includes/ReCaptcha/Response.php b/includes/ReCaptcha/Response.php
index 111df97..eb482bf 100755
--- a/includes/ReCaptcha/Response.php
+++ b/includes/ReCaptcha/Response.php
@@ -29,74 +29,72 @@
/**
* The response returned from the service.
*/
-class Response
-{
- /**
- * Success or failure.
- * @var boolean
- */
- private $success = false;
+class Response {
- /**
- * Error code strings.
- * @var array
- */
- private $errorCodes = array();
+ /**
+ * Success or failure.
+ *
+ * @var boolean
+ */
+ private $success = false;
- /**
- * Build the response from the expected JSON returned by the service.
- *
- * @param string $json
- * @return \ReCaptcha\Response
- */
- public static function fromJson($json)
- {
- $responseData = json_decode($json, true);
+ /**
+ * Error code strings.
+ *
+ * @var array
+ */
+ private $errorCodes = array();
- if (!$responseData) {
- return new Response(false, array('invalid-json'));
- }
+ /**
+ * Build the response from the expected JSON returned by the service.
+ *
+ * @param string $json
+ * @return \ReCaptcha\Response
+ */
+ public static function fromJson( $json ) {
+ $responseData = json_decode( $json, true );
- if (isset($responseData['success']) && $responseData['success'] == true) {
- return new Response(true);
- }
+ if ( ! $responseData ) {
+ return new Response( false, array( 'invalid-json' ) );
+ }
- if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
- return new Response(false, $responseData['error-codes']);
- }
+ if ( isset( $responseData['success'] ) && $responseData['success'] == true ) {
+ return new Response( true );
+ }
- return new Response(false);
- }
+ if ( isset( $responseData['error-codes'] ) && is_array( $responseData['error-codes'] ) ) {
+ return new Response( false, $responseData['error-codes'] );
+ }
- /**
- * Constructor.
- *
- * @param boolean $success
- * @param array $errorCodes
- */
- public function __construct($success, array $errorCodes = array())
- {
- $this->success = $success;
- $this->errorCodes = $errorCodes;
- }
+ return new Response( false );
+ }
- /**
- * Is success?
- *
- * @return boolean
- */
- public function isSuccess()
- {
- return $this->success;
- }
+ /**
+ * Constructor.
+ *
+ * @param boolean $success
+ * @param array $errorCodes
+ */
+ public function __construct( $success, array $errorCodes = array() ) {
+ $this->success = $success;
+ $this->errorCodes = $errorCodes;
+ }
- /**
- * Get error codes.
- *
- * @return array
- */
- public function getErrorCodes()
- {
- return $this->errorCodes;
- }
+ /**
+ * Is success?
+ *
+ * @return boolean
+ */
+ public function isSuccess() {
+ return $this->success;
+ }
+
+ /**
+ * Get error codes.
+ *
+ * @return array
+ */
+ public function getErrorCodes() {
+ return $this->errorCodes;
+ }
}
diff --git a/includes/class-admin-notice.php b/includes/class-admin-notice.php
index 0a13d8c..c71c1ac 100755
--- a/includes/class-admin-notice.php
+++ b/includes/class-admin-notice.php
@@ -38,7 +38,7 @@ class WP_Listings_Admin_Notice {
*
* @var string
*/
- protected static $nonce_field = '';
+ protected static $nonce_field = '';
/**
* The ignore key
@@ -49,22 +49,22 @@ class WP_Listings_Admin_Notice {
*
* @var string
*/
- protected static $ignore_key = '';
+ protected static $ignore_key = '';
/**
* Output the message
*
* @since 1.3
*
- * @param string $message The text of the message.
- * @param bool $error Optional. Whether to show as error or update. Default is notice.
- * @param string $cap_check Optional. Minimum user capability to show notice to. Default is "activate_plugins"
+ * @param string $message The text of the message.
+ * @param bool $error Optional. Whether to show as error or update. Default is notice.
+ * @param string $cap_check Optional. Minimum user capability to show notice to. Default is "activate_plugins"
* @param string|bool $ignore_key Optional. The user meta key to use for storing if this message has been dismissed by current user or not. If false, it will be generated.
*
* @return string|void Admin notice if is_admin() and not dismissed.
*/
- public static function notice( $message, $error = false, $cap_check = 'activate_plugins', $ignore_key = false ) {
- if ( is_admin() && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) {
+ public static function notice( $message, $error = false, $cap_check = 'activate_plugins', $ignore_key = false ) {
+ if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
if ( current_user_can( $cap_check ) ) {
$user_id = get_current_user_id();
if ( ! is_string( $ignore_key ) ) {
@@ -96,9 +96,7 @@ public static function notice( $message, $error = false, $cap_check = 'activate
return implode( '', $out );
}
-
}
-
}
}
@@ -114,11 +112,15 @@ public static function js_css() {
global $wp_version;
wp_enqueue_style( 'wp-listings-admin-notice', plugin_dir_url( __FILE__ ) . '/includes/css/wp-listings-admin-notice.css' );
wp_enqueue_script( 'wp-listings-admin', plugin_dir_url( __FILE__ ) . '/includes/js/admin.js' );
- wp_localize_script( 'wp-listings-admin', 'wp_listings_adminL10n', array(
- 'nonce' => wp_create_nonce( self::$nonce_action ),
- 'wp_version' => $wp_version,
- 'dismiss' => __( 'Dismiss this notice', 'wp-listings' ),
- ) );
+ wp_localize_script(
+ 'wp-listings-admin',
+ 'wp_listings_adminL10n',
+ array(
+ 'nonce' => wp_create_nonce( self::$nonce_action ),
+ 'wp_version' => $wp_version,
+ 'dismiss' => __( 'Dismiss this notice', 'wp-listings' ),
+ )
+ );
}
/**
@@ -131,12 +133,12 @@ public static function js_css() {
* @return bool
*/
public static function ajax_cb() {
- if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], self::$nonce_action ) ) {
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], self::$nonce_action ) ) {
return false;
}
- $nag = sanitize_key( $_POST[ 'nag' ] );
- if ( $nag === $_POST[ 'nag' ] ) {
+ $nag = sanitize_key( $_POST['nag'] );
+ if ( $nag === $_POST['nag'] ) {
update_user_meta( get_current_user_id(), $nag, true );
}
diff --git a/includes/class-featured-listings-widget.php b/includes/class-featured-listings-widget.php
index f111076..c3c696b 100755
--- a/includes/class-featured-listings-widget.php
+++ b/includes/class-featured-listings-widget.php
@@ -8,8 +8,15 @@
class WP_Listings_Featured_Listings_Widget extends WP_Widget {
function __construct() {
- $widget_ops = array( 'classname' => 'wplistings-featured-listings clearfix', 'description' => __( 'Display grid-style featured listings', 'wp-listings' ), 'customize_selective_refresh' => true );
- $control_ops = array( 'width' => 300, 'height' => 350 );
+ $widget_ops = array(
+ 'classname' => 'wplistings-featured-listings clearfix',
+ 'description' => __( 'Display grid-style featured listings', 'wp-listings' ),
+ 'customize_selective_refresh' => true,
+ );
+ $control_ops = array(
+ 'width' => 300,
+ 'height' => 350,
+ );
parent::__construct( 'wplistings-featured-listings', __( 'IMPress Listings - Featured Listings', 'wp-listings' ), $widget_ops, $control_ops );
}
@@ -19,15 +26,15 @@ function __construct() {
* @param int $number_columns
* @param int $number_items
*/
- function get_column_class($number_columns) {
+ function get_column_class( $number_columns ) {
$column_class = '';
// Max of six columns
- $number_columns = ( $number_columns > 6 ) ? 6 : (int)$number_columns;
+ $number_columns = ( $number_columns > 6 ) ? 6 : (int) $number_columns;
// column class
- switch ($number_columns) {
+ switch ( $number_columns ) {
case 0:
case 1:
$column_class = '';
@@ -56,29 +63,29 @@ function widget( $args, $instance ) {
extract( $args );
- $options = get_option('plugin_wp_listings_settings');
+ $options = get_option( 'plugin_wp_listings_settings' );
- $column_class = $instance['use_columns'] ? $this->get_column_class($instance['number_columns']) : '';
+ $column_class = $instance['use_columns'] ? $this->get_column_class( $instance['number_columns'] ) : '';
echo $before_widget;
- if ( ! empty( $instance['title'] ) ) {
- echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
- }
+ if ( ! empty( $instance['title'] ) ) {
+ echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
+ }
- if ( !empty( $instance['posts_term'] ) ) {
- $posts_term = explode( ',', $instance['posts_term'] );
- }
+ if ( ! empty( $instance['posts_term'] ) ) {
+ $posts_term = explode( ',', $instance['posts_term'] );
+ }
$query_args = array(
- 'post_type' => 'listing',
- 'posts_per_page' => $instance['posts_per_page'],
- 'paged' => get_query_var('paged') ? get_query_var('paged') : 1
+ 'post_type' => 'listing',
+ 'posts_per_page' => $instance['posts_per_page'],
+ 'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1,
);
- if ( !empty( $instance['posts_term'] ) && count($posts_term) == 2 ) {
- $query_args[$posts_term['0']] = $posts_term['1'];
- }
+ if ( ! empty( $instance['posts_term'] ) && count( $posts_term ) == 2 ) {
+ $query_args[ $posts_term['0'] ] = $posts_term['1'];
+ }
$wp_listings_widget_query = new WP_Query( $query_args );
@@ -86,7 +93,9 @@ function widget( $args, $instance ) {
global $post;
- if ( $wp_listings_widget_query->have_posts() ) : while ( $wp_listings_widget_query->have_posts() ) : $wp_listings_widget_query->the_post();
+ if ( $wp_listings_widget_query->have_posts() ) :
+ while ( $wp_listings_widget_query->have_posts() ) :
+ $wp_listings_widget_query->the_post();
$count = ( $count == $instance['number_columns'] ) ? 1 : $count + 1;
@@ -95,7 +104,7 @@ function widget( $args, $instance ) {
$loop = sprintf( '' );
@@ -120,18 +129,19 @@ function widget( $args, $instance ) {
$loop .= sprintf( '%s
', wp_listings_get_address() );
$loop .= sprintf( '%s, %s %s
', wp_listings_get_city(), wp_listings_get_state(), get_post_meta( $post->ID, '_listing_zip', true ) );
- if ( '' != get_post_meta( $post->ID, '_listing_bedrooms', true ) || '' != get_post_meta( $post->ID, '_listing_bathrooms', true ) || '' != get_post_meta( $post->ID, '_listing_sqft', true )) {
+ if ( '' != get_post_meta( $post->ID, '_listing_bedrooms', true ) || '' != get_post_meta( $post->ID, '_listing_bathrooms', true ) || '' != get_post_meta( $post->ID, '_listing_sqft', true ) ) {
$loop .= sprintf( '', get_post_meta( $post->ID, '_listing_bedrooms', true ), get_post_meta( $post->ID, '_listing_bathrooms', true ), get_post_meta( $post->ID, '_listing_sqft', true ) );
}
- $loop .= sprintf('');
+ $loop .= sprintf( '' );
$loop .= sprintf( '%s', get_permalink(), __( 'View Listing', 'wp-listings' ) );
- /** wrap in div with possible column class, and output **/
+ /** wrap in div with possible column class, and output */
printf( '', $column_class . $first_class, $post->ID, apply_filters( 'wp_listings_featured_listings_widget_loop', $loop ) );
- endwhile; endif;
+ endwhile;
+endif;
wp_reset_postdata();
echo $after_widget;
@@ -148,10 +158,10 @@ function widget( $args, $instance ) {
* @return array Updated safe values to be saved.
*/
function update( $new_instance, $old_instance ) {
- $instance = array();
+ $instance = array();
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['posts_per_page'] = (int) $new_instance['posts_per_page'];
- $instance['image_size'] = strip_tags($new_instance['image_size'] );
+ $instance['image_size'] = strip_tags( $new_instance['image_size'] );
$instance['use_columns'] = (int) $new_instance['use_columns'];
$instance['number_columns'] = (int) $new_instance['number_columns'];
$instance['posts_term'] = strip_tags( $new_instance['posts_term'] );
@@ -161,21 +171,24 @@ function update( $new_instance, $old_instance ) {
function form( $instance ) {
- $instance = wp_parse_args( $instance, array(
- 'title' => '',
- 'posts_per_page' => 3,
- 'image_size' => 'listings',
- 'use_columns' => 0,
- 'number_columns' => 3,
- 'posts_term' => ''
- ) );
+ $instance = wp_parse_args(
+ $instance,
+ array(
+ 'title' => '',
+ 'posts_per_page' => 3,
+ 'image_size' => 'listings',
+ 'use_columns' => 0,
+ 'number_columns' => 3,
+ 'posts_term' => '',
+ )
+ );
printf(
'',
- $this->get_field_id('title'),
+ $this->get_field_id( 'title' ),
__( 'Title:', 'wp-listings' ),
- $this->get_field_id('title'),
- $this->get_field_name('title'),
+ $this->get_field_id( 'title' ),
+ $this->get_field_name( 'title' ),
esc_attr( $instance['title'] ),
'width: 95%;'
); ?>
@@ -186,8 +199,9 @@ function form( $instance ) {
$size )
- echo '';
+ foreach ( (array) $sizes as $name => $size ) {
+ echo '';
+ }
?>
@@ -196,47 +210,48 @@ function form( $instance ) {
printf(
'%s
',
__( 'How many results should be returned?', 'wp-listings' ),
- $this->get_field_name('posts_per_page'),
+ $this->get_field_name( 'posts_per_page' ),
esc_attr( $instance['posts_per_page'] )
);
- echo '
+ echo '
-
';
?>
- id="get_field_id( 'use_columns' ); ?>" name="get_field_name( 'use_columns' ); ?>" value="1" />
+ id="get_field_id( 'use_columns' ); ?>" name="get_field_name( 'use_columns' ); ?>" value="1" />
-
-
-
-
-
+
+
+
+
+
diff --git a/includes/class-listing-import.php b/includes/class-listing-import.php
index c962a5c..fa4dadb 100755
--- a/includes/class-listing-import.php
+++ b/includes/class-listing-import.php
@@ -4,7 +4,9 @@
* to import listing data
*/
-if ( ! defined( 'ABSPATH' ) ) exit;
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
class WPL_Idx_Listing {
public $_idx;
@@ -13,31 +15,39 @@ public function __construct() {
}
/**
- * Function to get the array key (listingID+mlsID)
+ * Function to get the array key (listingID+mlsID)
+ *
* @param [type] $array [description]
* @param [type] $key [description]
* @param [type] $needle [description]
* @return [type] [description]
*/
- public static function get_key($array, $key, $needle) {
- if(!$array) return false;
- foreach($array as $index => $value) {
- if($value[$key] == $needle) return $index;
+ public static function get_key( $array, $key, $needle ) {
+ if ( ! $array ) {
+ return false;
+ }
+ foreach ( $array as $index => $value ) {
+ if ( $value[ $key ] == $needle ) {
+ return $index;
+ }
}
return false;
}
/**
* Function to find the key in the array
+ *
* @param [type] $needle [description]
* @param [type] $haystack [description]
* @param boolean $strict [description]
* @return [type] [description]
*/
- public static function in_array($needle, $haystack, $strict = false) {
- if(!$haystack) return false;
- foreach ($haystack as $item) {
- if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && self::in_array($needle, $item, $strict))) {
+ public static function in_array( $needle, $haystack, $strict = false ) {
+ if ( ! $haystack ) {
+ return false;
+ }
+ foreach ( $haystack as $item ) {
+ if ( ( $strict ? $item === $needle : $item == $needle ) || ( is_array( $item ) && self::in_array( $needle, $item, $strict ) ) ) {
return true;
}
}
@@ -46,300 +56,306 @@ public static function in_array($needle, $haystack, $strict = false) {
/**
* Creates a post of listing type using post data from options page
+ *
* @param array $listings listingID of the property
* @return [type] $featured [description]
*/
- public static function wp_listings_idx_create_post($listings) {
- if(class_exists( 'IDX_Broker_Plugin')) {
- require_once(ABSPATH . 'wp-content/plugins/idx-broker-platinum/idx/idx-api.php');
+ public static function wp_listings_idx_create_post( $listings ) {
+ if ( class_exists( 'IDX_Broker_Plugin' ) ) {
+ require_once ABSPATH . 'wp-content/plugins/idx-broker-platinum/idx/idx-api.php';
// Load Equity API if it exists
- if(class_exists( 'Equity_Idx_Api' )) {
- require_once(ABSPATH . 'wp-content/themes/equity/lib/idx/class.Equity_Idx_Api.inc.php');
- $_equity_idx = new Equity_Idx_Api;
+ if ( class_exists( 'Equity_Idx_Api' ) ) {
+ require_once ABSPATH . 'wp-content/themes/equity/lib/idx/class.Equity_Idx_Api.inc.php';
+ $_equity_idx = new Equity_Idx_Api();
}
// Load IDX Broker API Class and retrieve featured properties
- $_idx_api = new \IDX\Idx_Api();
- $properties = $_idx_api->client_properties('featured?disclaimers=true');
+ $_idx_api = new \IDX\Idx_Api();
+ $properties = $_idx_api->client_properties( 'featured?disclaimers=true' );
// Load WP options
- $idx_featured_listing_wp_options = get_option('wp_listings_idx_featured_listing_wp_options');
- $wpl_options = get_option('plugin_wp_listings_settings');
- update_option('wp_listings_import_progress', true);
+ $idx_featured_listing_wp_options = get_option( 'wp_listings_idx_featured_listing_wp_options' );
+ $wpl_options = get_option( 'plugin_wp_listings_settings' );
+ update_option( 'wp_listings_import_progress', true );
- if( is_array($listings) && is_array($properties) ) {
+ if ( is_array( $listings ) && is_array( $properties ) ) {
// Loop through featured properties
- foreach($properties as $prop) {
+ foreach ( $properties as $prop ) {
// Get the listing ID
- $key = self::get_key($properties, 'listingID', $prop['listingID']);
+ $key = self::get_key( $properties, 'listingID', $prop['listingID'] );
// Add options
- if(!in_array($prop['listingID'], $listings)) {
- $idx_featured_listing_wp_options[$prop['listingID']]['listingID'] = $prop['listingID'];
- $idx_featured_listing_wp_options[$prop['listingID']]['status'] = '';
+ if ( ! in_array( $prop['listingID'], $listings ) ) {
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['listingID'] = $prop['listingID'];
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] = '';
}
// Unset options if they don't exist
- if(isset($idx_featured_listing_wp_options[$prop['listingID']]['post_id']) && !get_post($idx_featured_listing_wp_options[$prop['listingID']]['post_id'])) {
- unset($idx_featured_listing_wp_options[$prop['listingID']]['post_id']);
- unset($idx_featured_listing_wp_options[$prop['listingID']]['status']);
- }
+ if ( isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) && ! get_post( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) ) {
+ unset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] );
+ unset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] );
+ }
- // Add post and update post meta
- if(in_array($prop['listingID'], $listings) && !isset($idx_featured_listing_wp_options[$prop['listingID']]['post_id'])) {
+ // Add post and update post meta
+ if ( in_array( $prop['listingID'], $listings ) && ! isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) ) {
// Get Equity listing API data if available
- if(class_exists( 'Equity_Idx_Api' )) {
- $equity_properties = $_equity_idx->equity_listing_ID($prop['idxID'], $prop['listingID']);
+ if ( class_exists( 'Equity_Idx_Api' ) ) {
+ $equity_properties = $_equity_idx->equity_listing_ID( $prop['idxID'], $prop['listingID'] );
- if($equity_properties == false) {
- add_settings_error('wp_listings_idx_listing_settings_group', 'idx_listing_empty', 'The Equity API returned no data for property ' . $prop['listingID'] . '. This is usually caused by your WordPress domain not matching the approved domain in your IDX account. Only some data has been imported.', 'error');
- $equity_properties = $properties[$key];
- delete_transient('equity_listing_' . $prop['listingID']);
+ if ( $equity_properties == false ) {
+ add_settings_error( 'wp_listings_idx_listing_settings_group', 'idx_listing_empty', 'The Equity API returned no data for property ' . $prop['listingID'] . '. This is usually caused by your WordPress domain not matching the approved domain in your IDX account. Only some data has been imported.', 'error' );
+ $equity_properties = $properties[ $key ];
+ delete_transient( 'equity_listing_' . $prop['listingID'] );
}
}
- if ($properties[$key]['address'] == '' || $properties[$key]['address'] == null) {
- $properties[$key]['address'] = 'Address unlisted';
+ if ( $properties[ $key ]['address'] == '' || $properties[ $key ]['address'] == null ) {
+ $properties[ $key ]['address'] = 'Address unlisted';
}
- if ($properties[$key]['remarksConcat'] == '' || $properties[$key]['remarksConcat'] == null) {
- $properties[$key]['remarksConcat'] = $properties[$key]['listingID'];
+ if ( $properties[ $key ]['remarksConcat'] == '' || $properties[ $key ]['remarksConcat'] == null ) {
+ $properties[ $key ]['remarksConcat'] = $properties[ $key ]['listingID'];
}
- if(empty($wpl_options['wp_listings_import_title'])) {
- $title_format = $properties[$key]['address'];
+ if ( empty( $wpl_options['wp_listings_import_title'] ) ) {
+ $title_format = $properties[ $key ]['address'];
} else {
$title_format = $wpl_options['wp_listings_import_title'];
- $title_format = str_replace('{{address}}', $properties[$key]['address'], $title_format);
- $title_format = str_replace('{{city}}', $properties[$key]['cityName'], $title_format);
- $title_format = str_replace('{{state}}', $properties[$key]['state'], $title_format);
- $title_format = str_replace('{{zipcode}}', $properties[$key]['zipcode'], $title_format);
- $title_format = str_replace('{{listingid}}', $properties[$key]['listingID'], $title_format);
+ $title_format = str_replace( '{{address}}', $properties[ $key ]['address'], $title_format );
+ $title_format = str_replace( '{{city}}', $properties[ $key ]['cityName'], $title_format );
+ $title_format = str_replace( '{{state}}', $properties[ $key ]['state'], $title_format );
+ $title_format = str_replace( '{{zipcode}}', $properties[ $key ]['zipcode'], $title_format );
+ $title_format = str_replace( '{{listingid}}', $properties[ $key ]['listingID'], $title_format );
}
// Post creation options
$opts = array(
- 'post_content' => $properties[$key]['remarksConcat'],
- 'post_title' => $title_format,
- 'post_status' => 'publish',
- 'post_type' => 'listing',
- 'post_author' => (isset($wpl_options['import_author'])) ? $wpl_options['import_author'] : 1
+ 'post_content' => $properties[ $key ]['remarksConcat'],
+ 'post_title' => $title_format,
+ 'post_status' => 'publish',
+ 'post_type' => 'listing',
+ 'post_author' => ( isset( $wpl_options['import_author'] ) ) ? $wpl_options['import_author'] : 1,
);
// Add the post
- $add_post = wp_insert_post($opts, true);
+ $add_post = wp_insert_post( $opts, true );
// Show error if wp_insert_post fails
// add post meta and update options if success
- if (is_wp_error($add_post)) {
+ if ( is_wp_error( $add_post ) ) {
$error_string = $add_post->get_error_message();
- add_settings_error('wp_listings_idx_listing_settings_group', 'insert_post_failed', 'WordPress failed to insert the post. Error ' . $error_string, 'error');
- } elseif($add_post) {
- $idx_featured_listing_wp_options[$prop['listingID']]['post_id'] = $add_post;
- $idx_featured_listing_wp_options[$prop['listingID']]['status'] = 'publish';
- update_post_meta($add_post, '_listing_details_url', $properties[$key]['fullDetailsURL']);
+ add_settings_error( 'wp_listings_idx_listing_settings_group', 'insert_post_failed', 'WordPress failed to insert the post. Error ' . $error_string, 'error' );
+ } elseif ( $add_post ) {
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] = $add_post;
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] = 'publish';
+ update_post_meta( $add_post, '_listing_details_url', $properties[ $key ]['fullDetailsURL'] );
// Use custom default template if set
- if(isset($wpl_options['wp_listings_default_template']) && $wpl_options['wp_listings_default_template'] != '') {
- update_post_meta($add_post, '_wp_post_template', $wpl_options['wp_listings_default_template']);
+ if ( isset( $wpl_options['wp_listings_default_template'] ) && $wpl_options['wp_listings_default_template'] != '' ) {
+ update_post_meta( $add_post, '_wp_post_template', $wpl_options['wp_listings_default_template'] );
}
- if(class_exists( 'Equity_Idx_Api' )) {
- self::wp_listings_idx_insert_post_meta($add_post, $equity_properties);
+ if ( class_exists( 'Equity_Idx_Api' ) ) {
+ self::wp_listings_idx_insert_post_meta( $add_post, $equity_properties );
} else {
- self::wp_listings_idx_insert_post_meta($add_post, $properties[$key]);
+ self::wp_listings_idx_insert_post_meta( $add_post, $properties[ $key ] );
}
}
}
// Change status to publish if it's not already
- elseif( in_array($prop['listingID'], $listings) && $idx_featured_listing_wp_options[$prop['listingID']]['status'] != 'publish' ) {
- self::wp_listings_idx_change_post_status($idx_featured_listing_wp_options[$prop['listingID']]['post_id'], 'publish');
- $idx_featured_listing_wp_options[$prop['listingID']]['status'] = 'publish';
+ elseif ( in_array( $prop['listingID'], $listings ) && $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] != 'publish' ) {
+ self::wp_listings_idx_change_post_status( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'], 'publish' );
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] = 'publish';
}
// Change post status or delete post based on options
- elseif( !in_array($prop['listingID'], $listings) && isset($idx_featured_listing_wp_options[$prop['listingID']]['status']) && $idx_featured_listing_wp_options[$prop['listingID']]['status'] == 'publish' ) {
+ elseif ( ! in_array( $prop['listingID'], $listings ) && isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] ) && $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] == 'publish' ) {
// Change to draft or delete listing if the post exists but is not in the listing array based on settings
- if(isset($wpl_options['wp_listings_idx_sold']) && $wpl_options['wp_listings_idx_sold'] == 'sold-draft') {
+ if ( isset( $wpl_options['wp_listings_idx_sold'] ) && $wpl_options['wp_listings_idx_sold'] == 'sold-draft' ) {
// Change to draft
- self::wp_listings_idx_change_post_status($idx_featured_listing_wp_options[$prop['listingID']]['post_id'], 'draft');
- $idx_featured_listing_wp_options[$prop['listingID']]['status'] = 'draft';
- } elseif(isset($wpl_options['wp_listings_idx_sold']) && $wpl_options['wp_listings_idx_sold'] == 'sold-delete') {
+ self::wp_listings_idx_change_post_status( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'], 'draft' );
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] = 'draft';
+ } elseif ( isset( $wpl_options['wp_listings_idx_sold'] ) && $wpl_options['wp_listings_idx_sold'] == 'sold-delete' ) {
- $idx_featured_listing_wp_options[$prop['listingID']]['status'] = 'deleted';
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] = 'deleted';
// Delete featured image
- $post_featured_image_id = get_post_thumbnail_id( $idx_featured_listing_wp_options[$prop['listingID']]['post_id'] );
+ $post_featured_image_id = get_post_thumbnail_id( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] );
wp_delete_attachment( $post_featured_image_id );
- //Delete post
- wp_delete_post( $idx_featured_listing_wp_options[$prop['listingID']]['post_id'] );
+ // Delete post
+ wp_delete_post( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] );
}
}
}
}
// Lastly update our options
- update_option('wp_listings_idx_featured_listing_wp_options', $idx_featured_listing_wp_options);
- delete_option('wp_listings_import_progress');
+ update_option( 'wp_listings_idx_featured_listing_wp_options', $idx_featured_listing_wp_options );
+ delete_option( 'wp_listings_import_progress' );
return $idx_featured_listing_wp_options;
}
}
/**
* Update existing post
+ *
* @return true if success
*/
public static function wp_listings_update_post() {
- require_once(ABSPATH . 'wp-content/plugins/idx-broker-platinum/idx/idx-api.php');
+ require_once ABSPATH . 'wp-content/plugins/idx-broker-platinum/idx/idx-api.php';
// Load IDX Broker API Class and retrieve featured properties
- $_idx_api = new \IDX\Idx_Api();
- $properties = $_idx_api->client_properties('featured?disclaimers=true');
+ $_idx_api = new \IDX\Idx_Api();
+ $properties = $_idx_api->client_properties( 'featured?disclaimers=true' );
// Load WP options
- $idx_featured_listing_wp_options = get_option('wp_listings_idx_featured_listing_wp_options');
- $wpl_options = get_option('plugin_wp_listings_settings');
+ $idx_featured_listing_wp_options = get_option( 'wp_listings_idx_featured_listing_wp_options' );
+ $wpl_options = get_option( 'plugin_wp_listings_settings' );
foreach ( $properties as $prop ) {
- $key = self::get_key($properties, 'listingID', $prop['listingID']);
+ $key = self::get_key( $properties, 'listingID', $prop['listingID'] );
- if( isset($idx_featured_listing_wp_options[$prop['listingID']]['post_id']) ) {
+ if ( isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) ) {
// Update property data
- if(class_exists( 'Equity_Idx_Api' )) {
- require_once(ABSPATH . 'wp-content/themes/equity/lib/idx/class.Equity_Idx_Api.inc.php');
- $_equity_idx = new Equity_Idx_Api;
- $equity_properties = $_equity_idx->equity_listing_ID($prop['idxID'], $prop['listingID']);
- if($equity_properties == false) {
- $equity_properties = $properties[$key];
- delete_transient('equity_listing_' . $prop['listingID']);
+ if ( class_exists( 'Equity_Idx_Api' ) ) {
+ require_once ABSPATH . 'wp-content/themes/equity/lib/idx/class.Equity_Idx_Api.inc.php';
+ $_equity_idx = new Equity_Idx_Api();
+ $equity_properties = $_equity_idx->equity_listing_ID( $prop['idxID'], $prop['listingID'] );
+ if ( $equity_properties == false ) {
+ $equity_properties = $properties[ $key ];
+ delete_transient( 'equity_listing_' . $prop['listingID'] );
+ }
+ if ( ! isset( $wpl_options['wp_listings_idx_update'] ) || isset( $wpl_options['wp_listings_idx_update'] ) && $wpl_options['wp_listings_idx_update'] != 'update-none' ) {
+ self::wp_listings_idx_insert_post_meta( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'], $equity_properties, true, ( $wpl_options['wp_listings_idx_update'] == 'update-noimage' ) ? false : true, false );
}
- if(!isset($wpl_options['wp_listings_idx_update']) || isset($wpl_options['wp_listings_idx_update']) && $wpl_options['wp_listings_idx_update'] != 'update-none')
- self::wp_listings_idx_insert_post_meta($idx_featured_listing_wp_options[$prop['listingID']]['post_id'], $equity_properties, true, ($wpl_options['wp_listings_idx_update'] == 'update-noimage') ? false : true, false );
- $idx_featured_listing_wp_options[$prop['listingID']]['updated'] = date("m/d/Y h:i:sa");
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['updated'] = date( 'm/d/Y h:i:sa' );
} else {
- if(!isset($wpl_options['wp_listings_idx_update']) || isset($wpl_options['wp_listings_idx_update']) && $wpl_options['wp_listings_idx_update'] != 'update-none')
- self::wp_listings_idx_insert_post_meta($idx_featured_listing_wp_options[$prop['listingID']]['post_id'], $properties[$key], true, ($wpl_options['wp_listings_idx_update'] == 'update-noimage') ? false : true, false );
- $idx_featured_listing_wp_options[$prop['listingID']]['updated'] = date("m/d/Y h:i:sa");
+ if ( ! isset( $wpl_options['wp_listings_idx_update'] ) || isset( $wpl_options['wp_listings_idx_update'] ) && $wpl_options['wp_listings_idx_update'] != 'update-none' ) {
+ self::wp_listings_idx_insert_post_meta( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'], $properties[ $key ], true, ( $wpl_options['wp_listings_idx_update'] == 'update-noimage' ) ? false : true, false );
+ }
+ $idx_featured_listing_wp_options[ $prop['listingID'] ]['updated'] = date( 'm/d/Y h:i:sa' );
}
}
-
}
// Load and loop through Sold properties
- $sold_properties = $_idx_api->client_properties('soldpending');
+ $sold_properties = $_idx_api->client_properties( 'soldpending' );
foreach ( $sold_properties as $sold_prop ) {
- $key = self::get_key($sold_properties, 'listingID', $sold_prop['listingID']);
+ $key = self::get_key( $sold_properties, 'listingID', $sold_prop['listingID'] );
- if( isset($idx_featured_listing_wp_options[$sold_prop['listingID']]['post_id']) ) {
+ if ( isset( $idx_featured_listing_wp_options[ $sold_prop['listingID'] ]['post_id'] ) ) {
// Update property data
- self::wp_listings_idx_insert_post_meta($idx_featured_listing_wp_options[$sold_prop['listingID']]['post_id'], $sold_properties[$key], true, ($wpl_options['wp_listings_idx_update'] == 'update-noimage') ? false : true, true );
+ self::wp_listings_idx_insert_post_meta( $idx_featured_listing_wp_options[ $sold_prop['listingID'] ]['post_id'], $sold_properties[ $key ], true, ( $wpl_options['wp_listings_idx_update'] == 'update-noimage' ) ? false : true, true );
- if(isset($wpl_options['wp_listings_idx_sold']) && $wpl_options['wp_listings_idx_sold'] == 'sold-draft') {
+ if ( isset( $wpl_options['wp_listings_idx_sold'] ) && $wpl_options['wp_listings_idx_sold'] == 'sold-draft' ) {
// Change to draft
- self::wp_listings_idx_change_post_status($idx_featured_listing_wp_options[$sold_prop['listingID']]['post_id'], 'draft');
- } elseif(isset($wpl_options['wp_listings_idx_sold']) && $wpl_options['wp_listings_idx_sold'] == 'sold-delete') {
+ self::wp_listings_idx_change_post_status( $idx_featured_listing_wp_options[ $sold_prop['listingID'] ]['post_id'], 'draft' );
+ } elseif ( isset( $wpl_options['wp_listings_idx_sold'] ) && $wpl_options['wp_listings_idx_sold'] == 'sold-delete' ) {
// Delete featured image
- $post_featured_image_id = get_post_thumbnail_id( $idx_featured_listing_wp_options[$sold_prop['listingID']]['post_id'] );
+ $post_featured_image_id = get_post_thumbnail_id( $idx_featured_listing_wp_options[ $sold_prop['listingID'] ]['post_id'] );
wp_delete_attachment( $post_featured_image_id );
- //Delete post
- wp_delete_post( $idx_featured_listing_wp_options[$sold_prop['listingID']]['post_id'] );
+ // Delete post
+ wp_delete_post( $idx_featured_listing_wp_options[ $sold_prop['listingID'] ]['post_id'] );
}
}
-
}
- update_option('wp_listings_idx_featured_listing_wp_options', $idx_featured_listing_wp_options);
+ update_option( 'wp_listings_idx_featured_listing_wp_options', $idx_featured_listing_wp_options );
}
/**
* Change post status
+ *
* @param [type] $post_id [description]
* @param [type] $status [description]
* @return [type] [description]
*/
- public static function wp_listings_idx_change_post_status($post_id, $status){
- $current_post = get_post( $post_id, 'ARRAY_A' );
- $current_post['post_status'] = $status;
- wp_update_post($current_post);
+ public static function wp_listings_idx_change_post_status( $post_id, $status ) {
+ $current_post = get_post( $post_id, 'ARRAY_A' );
+ $current_post['post_status'] = $status;
+ wp_update_post( $current_post );
}
/**
* Inserts post meta based on property data
* API fields are mapped to post meta fields
* prefixed with _listing_ and lowercased
+ *
* @param [type] $id [description]
* @param [type] $key [description]
* @return [type] [description]
*/
- public static function wp_listings_idx_insert_post_meta($id, $idx_featured_listing_data, $update = false, $update_image = true, $sold = false) {
+ public static function wp_listings_idx_insert_post_meta( $id, $idx_featured_listing_data, $update = false, $update_image = true, $sold = false ) {
- if ($update == false || $update_image == true) {
- $imgs = '';
+ if ( $update == false || $update_image == true ) {
+ $imgs = '';
$featured_image = $idx_featured_listing_data['image']['0']['url'];
- foreach ($idx_featured_listing_data['image'] as $image_data => $img) {
- if($image_data == "totalCount") continue;
- $img_markup = sprintf('
', $img['url'], $idx_featured_listing_data['address']);
- $imgs .= apply_filters( 'wp_listings_imported_image_markup', $img_markup, $img, $idx_featured_listing_data );
+ foreach ( $idx_featured_listing_data['image'] as $image_data => $img ) {
+ if ( $image_data == 'totalCount' ) {
+ continue;
+ }
+ $img_markup = sprintf( '
', $img['url'], $idx_featured_listing_data['address'] );
+ $imgs .= apply_filters( 'wp_listings_imported_image_markup', $img_markup, $img, $idx_featured_listing_data );
}
- update_post_meta($id, '_listing_gallery', apply_filters('wp_listings_imported_gallery', $imgs));
+ update_post_meta( $id, '_listing_gallery', apply_filters( 'wp_listings_imported_gallery', $imgs ) );
}
if ( $idx_featured_listing_data['propStatus'] == 'A' ) {
$propstatus = 'Active';
- } elseif( $idx_featured_listing_data['propStatus'] == 'S' ) {
+ } elseif ( $idx_featured_listing_data['propStatus'] == 'S' ) {
$propstatus = 'Sold';
} else {
$propstatus = ucfirst( $idx_featured_listing_data['propStatus'] );
}
// Add or reset taxonomies for property-types, locations, and status
- wp_set_object_terms($id, $idx_featured_listing_data['idxPropType'], 'property-types', true);
- wp_set_object_terms($id, $idx_featured_listing_data['cityName'], 'locations', true);
- wp_set_object_terms($id, $propstatus, 'status', false);
+ wp_set_object_terms( $id, $idx_featured_listing_data['idxPropType'], 'property-types', true );
+ wp_set_object_terms( $id, $idx_featured_listing_data['cityName'], 'locations', true );
+ wp_set_object_terms( $id, $propstatus, 'status', false );
// Add post meta for existing WPL fields
- update_post_meta($id, '_listing_lot_sqft', isset($idx_featured_listing_data['lotSqFt']) ? $idx_featured_listing_data['lotSqFt'] : $idx_featured_listing_data['acres'].' acres');
- update_post_meta($id, '_listing_acres', $idx_featured_listing_data['acres']);
- update_post_meta($id, '_listing_price', $idx_featured_listing_data['listingPrice']);
- update_post_meta($id, '_listing_address', $idx_featured_listing_data['address']);
- update_post_meta($id, '_listing_city', $idx_featured_listing_data['cityName']);
- update_post_meta($id, '_listing_county', $idx_featured_listing_data['countyName']);
- update_post_meta($id, '_listing_state', $idx_featured_listing_data['state']);
- update_post_meta($id, '_listing_zip', $idx_featured_listing_data['zipcode']);
- update_post_meta($id, '_listing_mls', $idx_featured_listing_data['listingID']);
- update_post_meta($id, '_listing_sqft', $idx_featured_listing_data['sqFt']);
- update_post_meta($id, '_listing_year_built', (isset($idx_featured_listing_data['yearBuilt'])) ? $idx_featured_listing_data['yearBuilt'] : '');
- update_post_meta($id, '_listing_bedrooms', $idx_featured_listing_data['bedrooms']);
- update_post_meta($id, '_listing_bathrooms', $idx_featured_listing_data['totalBaths']);
- update_post_meta($id, '_listing_half_bath', $idx_featured_listing_data['partialBaths']);
+ update_post_meta( $id, '_listing_lot_sqft', isset( $idx_featured_listing_data['lotSqFt'] ) ? $idx_featured_listing_data['lotSqFt'] : $idx_featured_listing_data['acres'] . ' acres' );
+ update_post_meta( $id, '_listing_acres', $idx_featured_listing_data['acres'] );
+ update_post_meta( $id, '_listing_price', $idx_featured_listing_data['listingPrice'] );
+ update_post_meta( $id, '_listing_address', $idx_featured_listing_data['address'] );
+ update_post_meta( $id, '_listing_city', $idx_featured_listing_data['cityName'] );
+ update_post_meta( $id, '_listing_county', $idx_featured_listing_data['countyName'] );
+ update_post_meta( $id, '_listing_state', $idx_featured_listing_data['state'] );
+ update_post_meta( $id, '_listing_zip', $idx_featured_listing_data['zipcode'] );
+ update_post_meta( $id, '_listing_mls', $idx_featured_listing_data['listingID'] );
+ update_post_meta( $id, '_listing_sqft', $idx_featured_listing_data['sqFt'] );
+ update_post_meta( $id, '_listing_year_built', ( isset( $idx_featured_listing_data['yearBuilt'] ) ) ? $idx_featured_listing_data['yearBuilt'] : '' );
+ update_post_meta( $id, '_listing_bedrooms', $idx_featured_listing_data['bedrooms'] );
+ update_post_meta( $id, '_listing_bathrooms', $idx_featured_listing_data['totalBaths'] );
+ update_post_meta( $id, '_listing_half_bath', $idx_featured_listing_data['partialBaths'] );
// Add post meta for Equity API fields
- if (class_exists( 'Equity_Idx_Api' )) {
- foreach ($idx_featured_listing_data as $metakey => $metavalue) {
- if ($update == true && $metakey != 'price') {
- delete_post_meta($id, '_listing_' . strtolower($metakey));
+ if ( class_exists( 'Equity_Idx_Api' ) ) {
+ foreach ( $idx_featured_listing_data as $metakey => $metavalue ) {
+ if ( $update == true && $metakey != 'price' ) {
+ delete_post_meta( $id, '_listing_' . strtolower( $metakey ) );
}
- if(isset($metavalue) && !is_array($metavalue) && $metavalue != '' && $metakey != 'price') {
- update_post_meta($id, '_listing_' . strtolower($metakey), $metavalue);
- } elseif(isset( $metavalue ) && is_array( $metavalue )) {
- foreach ($metavalue as $key => $value) {
- if(get_post_meta($id, '_listing_' . strtolower($metakey)) && $metakey != 'images' && $metakey != 'disclaimer' && $metakey != 'courtesy') {
- $oldvalue = get_post_meta($id, '_listing_' . strtolower($metakey), true);
+ if ( isset( $metavalue ) && ! is_array( $metavalue ) && $metavalue != '' && $metakey != 'price' ) {
+ update_post_meta( $id, '_listing_' . strtolower( $metakey ), $metavalue );
+ } elseif ( isset( $metavalue ) && is_array( $metavalue ) ) {
+ foreach ( $metavalue as $key => $value ) {
+ if ( get_post_meta( $id, '_listing_' . strtolower( $metakey ) ) && $metakey != 'images' && $metakey != 'disclaimer' && $metakey != 'courtesy' ) {
+ $oldvalue = get_post_meta( $id, '_listing_' . strtolower( $metakey ), true );
$newvalue = $value . ', ' . $oldvalue;
- update_post_meta($id, '_listing_' . strtolower($metakey), $newvalue);
- } elseif($metakey != 'images') {
- update_post_meta($id, '_listing_' . strtolower($metakey), $value);
+ update_post_meta( $id, '_listing_' . strtolower( $metakey ), $newvalue );
+ } elseif ( $metakey != 'images' ) {
+ update_post_meta( $id, '_listing_' . strtolower( $metakey ), $value );
}
}
}
@@ -347,34 +363,34 @@ public static function wp_listings_idx_insert_post_meta($id, $idx_featured_listi
}
// Add disclaimers and courtesies
- foreach($idx_featured_listing_data['disclaimer'] as $disclaimer) {
- if(in_array('details', $disclaimer)) {
- $disclaimer_logo = ($disclaimer['logoURL']) ? '
' : '';
+ foreach ( $idx_featured_listing_data['disclaimer'] as $disclaimer ) {
+ if ( in_array( 'details', $disclaimer ) ) {
+ $disclaimer_logo = ( $disclaimer['logoURL'] ) ? '
' : '';
$disclaimer_combined = $disclaimer['text'] . $disclaimer_logo;
- update_post_meta($id, '_listing_disclaimer', $disclaimer_combined);
+ update_post_meta( $id, '_listing_disclaimer', $disclaimer_combined );
}
- if(in_array('widget', $disclaimer)) {
- $disclaimer_logo = ($disclaimer['logoURL']) ? '
' : '';
+ if ( in_array( 'widget', $disclaimer ) ) {
+ $disclaimer_logo = ( $disclaimer['logoURL'] ) ? '
' : '';
$disclaimer_combined = $disclaimer['text'] . $disclaimer_logo;
- update_post_meta($id, '_listing_disclaimer_widget', $disclaimer_combined);
+ update_post_meta( $id, '_listing_disclaimer_widget', $disclaimer_combined );
}
}
- foreach($idx_featured_listing_data['courtesy'] as $courtesy) {
- if(in_array('details', $courtesy)) {
- update_post_meta($id, '_listing_courtesy', $courtesy['text']);
+ foreach ( $idx_featured_listing_data['courtesy'] as $courtesy ) {
+ if ( in_array( 'details', $courtesy ) ) {
+ update_post_meta( $id, '_listing_courtesy', $courtesy['text'] );
}
- if(in_array('widget', $courtesy)) {
- update_post_meta($id, '_listing_courtesy_widget', $courtesy['text']);
+ if ( in_array( 'widget', $courtesy ) ) {
+ update_post_meta( $id, '_listing_courtesy_widget', $courtesy['text'] );
}
}
/**
* Pull featured image if it's not an update or update image is set to true
*/
- if($update == false || $update_image == true) {
+ if ( $update == false || $update_image == true ) {
// Delete previously attached image
- if($update_image == true) {
+ if ( $update_image == true ) {
$post_featured_image_id = get_post_thumbnail_id( $id );
wp_delete_attachment( $post_featured_image_id );
}
@@ -382,19 +398,20 @@ public static function wp_listings_idx_insert_post_meta($id, $idx_featured_listi
// Add Featured Image to Post
$image_url = $featured_image; // Define the image URL here
$upload_dir = wp_upload_dir(); // Set upload folder
- $image_data = file_get_contents($image_url); // Get image data
- $filename = basename($image_url.'/' . $idx_featured_listing_data['listingID'] . '.jpg'); // Create image file name
+ $image_data = file_get_contents( $image_url ); // Get image data
+ $filename = basename( $image_url . '/' . $idx_featured_listing_data['listingID'] . '.jpg' ); // Create image file name
// Check folder permission and define file location
- if( wp_mkdir_p( $upload_dir['path'] ) ) {
+ if ( wp_mkdir_p( $upload_dir['path'] ) ) {
$file = $upload_dir['path'] . '/' . $filename;
} else {
$file = $upload_dir['basedir'] . '/' . $filename;
}
// Create the image file on the server
- if(!file_exists($file))
+ if ( ! file_exists( $file ) ) {
file_put_contents( $file, $image_data );
+ }
// Check image file type
$wp_filetype = wp_check_filetype( $filename, null );
@@ -404,14 +421,14 @@ public static function wp_listings_idx_insert_post_meta($id, $idx_featured_listi
'post_mime_type' => $wp_filetype['type'],
'post_title' => $idx_featured_listing_data['listingID'] . ' - ' . $idx_featured_listing_data['address'],
'post_content' => '',
- 'post_status' => 'inherit'
+ 'post_status' => 'inherit',
);
// Create the attachment
$attach_id = wp_insert_attachment( $attachment, $file, $id );
// Include image.php
- require_once(ABSPATH . 'wp-admin/includes/image.php');
+ require_once ABSPATH . 'wp-admin/includes/image.php';
// Define attachment metadata
$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
@@ -435,29 +452,30 @@ public static function wp_listings_idx_insert_post_meta($id, $idx_featured_listi
* Enqueues scripts for display
* Deletes post and post thumbnail via ajax
*/
-add_action( 'admin_menu', 'wp_listings_idx_listing_register_menu_page');
+add_action( 'admin_menu', 'wp_listings_idx_listing_register_menu_page' );
function wp_listings_idx_listing_register_menu_page() {
add_submenu_page( 'edit.php?post_type=listing', __( 'Import IDX Listings', 'wp-listings' ), __( 'Import IDX Listings', 'wp-listings' ), 'manage_options', 'wplistings-idx-listing', 'wp_listings_idx_listing_setting_page' );
add_action( 'admin_init', 'wp_listings_idx_listing_register_settings' );
}
function wp_listings_idx_listing_register_settings() {
- register_setting('wp_listings_idx_listing_settings_group', 'wp_listings_idx_featured_listing_options', 'wp_listings_idx_create_post_cron');
+ register_setting( 'wp_listings_idx_listing_settings_group', 'wp_listings_idx_featured_listing_options', 'wp_listings_idx_create_post_cron' );
}
/**
* Do wp_cron job for importing listings
*/
-function wp_listings_idx_create_post_cron($listings) {
- wp_schedule_single_event( time(), 'wp_listings_idx_create_post_cron_hook', array($listings) );
+function wp_listings_idx_create_post_cron( $listings ) {
+ wp_schedule_single_event( time(), 'wp_listings_idx_create_post_cron_hook', array( $listings ) );
}
-add_action('wp_listings_idx_create_post_cron_hook', array('WPL_Idx_Listing', 'wp_listings_idx_create_post'));
+add_action( 'wp_listings_idx_create_post_cron_hook', array( 'WPL_Idx_Listing', 'wp_listings_idx_create_post' ) );
add_action( 'admin_enqueue_scripts', 'wp_listings_idx_listing_scripts' );
function wp_listings_idx_listing_scripts() {
$screen = get_current_screen();
- if($screen->id != 'listing_page_wplistings-idx-listing')
+ if ( $screen->id != 'listing_page_wplistings-idx-listing' ) {
return;
+ }
wp_enqueue_script( 'jquery-masonry' );
wp_enqueue_script( 'wp_listings_idx_listing_lazyload', WP_LISTINGS_URL . 'includes/js/jquery.lazyload.min.js', array( 'jquery' ), true );
@@ -467,18 +485,17 @@ function wp_listings_idx_listing_scripts() {
wp_enqueue_style( 'wp_listings_idx_listing_style', WP_LISTINGS_URL . 'includes/css/wp-listings-import.css' );
}
add_action( 'wp_ajax_wp_listings_idx_listing_delete', 'wp_listings_idx_listing_delete' );
-function wp_listings_idx_listing_delete(){
+function wp_listings_idx_listing_delete() {
$permission = check_ajax_referer( 'wp_listings_idx_listing_delete_nonce', 'nonce', false );
- if( $permission == false ) {
+ if ( $permission == false ) {
echo 'error';
- }
- else {
+ } else {
// Delete featured image
$post_featured_image_id = get_post_thumbnail_id( $_REQUEST['id'] );
wp_delete_attachment( $post_featured_image_id );
- //Delete post
+ // Delete post
wp_delete_post( $_REQUEST['id'] );
echo 'success';
}
@@ -486,37 +503,36 @@ function wp_listings_idx_listing_delete(){
}
add_action( 'wp_ajax_wp_listings_idx_listing_delete_all', 'wp_listings_idx_listing_delete_all' );
-function wp_listings_idx_listing_delete_all(){
+function wp_listings_idx_listing_delete_all() {
$permission = check_ajax_referer( 'wp_listings_idx_listing_delete_all_nonce', 'nonce', false );
- if( $permission == false ) {
+ if ( $permission == false ) {
echo 'error';
- }
- else {
+ } else {
// Get listings
- $idx_featured_listing_wp_options = get_option('wp_listings_idx_featured_listing_wp_options');
+ $idx_featured_listing_wp_options = get_option( 'wp_listings_idx_featured_listing_wp_options' );
- foreach($idx_featured_listing_wp_options as $prop) {
- if(isset($prop['post_id'])) {
+ foreach ( $idx_featured_listing_wp_options as $prop ) {
+ if ( isset( $prop['post_id'] ) ) {
// Delete featured image
$post_featured_image_id = get_post_thumbnail_id( $prop['post_id'] );
wp_delete_attachment( $post_featured_image_id );
- //Delete post
+ // Delete post
wp_delete_post( $prop['post_id'] );
}
}
-
+
echo 'success';
}
die();
}
function wp_listings_idx_listing_setting_page() {
- if( get_option('wp_listings_import_progress') == true ) {
- add_settings_error('wp_listings_idx_listing_settings_group', 'idx_listing_import_progress', 'Your listings are being imported in the background. This notice will dismiss when all selected listings have been imported.', 'updated');
+ if ( get_option( 'wp_listings_import_progress' ) == true ) {
+ add_settings_error( 'wp_listings_idx_listing_settings_group', 'idx_listing_import_progress', 'Your listings are being imported in the background. This notice will dismiss when all selected listings have been imported.', 'updated' );
}
- $idx_featured_listing_wp_options = get_option('wp_listings_idx_featured_listing_wp_options');
+ $idx_featured_listing_wp_options = get_option( 'wp_listings_idx_featured_listing_wp_options' );
?>
Import IDX Listings
@@ -525,21 +541,20 @@ function wp_listings_idx_listing_setting_page() {
Delete All Imported Listings';
+ if ( $idx_featured_listing_wp_options ) {
+ foreach ( $idx_featured_listing_wp_options as $prop ) {
+ if ( isset( $prop['post_id'] ) ) {
+ $nonce_all = wp_create_nonce( 'wp_listings_idx_listing_delete_all_nonce' );
+ echo 'Delete All Imported Listings';
break;
}
}
}
- submit_button('Import Listings');
-
+ submit_button( 'Import Listings' );
// Show popup if IDX Broker plugin not active or installed
- if( !class_exists( 'IDX_Broker_Plugin') ) {
+ if ( ! class_exists( 'IDX_Broker_Plugin' ) ) {
// thickbox like content
echo '
@@ -550,7 +565,7 @@ function wp_listings_idx_listing_setting_page() {
return;
}
- settings_errors('wp_listings_idx_listing_settings_group');
+ settings_errors( 'wp_listings_idx_listing_settings_group' );
?>
@@ -561,20 +576,20 @@ function wp_listings_idx_listing_setting_page() {
$plugin_data = get_plugins();
// Get properties from IDX Broker plugin
- if (class_exists( 'IDX_Broker_Plugin' )) {
+ if ( class_exists( 'IDX_Broker_Plugin' ) ) {
// bail if IDX plugin version is not at least 2.0
- if($plugin_data['idx-broker-platinum/idx-broker-platinum.php']['Version'] < 2.0 ) {
- add_settings_error('wp_listings_idx_listing_settings_group', 'idx_listing_update', 'You must update to IMPress for IDX Broker version 2.0.0 or higher to import listings.', 'error');
- settings_errors('wp_listings_idx_listing_settings_group');
+ if ( $plugin_data['idx-broker-platinum/idx-broker-platinum.php']['Version'] < 2.0 ) {
+ add_settings_error( 'wp_listings_idx_listing_settings_group', 'idx_listing_update', 'You must update to IMPress for IDX Broker version 2.0.0 or higher to import listings.', 'error' );
+ settings_errors( 'wp_listings_idx_listing_settings_group' );
return;
}
- $_idx_api = new \IDX\Idx_Api();
- $properties = $_idx_api->client_properties('featured');
- } elseif(is_wp_error($properties)) {
+ $_idx_api = new \IDX\Idx_Api();
+ $properties = $_idx_api->client_properties( 'featured' );
+ } elseif ( is_wp_error( $properties ) ) {
$error_string = $properties->get_error_message();
- add_settings_error('wp_listings_idx_listing_settings_group', 'idx_listing_update', $error_string, 'error');
- settings_errors('wp_listings_idx_listing_settings_group');
+ add_settings_error( 'wp_listings_idx_listing_settings_group', 'idx_listing_update', $error_string, 'error' );
+ settings_errors( 'wp_listings_idx_listing_settings_group' );
return;
} else {
return;
@@ -584,47 +599,49 @@ function wp_listings_idx_listing_setting_page() {
do_settings_sections( 'wp_listings_idx_listing_settings_group' );
// No featured properties found
- if(!$properties) {
+ if ( ! $properties ) {
echo 'No featured properties found.';
return;
}
// Loop through properties
- foreach ($properties as $prop) {
+ foreach ( $properties as $prop ) {
- if(!isset($idx_featured_listing_wp_options[$prop['listingID']]['post_id']) || !get_post($idx_featured_listing_wp_options[$prop['listingID']]['post_id']) ) {
- $idx_featured_listing_wp_options[$prop['listingID']] = array(
- 'listingID' => $prop['listingID']
- );
+ if ( ! isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) || ! get_post( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) ) {
+ $idx_featured_listing_wp_options[ $prop['listingID'] ] = array(
+ 'listingID' => $prop['listingID'],
+ );
}
- if(isset($idx_featured_listing_wp_options[$prop['listingID']]['post_id']) && get_post($idx_featured_listing_wp_options[$prop['listingID']]['post_id']) ) {
- $pid = $idx_featured_listing_wp_options[$prop['listingID']]['post_id'];
- $nonce = wp_create_nonce('wp_listings_idx_listing_delete_nonce');
- $delete_listing = sprintf('Delete',
- admin_url( 'admin-ajax.php?action=wp_listings_idx_listing_delete&id=' . $pid . '&nonce=' . $nonce),
- $pid,
- $nonce
- );
+ if ( isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) && get_post( $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'] ) ) {
+ $pid = $idx_featured_listing_wp_options[ $prop['listingID'] ]['post_id'];
+ $nonce = wp_create_nonce( 'wp_listings_idx_listing_delete_nonce' );
+ $delete_listing = sprintf(
+ 'Delete',
+ admin_url( 'admin-ajax.php?action=wp_listings_idx_listing_delete&id=' . $pid . '&nonce=' . $nonce ),
+ $pid,
+ $nonce
+ );
}
- printf('',
+ printf(
+ '',
$prop['listingID'],
- isset($idx_featured_listing_wp_options[$prop['listingID']]['status']) ? ($idx_featured_listing_wp_options[$prop['listingID']]['status'] == 'publish' ? "imported" : '') : '',
- isset($prop['image']['0']['url']) ? $prop['image']['0']['url'] : '//mlsphotos.idxbroker.com/defaultNoPhoto/noPhotoFull.png',
+ isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] ) ? ( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] == 'publish' ? 'imported' : '' ) : '',
+ isset( $prop['image']['0']['url'] ) ? $prop['image']['0']['url'] : '//mlsphotos.idxbroker.com/defaultNoPhoto/noPhotoFull.png',
$prop['listingID'],
$prop['listingID'],
- isset($idx_featured_listing_wp_options[$prop['listingID']]['status']) ? ($idx_featured_listing_wp_options[$prop['listingID']]['status'] == 'publish' ? "checked" : '') : '',
- isset($idx_featured_listing_wp_options[$prop['listingID']]['status']) ? ($idx_featured_listing_wp_options[$prop['listingID']]['status'] == 'publish' ? "Imported" : '') : '',
+ isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] ) ? ( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] == 'publish' ? 'checked' : '' ) : '',
+ isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] ) ? ( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] == 'publish' ? "Imported" : '' ) : '',
$prop['listingPrice'],
$prop['address'],
$prop['listingID'],
- isset($idx_featured_listing_wp_options[$prop['listingID']]['status']) ? ($idx_featured_listing_wp_options[$prop['listingID']]['status'] == 'publish' ? $delete_listing : '') : ''
- );
+ isset( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] ) ? ( $idx_featured_listing_wp_options[ $prop['listingID'] ]['status'] == 'publish' ? $delete_listing : '' ) : ''
+ );
}
echo '
';
- submit_button('Import Listings');
+ submit_button( 'Import Listings' );
?>
client_properties('featured');
+ if ( class_exists( 'IDX_Broker_Plugin' ) ) {
+ require_once ABSPATH . 'wp-content/plugins/idx-broker-platinum/idx/idx-api.php';
+ $_idx_api = new \IDX\Idx_Api();
+ $properties = $_idx_api->client_properties( 'featured' );
- foreach($properties as $prop) {
+ foreach ( $properties as $prop ) {
$listingIDs[] = $prop['listingID'];
}
}
- wp_listings_idx_create_post_cron($listingIDs);
+ wp_listings_idx_create_post_cron( $listingIDs );
}
diff --git a/includes/class-listing-template.php b/includes/class-listing-template.php
index b7f3852..5c7d3e8 100755
--- a/includes/class-listing-template.php
+++ b/includes/class-listing-template.php
@@ -24,15 +24,16 @@ function __construct() {
function get_listing_templates() {
- $templates = wp_get_theme()->get_files( 'php', 1 );
+ $templates = wp_get_theme()->get_files( 'php', 1 );
$listing_templates = array();
$base = array( trailingslashit( get_template_directory() ), trailingslashit( get_stylesheet_directory() ) );
foreach ( (array) $templates as $file => $full_path ) {
- if ( ! preg_match( '|Single Listing Template:(.*)$|mi', file_get_contents( $full_path ), $header ) )
+ if ( ! preg_match( '|Single Listing Template:(.*)$|mi', file_get_contents( $full_path ), $header ) ) {
continue;
+ }
$listing_templates[ $file ] = _cleanup_header_comment( $header[1] );
@@ -51,7 +52,7 @@ function listing_templates_dropdown() {
/** Loop through templates, make them options */
foreach ( (array) $listing_templates as $template_file => $template_name ) {
$selected = ( $template_file == get_post_meta( $post->ID, '_wp_post_template', true ) ) ? ' selected="selected"' : '';
- $opt = '';
+ $opt = '';
echo $opt;
}
@@ -66,7 +67,7 @@ function listing_template_metabox( $post ) {
?>
-
+
listing_templates_dropdown(); ?>
@@ -82,16 +83,18 @@ function metabox_save( $post_id, $post ) {
* Verify this came from our screen and with proper authorization,
* because save_post can be triggered at other times
*/
- if ( !isset( $_POST['wplistings_single_noncename'] ) || ! wp_verify_nonce( $_POST['wplistings_single_noncename'], plugin_basename( __FILE__ ) ) )
+ if ( ! isset( $_POST['wplistings_single_noncename'] ) || ! wp_verify_nonce( $_POST['wplistings_single_noncename'], plugin_basename( __FILE__ ) ) ) {
return $post->ID;
+ }
/** Is the user allowed to edit the post or page? */
- if ( 'listing' == $_POST['post_type'] )
- if ( ! current_user_can( 'edit_page', $post->ID ) )
+ if ( 'listing' == $_POST['post_type'] ) {
+ if ( ! current_user_can( 'edit_page', $post->ID ) ) {
return $post->ID;
- else
- if ( ! current_user_can( 'edit_post', $post->ID ) )
+ } elseif ( ! current_user_can( 'edit_post', $post->ID ) ) {
return $post->ID;
+ }
+ }
/** OK, we're authenticated: we need to find and save the data */
@@ -101,23 +104,26 @@ function metabox_save( $post_id, $post ) {
/** Add values of $mydata as custom fields */
foreach ( $mydata as $key => $value ) {
/** Don't store custom data twice */
- if( 'revision' == $post->post_type )
+ if ( 'revision' == $post->post_type ) {
return;
+ }
/** If $value is an array, make it a CSV (unlikely) */
$value = implode( ',', (array) $value );
/** Update the data if it exists, or add it if it doesn't */
- if( get_post_meta( $post->ID, $key, false ) )
+ if ( get_post_meta( $post->ID, $key, false ) ) {
update_post_meta( $post->ID, $key, $value );
- else
+ } else {
add_post_meta( $post->ID, $key, $value );
+ }
/** Delete if blank */
- if( ! $value )
+ if ( ! $value ) {
delete_post_meta( $post->ID, $key );
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/includes/class-listings-search-widget.php b/includes/class-listings-search-widget.php
index 72174f0..92fe23c 100755
--- a/includes/class-listings-search-widget.php
+++ b/includes/class-listings-search-widget.php
@@ -8,17 +8,28 @@
class WP_Listings_Search_Widget extends WP_Widget {
function __construct() {
- $widget_ops = array( 'classname' => 'listings-search wp-listings-search', 'description' => __( 'Display listings search dropdown', 'wp-listings' ), 'customize_selective_refresh' => true );
- $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'listings-search' );
+ $widget_ops = array(
+ 'classname' => 'listings-search wp-listings-search',
+ 'description' => __( 'Display listings search dropdown', 'wp-listings' ),
+ 'customize_selective_refresh' => true,
+ );
+ $control_ops = array(
+ 'width' => 300,
+ 'height' => 350,
+ 'id_base' => 'listings-search',
+ );
parent::__construct( 'listings-search', __( 'IMPress Listings - Search', 'wp-listings' ), $widget_ops, $control_ops );
}
function widget( $args, $instance ) {
- $instance = wp_parse_args( (array) $instance, array(
- 'title' => '',
- 'button_text' => __( 'Search Listings', 'wp-listings' )
- ) );
+ $instance = wp_parse_args(
+ (array) $instance,
+ array(
+ 'title' => '',
+ 'button_text' => __( 'Search Listings', 'wp-listings' ),
+ )
+ );
global $_wp_listings_taxonomies;
@@ -28,28 +39,40 @@ function widget( $args, $instance ) {
echo $before_widget;
- if ( $instance['title'] ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
+ if ( $instance['title'] ) {
+ echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
+ }
echo '';
@@ -63,15 +86,18 @@ function update( $new_instance, $old_instance ) {
function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array(
- 'title' => '',
- 'button_text' => __( 'Search Listings', 'wp-listings' )
- ) );
+ $instance = wp_parse_args(
+ (array) $instance,
+ array(
+ 'title' => '',
+ 'button_text' => __( 'Search Listings', 'wp-listings' ),
+ )
+ );
global $_wp_listings_taxonomies;
$listings_taxonomies = $_wp_listings_taxonomies->get_taxonomies();
- $new_widget = empty( $instance );
+ $new_widget = empty( $instance );
printf( '', $this->get_field_id( 'title' ), __( 'Title:', 'wp-listings' ), $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), esc_attr( $instance['title'] ), 'width: 95%;' );
?>
@@ -79,8 +105,9 @@ function form( $instance ) {
$data ) {
$terms = get_terms( $tax );
- if ( empty( $terms ) )
+ if ( empty( $terms ) ) {
continue;
+ }
$checked = isset( $instance[ $tax ] ) && $instance[ $tax ];
diff --git a/includes/class-listings.php b/includes/class-listings.php
index d70389c..5a1bf51 100755
--- a/includes/class-listings.php
+++ b/includes/class-listings.php
@@ -6,13 +6,12 @@
/**
* This class handles the creation of the "Listings" post type, and creates a
* UI to display the Listing-specific data on the admin screens.
- *
*/
class WP_Listings {
- var $settings_page = 'wp-listings-settings';
+ var $settings_page = 'wp-listings-settings';
var $settings_field = 'wp_listings_taxonomies';
- var $menu_page = 'register-taxonomies';
+ var $menu_page = 'register-taxonomies';
var $options;
@@ -26,61 +25,67 @@ class WP_Listings {
*/
function __construct() {
- $this->options = get_option('plugin_wp_listings_settings');
-
- $this->property_details = apply_filters( 'wp_listings_property_details', array(
- 'col1' => array(
- __( 'Price:', 'wp-listings' ) => '_listing_price',
- __( 'Address:', 'wp-listings' ) => '_listing_address',
- __( 'City:', 'wp-listings' ) => '_listing_city',
- __( 'County:', 'wp-listings' ) => '_listing_county',
- __( 'State:', 'wp-listings' ) => '_listing_state',
- __( 'Country:', 'wp-listings' ) => '_listing_country',
- __( 'ZIP:', 'wp-listings' ) => '_listing_zip',
- __( 'MLS #:', 'wp-listings' ) => '_listing_mls',
- __( 'Open House Time & Date:', 'wp-listings' ) => '_listing_open_house'
- ),
- 'col2' => array(
- __( 'Year Built:', 'wp-listings' ) => '_listing_year_built',
- __( 'Floors:', 'wp-listings' ) => '_listing_floors',
- __( 'Square Feet:', 'wp-listings' ) => '_listing_sqft',
- __( 'Acres:', 'wp-listings' ) => '_listing_acres',
- __( 'Lot Square Feet:', 'wp-listings' ) => '_listing_lot_sqft',
- __( 'Bedrooms:', 'wp-listings' ) => '_listing_bedrooms',
- __( 'Bathrooms:', 'wp-listings' ) => '_listing_bathrooms',
- __( 'Half Bathrooms:', 'wp-listings' ) => '_listing_half_bath',
- __( 'Garage:', 'wp-listings' ) => '_listing_garage',
- __( 'Pool:', 'wp-listings' ) => '_listing_pool'
- ),
- ) );
-
- $this->extended_property_details = apply_filters( 'wp_listings_extended_property_details', array(
- 'col1' => array(
- __( 'Property Type:', 'wp-listings' ) => '_listing_proptype',
- __( 'Condo:', 'wp-listings' ) => '_listing_condo',
- __( 'Financial:', 'wp-listings' ) => '_listing_financial',
- __( 'Condition:', 'wp-listings' ) => '_listing_condition',
- __( 'Construction:', 'wp-listings' ) => '_listing_construction',
- __( 'Exterior:', 'wp-listings' ) => '_listing_exterior',
- __( 'Fencing:', 'wp-listings' ) => '_listing_fencing',
- __( 'Interior:', 'wp-listings' ) => '_listing_interior',
- __( 'Flooring:', 'wp-listings' ) => '_listing_flooring',
- __( 'Heat/Cool:', 'wp-listings' ) => '_listing_heatcool'
- ),
- 'col2' => array(
- __( 'Lot size:', 'wp-listings' ) => '_listing_lotsize',
- __( 'Location:', 'wp-listings' ) => '_listing_location',
- __( 'Scenery:', 'wp-listings' ) => '_listing_scenery',
- __( 'Community:', 'wp-listings' ) => '_listing_community',
- __( 'Recreation:', 'wp-listings' ) => '_listing_recreation',
- __( 'General:', 'wp-listings' ) => '_listing_general',
- __( 'Inclusions:', 'wp-listings' ) => '_listing_inclusions',
- __( 'Parking:', 'wp-listings' ) => '_listing_parking',
- __( 'Rooms:', 'wp-listings' ) => '_listing_rooms',
- __( 'Laundry:', 'wp-listings' ) => '_listing_laundry',
- __( 'Utilities:', 'wp-listings' ) => '_listing_utilities'
- ),
- ) );
+ $this->options = get_option( 'plugin_wp_listings_settings' );
+
+ $this->property_details = apply_filters(
+ 'wp_listings_property_details',
+ array(
+ 'col1' => array(
+ __( 'Price:', 'wp-listings' ) => '_listing_price',
+ __( 'Address:', 'wp-listings' ) => '_listing_address',
+ __( 'City:', 'wp-listings' ) => '_listing_city',
+ __( 'County:', 'wp-listings' ) => '_listing_county',
+ __( 'State:', 'wp-listings' ) => '_listing_state',
+ __( 'Country:', 'wp-listings' ) => '_listing_country',
+ __( 'ZIP:', 'wp-listings' ) => '_listing_zip',
+ __( 'MLS #:', 'wp-listings' ) => '_listing_mls',
+ __( 'Open House Time & Date:', 'wp-listings' ) => '_listing_open_house',
+ ),
+ 'col2' => array(
+ __( 'Year Built:', 'wp-listings' ) => '_listing_year_built',
+ __( 'Floors:', 'wp-listings' ) => '_listing_floors',
+ __( 'Square Feet:', 'wp-listings' ) => '_listing_sqft',
+ __( 'Acres:', 'wp-listings' ) => '_listing_acres',
+ __( 'Lot Square Feet:', 'wp-listings' ) => '_listing_lot_sqft',
+ __( 'Bedrooms:', 'wp-listings' ) => '_listing_bedrooms',
+ __( 'Bathrooms:', 'wp-listings' ) => '_listing_bathrooms',
+ __( 'Half Bathrooms:', 'wp-listings' ) => '_listing_half_bath',
+ __( 'Garage:', 'wp-listings' ) => '_listing_garage',
+ __( 'Pool:', 'wp-listings' ) => '_listing_pool',
+ ),
+ )
+ );
+
+ $this->extended_property_details = apply_filters(
+ 'wp_listings_extended_property_details',
+ array(
+ 'col1' => array(
+ __( 'Property Type:', 'wp-listings' ) => '_listing_proptype',
+ __( 'Condo:', 'wp-listings' ) => '_listing_condo',
+ __( 'Financial:', 'wp-listings' ) => '_listing_financial',
+ __( 'Condition:', 'wp-listings' ) => '_listing_condition',
+ __( 'Construction:', 'wp-listings' ) => '_listing_construction',
+ __( 'Exterior:', 'wp-listings' ) => '_listing_exterior',
+ __( 'Fencing:', 'wp-listings' ) => '_listing_fencing',
+ __( 'Interior:', 'wp-listings' ) => '_listing_interior',
+ __( 'Flooring:', 'wp-listings' ) => '_listing_flooring',
+ __( 'Heat/Cool:', 'wp-listings' ) => '_listing_heatcool',
+ ),
+ 'col2' => array(
+ __( 'Lot size:', 'wp-listings' ) => '_listing_lotsize',
+ __( 'Location:', 'wp-listings' ) => '_listing_location',
+ __( 'Scenery:', 'wp-listings' ) => '_listing_scenery',
+ __( 'Community:', 'wp-listings' ) => '_listing_community',
+ __( 'Recreation:', 'wp-listings' ) => '_listing_recreation',
+ __( 'General:', 'wp-listings' ) => '_listing_general',
+ __( 'Inclusions:', 'wp-listings' ) => '_listing_inclusions',
+ __( 'Parking:', 'wp-listings' ) => '_listing_parking',
+ __( 'Rooms:', 'wp-listings' ) => '_listing_rooms',
+ __( 'Laundry:', 'wp-listings' ) => '_listing_laundry',
+ __( 'Utilities:', 'wp-listings' ) => '_listing_utilities',
+ ),
+ )
+ );
add_action( 'init', array( $this, 'create_post_type' ) );
@@ -113,10 +118,10 @@ function add_options() {
$new_options = array(
'wp_listings_archive_posts_num' => 9,
- 'wp_listings_slug' => 'listings'
+ 'wp_listings_slug' => 'listings',
);
- if ( empty($this->options['wp_listings_slug']) && empty($this->options['wp_listings_archive_posts_num']) ) {
+ if ( empty( $this->options['wp_listings_slug'] ) && empty( $this->options['wp_listings_archive_posts_num'] ) ) {
add_option( 'plugin_wp_listings_settings', $new_options );
}
@@ -133,7 +138,7 @@ function settings_init() {
* Creates display of settings page along with form fields
*/
function settings_page() {
- include( dirname( __FILE__ ) . '/views/wp-listings-settings.php' );
+ include dirname( __FILE__ ) . '/views/wp-listings-settings.php';
}
/**
@@ -141,35 +146,40 @@ function settings_page() {
*/
function create_post_type() {
- $args = apply_filters( 'wp_listings_post_type_args',
+ $args = apply_filters(
+ 'wp_listings_post_type_args',
array(
- 'labels' => array(
- 'name' => __( 'Listings', 'wp-listings' ),
- 'singular_name' => __( 'Listing', 'wp-listings' ),
- 'add_new' => __( 'Add New', 'wp-listings' ),
- 'add_new_item' => __( 'Add New Listing', 'wp-listings' ),
- 'edit' => __( 'Edit', 'wp-listings' ),
- 'edit_item' => __( 'Edit Listing', 'wp-listings' ),
- 'new_item' => __( 'New Listing', 'wp-listings' ),
- 'view' => __( 'View Listing', 'wp-listings' ),
- 'view_item' => __( 'View Listing', 'wp-listings' ),
- 'search_items' => __( 'Search Listings', 'wp-listings' ),
- 'not_found' => __( 'No listings found', 'wp-listings' ),
- 'not_found_in_trash' => __( 'No listings found in Trash', 'wp-listings' ),
+ 'labels' => array(
+ 'name' => __( 'Listings', 'wp-listings' ),
+ 'singular_name' => __( 'Listing', 'wp-listings' ),
+ 'add_new' => __( 'Add New', 'wp-listings' ),
+ 'add_new_item' => __( 'Add New Listing', 'wp-listings' ),
+ 'edit' => __( 'Edit', 'wp-listings' ),
+ 'edit_item' => __( 'Edit Listing', 'wp-listings' ),
+ 'new_item' => __( 'New Listing', 'wp-listings' ),
+ 'view' => __( 'View Listing', 'wp-listings' ),
+ 'view_item' => __( 'View Listing', 'wp-listings' ),
+ 'search_items' => __( 'Search Listings', 'wp-listings' ),
+ 'not_found' => __( 'No listings found', 'wp-listings' ),
+ 'not_found_in_trash' => __( 'No listings found in Trash', 'wp-listings' ),
'filter_items_list' => __( 'Filter Listings', 'wp-listings' ),
'items_list_navigation' => __( 'Listings navigation', 'wp-listings' ),
- 'items_list' => __( 'Listings list', 'wp-listings' )
+ 'items_list' => __( 'Listings list', 'wp-listings' ),
),
- 'public' => true,
- 'query_var' => true,
- 'show_in_rest' => true,
- 'rest_base' => 'listing',
+ 'public' => true,
+ 'query_var' => true,
+ 'show_in_rest' => true,
+ 'rest_base' => 'listing',
'rest_controller_class' => 'WP_REST_Posts_Controller',
- 'menu_position' => 5,
- 'menu_icon' => 'dashicons-admin-home',
- 'has_archive' => true,
- 'supports' => array( 'title', 'editor', 'author', 'comments', 'excerpt', 'thumbnail', 'revisions', 'equity-layouts', 'equity-cpt-archives-settings', 'genesis-seo', 'genesis-layouts', 'genesis-simple-sidebars', 'genesis-cpt-archives-settings', 'publicize', 'wpcom-markdown'),
- 'rewrite' => array( 'slug' => $this->options['wp_listings_slug'], 'feeds' => true, 'with_front' => false ),
+ 'menu_position' => 5,
+ 'menu_icon' => 'dashicons-admin-home',
+ 'has_archive' => true,
+ 'supports' => array( 'title', 'editor', 'author', 'comments', 'excerpt', 'thumbnail', 'revisions', 'equity-layouts', 'equity-cpt-archives-settings', 'genesis-seo', 'genesis-layouts', 'genesis-simple-sidebars', 'genesis-cpt-archives-settings', 'publicize', 'wpcom-markdown' ),
+ 'rewrite' => array(
+ 'slug' => $this->options['wp_listings_slug'],
+ 'feeds' => true,
+ 'with_front' => false,
+ ),
)
);
@@ -180,79 +190,88 @@ function create_post_type() {
function register_meta_boxes() {
add_meta_box( 'listing_details_metabox', __( 'Property Details', 'wp-listings' ), array( &$this, 'listing_details_metabox' ), 'listing', 'normal', 'high' );
add_meta_box( 'listing_features_metabox', __( 'Additional Details', 'wp-listings' ), array( &$this, 'listing_features_metabox' ), 'listing', 'normal', 'high' );
- if ( !class_exists( 'Idx_Broker_Plugin' ) ) {
+ if ( ! class_exists( 'Idx_Broker_Plugin' ) ) {
add_meta_box( 'idx_metabox', __( 'IDX Broker', 'wp-listings' ), array( &$this, 'idx_metabox' ), 'wp-listings-options', 'side', 'core' );
}
- if( !function_exists( 'equity' ) ) {
+ if ( ! function_exists( 'equity' ) ) {
add_meta_box( 'agentevo_metabox', __( 'Equity Framework', 'wp-listings' ), array( &$this, 'agentevo_metabox' ), 'wp-listings-options', 'side', 'core' );
}
}
function listing_details_metabox() {
- include( dirname( __FILE__ ) . '/views/listing-details-metabox.php' );
+ include dirname( __FILE__ ) . '/views/listing-details-metabox.php';
}
function listing_features_metabox() {
- include( dirname( __FILE__ ) . '/views/listing-features-metabox.php' );
+ include dirname( __FILE__ ) . '/views/listing-features-metabox.php';
}
function agentevo_metabox() {
- include( dirname( __FILE__ ) . '/views/agentevo-metabox.php' );
+ include dirname( __FILE__ ) . '/views/agentevo-metabox.php';
}
function idx_metabox() {
- include( dirname( __FILE__ ) . '/views/idx-metabox.php' );
+ include dirname( __FILE__ ) . '/views/idx-metabox.php';
}
function metabox_save( $post_id, $post ) {
/** Run only on listings post type save */
- if ( 'listing' != $post->post_type )
+ if ( 'listing' != $post->post_type ) {
return;
+ }
- if ( !isset( $_POST['wp_listings_metabox_nonce'] ) || !wp_verify_nonce( $_POST['wp_listings_metabox_nonce'], 'wp_listings_metabox_save' ) )
- return $post_id;
+ if ( ! isset( $_POST['wp_listings_metabox_nonce'] ) || ! wp_verify_nonce( $_POST['wp_listings_metabox_nonce'], 'wp_listings_metabox_save' ) ) {
+ return $post_id;
+ }
- /** Don't try to save the data under autosave, ajax, or future post */
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) return;
- if ( defined( 'DOING_CRON' ) && DOING_CRON ) return;
+ /** Don't try to save the data under autosave, ajax, or future post */
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
+ return;
+ }
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
+ return;
+ }
+ if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
+ return;
+ }
- /** Check permissions */
- if ( ! current_user_can( 'edit_post', $post_id ) )
- return;
+ /** Check permissions */
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
+ return;
+ }
- $property_details = $_POST['wp_listings'];
+ $property_details = $_POST['wp_listings'];
- if ( ! isset( $property_details['_listing_hide_price'] ) )
+ if ( ! isset( $property_details['_listing_hide_price'] ) ) {
$property_details['_listing_hide_price'] = 0;
+ }
- /** Store the property details custom fields */
- foreach ( (array) $property_details as $key => $value ) {
-
- /** Save/Update/Delete */
- if ( $value ) {
- update_post_meta($post->ID, $key, $value);
- } else {
- delete_post_meta($post->ID, $key);
- }
+ /** Store the property details custom fields */
+ foreach ( (array) $property_details as $key => $value ) {
- }
+ /** Save/Update/Delete */
+ if ( $value ) {
+ update_post_meta( $post->ID, $key, $value );
+ } else {
+ delete_post_meta( $post->ID, $key );
+ }
+ }
}
/**
* Filter the columns in the "Listings" screen, define our own.
*/
- function columns_filter ( $columns ) {
+ function columns_filter( $columns ) {
$columns = array(
- 'cb' => '',
- 'listing_thumbnail' => __( 'Thumbnail', 'wp-listings' ),
- 'title' => __( 'Listing Title', 'wp-listings' ),
- 'listing_details' => __( 'Details', 'wp-listings' ),
- 'listing_tags' => __( 'Tags', 'wp-listings' )
+ 'cb' => '',
+ 'listing_thumbnail' => __( 'Thumbnail', 'wp-listings' ),
+ 'title' => __( 'Listing Title', 'wp-listings' ),
+ 'listing_details' => __( 'Details', 'wp-listings' ),
+ 'listing_tags' => __( 'Tags', 'wp-listings' ),
);
return $columns;
@@ -268,29 +287,29 @@ function columns_data( $column ) {
$image_size = 'style="max-width: 115px;"';
- apply_filters( 'wp_listings_admin_listing_details', $admin_details = $this->property_details['col1']);
+ apply_filters( 'wp_listings_admin_listing_details', $admin_details = $this->property_details['col1'] );
- if (isset($_GET["mode"]) && trim($_GET["mode"]) == 'excerpt' ) {
- apply_filters( 'wp_listings_admin_extended_details', $admin_details = $this->property_details['col1'] + $this->property_details['col2']);
+ if ( isset( $_GET['mode'] ) && trim( $_GET['mode'] ) == 'excerpt' ) {
+ apply_filters( 'wp_listings_admin_extended_details', $admin_details = $this->property_details['col1'] + $this->property_details['col2'] );
$image_size = 'style="max-width: 150px;"';
}
- $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' );
- switch( $column ) {
- case "listing_thumbnail":
+ switch ( $column ) {
+ case 'listing_thumbnail':
echo '
';
break;
- case "listing_details":
+ case 'listing_details':
foreach ( (array) $admin_details as $label => $key ) {
- printf( '%s %s
', esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) );
+ printf( '%s %s
', esc_html( $label ), esc_html( get_post_meta( $post->ID, $key, true ) ) );
}
break;
- case "listing_tags":
- _e('Status: ' . get_the_term_list( $post->ID, 'status', '', ', ', '' ) . '
', 'wp-listings');
- _e('Property Type: ' . get_the_term_list( $post->ID, 'property-types', '', ', ', '' ) . '
', 'wp-listings');
- _e('Location: ' . get_the_term_list( $post->ID, 'locations', '', ', ', '' ) . '
', 'wp-listings');
- _e('Features: ' . get_the_term_list( $post->ID, 'features', '', ', ', '' ), 'wp-listings');
+ case 'listing_tags':
+ _e( 'Status: ' . get_the_term_list( $post->ID, 'status', '', ', ', '' ) . '
', 'wp-listings' );
+ _e( 'Property Type: ' . get_the_term_list( $post->ID, 'property-types', '', ', ', '' ) . '
', 'wp-listings' );
+ _e( 'Location: ' . get_the_term_list( $post->ID, 'locations', '', ', ', '' ) . '
', 'wp-listings' );
+ _e( 'Features: ' . get_the_term_list( $post->ID, 'features', '', ', ', '' ), 'wp-listings' );
break;
}
@@ -298,14 +317,16 @@ function columns_data( $column ) {
/**
* Adds query var on saving post to show notice
+ *
* @param [type] $post_id [description]
* @param [type] $post [description]
* @param [type] $update [description]
* @return [type] [description]
*/
function save_post( $post_id, $post, $update ) {
- if ( 'listing' != $post->post_type )
+ if ( 'listing' != $post->post_type ) {
return;
+ }
add_filter( 'redirect_post_location', array( &$this, 'add_notice_query_var' ), 99 );
}
@@ -317,6 +338,7 @@ function add_notice_query_var( $location ) {
/**
* Displays admin notices if show-notice url param exists or edit listing page
+ *
* @return object current screen
* @uses wp_listings_admin_notice
*/
@@ -324,14 +346,14 @@ function admin_notices() {
$screen = get_current_screen();
- if ( isset( $_GET['wp-listings']) || $screen->id == 'edit-listing' ) {
- if ( !class_exists( 'Idx_Broker_Plugin') ) {
- echo wp_listings_admin_notice( __( 'Integrate your MLS Listings into WordPress with IDX Broker! Find out how', 'wp-listings' ), false, 'activate_plugins', (isset( $_GET['wp-listings'])) ? 'wpl_listing_notice_idx' : 'wpl_notice_idx' );
+ if ( isset( $_GET['wp-listings'] ) || $screen->id == 'edit-listing' ) {
+ if ( ! class_exists( 'Idx_Broker_Plugin' ) ) {
+ echo wp_listings_admin_notice( __( 'Integrate your MLS Listings into WordPress with IDX Broker! Find out how', 'wp-listings' ), false, 'activate_plugins', ( isset( $_GET['wp-listings'] ) ) ? 'wpl_listing_notice_idx' : 'wpl_notice_idx' );
}
- if( !function_exists( 'equity' ) ) {
- echo wp_listings_admin_notice( __( 'Stop filling out forms. Equity automatically enhances your listings with extended property details. Find out how', 'wp-listings' ), false, 'activate_plugins', (isset( $_GET['wp-listings'])) ? 'wpl_listing_notice_equity' : 'wpl_notice_equity' );
+ if ( ! function_exists( 'equity' ) ) {
+ echo wp_listings_admin_notice( __( 'Stop filling out forms. Equity automatically enhances your listings with extended property details. Find out how', 'wp-listings' ), false, 'activate_plugins', ( isset( $_GET['wp-listings'] ) ) ? 'wpl_listing_notice_equity' : 'wpl_notice_equity' );
}
- if( get_option('wp_listings_import_progress') == true ) {
+ if ( get_option( 'wp_listings_import_progress' ) == true ) {
echo wp_listings_admin_notice( __( 'Your listings are being imported in the background. This notice will dismiss when all selected listings have been imported.', 'wp-listings' ), false, 'activate_plugins', 'wpl_notice_import_progress' );
}
}
diff --git a/includes/class-taxonomies.php b/includes/class-taxonomies.php
index 17b8708..6a902f1 100755
--- a/includes/class-taxonomies.php
+++ b/includes/class-taxonomies.php
@@ -6,13 +6,12 @@
/**
* This class handles all the aspects of displaying, creating, and editing the
* user-created taxonomies for the "Listings" post-type.
- *
*/
class WP_Listings_Taxonomies {
var $settings_field = 'wp_listings_taxonomies';
- var $menu_page = 'register-taxonomies';
- var $reorder_page = 'reorder-taxonomies';
+ var $menu_page = 'register-taxonomies';
+ var $reorder_page = 'reorder-taxonomies';
/**
* Construct Method.
@@ -31,19 +30,19 @@ function __construct() {
if ( function_exists( 'get_term_meta' ) ) {
add_action( 'init', array( $this, 'register_term_meta' ), 17 );
-
- foreach( (array) $this->get_taxonomies() as $slug => $data ) {
- add_action( "{$slug}_add_form_fields", array( $this, 'wp_listings_new_term_image_field') );
- add_action( "{$slug}_edit_form_fields", array( $this, 'wp_listings_edit_term_image_field') );
- add_action( "create_{$slug}", array( $this, 'wp_listings_save_term_image') );
- add_action( "edit_{$slug}", array( $this, 'wp_listings_save_term_image') );
+
+ foreach ( (array) $this->get_taxonomies() as $slug => $data ) {
+ add_action( "{$slug}_add_form_fields", array( $this, 'wp_listings_new_term_image_field' ) );
+ add_action( "{$slug}_edit_form_fields", array( $this, 'wp_listings_edit_term_image_field' ) );
+ add_action( "create_{$slug}", array( $this, 'wp_listings_save_term_image' ) );
+ add_action( "edit_{$slug}", array( $this, 'wp_listings_save_term_image' ) );
add_filter( "manage_edit-{$slug}_columns", array( $this, 'wp_listings_edit_term_columns' ) );
add_action( "manage_{$slug}_custom_column", array( $this, 'wp_listings_manage_term_custom_column' ), 10, 3 );
}
}
- add_action('restrict_manage_posts', array($this, 'wp_listings_filter_post_type_by_taxonomy') );
- add_filter('parse_query', array($this, 'wp_listings_convert_id_to_term_in_query') );
+ add_action( 'restrict_manage_posts', array( $this, 'wp_listings_filter_post_type_by_taxonomy' ) );
+ add_filter( 'parse_query', array( $this, 'wp_listings_convert_id_to_term_in_query' ) );
}
@@ -85,19 +84,18 @@ function actions() {
}
function tax_reorder_enqueue() {
- wp_enqueue_script('jquery-ui-sortable');
+ wp_enqueue_script( 'jquery-ui-sortable' );
}
function admin() {
echo '';
- if ( isset( $_REQUEST['view'] ) && 'edit' == $_REQUEST['view'] ) {
- require( dirname( __FILE__ ) . '/views/edit-tax.php' );
- }
- else {
- require( dirname( __FILE__ ) . '/views/create-tax.php' );
- }
+ if ( isset( $_REQUEST['view'] ) && 'edit' == $_REQUEST['view'] ) {
+ require dirname( __FILE__ ) . '/views/edit-tax.php';
+ } else {
+ require dirname( __FILE__ ) . '/views/create-tax.php';
+ }
echo '
';
@@ -105,39 +103,45 @@ function admin() {
function create_taxonomy( $args = array() ) {
- /**** VERIFY THE NONCE ****/
+ /**** VERIFY THE NONCE */
/** No empty fields */
- if ( ! isset( $args['id'] ) || empty( $args['id'] ) )
+ if ( ! isset( $args['id'] ) || empty( $args['id'] ) ) {
wp_die( __( 'Please complete all required fields.', 'wp-listings' ) );
- if ( ! isset( $args['name'] ) || empty( $args['name'] ) )
+ }
+ if ( ! isset( $args['name'] ) || empty( $args['name'] ) ) {
wp_die( __( 'Please complete all required fields.', 'wp-listings' ) );
- if ( ! isset( $args['singular_name'] ) || empty( $args['singular_name'] ) )
+ }
+ if ( ! isset( $args['singular_name'] ) || empty( $args['singular_name'] ) ) {
wp_die( __( 'Please complete all required fields.', 'wp-listings' ) );
+ }
extract( $args );
$labels = array(
- 'name' => strip_tags( $name ),
- 'singular_name' => strip_tags( $singular_name ),
- 'menu_name' => strip_tags( $name ),
-
- 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
- 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
- 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
- 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
- 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) )
+ 'name' => strip_tags( $name ),
+ 'singular_name' => strip_tags( $singular_name ),
+ 'menu_name' => strip_tags( $name ),
+
+ 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) ),
);
$args = array(
- 'labels' => $labels,
- 'hierarchical' => true,
- 'rewrite' => array( 'slug' => $id, 'with_front' => false ),
- 'editable' => 1
+ 'labels' => $labels,
+ 'hierarchical' => true,
+ 'rewrite' => array(
+ 'slug' => $id,
+ 'with_front' => false,
+ ),
+ 'editable' => 1,
);
$tax = array( $id => $args );
@@ -155,17 +159,18 @@ function create_taxonomy( $args = array() ) {
function delete_taxonomy( $id = '' ) {
- /**** VERIFY THE NONCE ****/
+ /**** VERIFY THE NONCE */
/** No empty ID */
- if ( ! isset( $id ) || empty( $id ) )
+ if ( ! isset( $id ) || empty( $id ) ) {
wp_die( __( "Nice try, partner. But that taxonomy doesn't exist. Click back and try again.", 'wp-listings' ) );
+ }
$options = get_option( $this->settings_field );
/** Look for the ID, delete if it exists */
if ( array_key_exists( $id, (array) $options ) ) {
- unset( $options[$id] );
+ unset( $options[ $id ] );
} else {
wp_die( __( "Nice try, partner. But that taxonomy doesn't exist. Click back and try again.", 'wp-listings' ) );
}
@@ -177,39 +182,45 @@ function delete_taxonomy( $id = '' ) {
function edit_taxonomy( $args = array() ) {
- /**** VERIFY THE NONCE ****/
+ /**** VERIFY THE NONCE */
/** No empty fields */
- if ( ! isset( $args['id'] ) || empty( $args['id'] ) )
+ if ( ! isset( $args['id'] ) || empty( $args['id'] ) ) {
wp_die( __( 'Please complete all required fields.', 'wp-listings' ) );
- if ( ! isset( $args['name'] ) || empty( $args['name'] ) )
+ }
+ if ( ! isset( $args['name'] ) || empty( $args['name'] ) ) {
wp_die( __( 'Please complete all required fields.', 'wp-listings' ) );
- if ( ! isset( $args['singular_name'] ) || empty( $args['singular_name'] ) )
+ }
+ if ( ! isset( $args['singular_name'] ) || empty( $args['singular_name'] ) ) {
wp_die( __( 'Please complete all required fields.', 'wp-listings' ) );
+ }
extract( $args );
$labels = array(
- 'name' => strip_tags( $name ),
- 'singular_name' => strip_tags( $singular_name ),
- 'menu_name' => strip_tags( $name ),
-
- 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
- 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
- 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
- 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
- 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) )
+ 'name' => strip_tags( $name ),
+ 'singular_name' => strip_tags( $singular_name ),
+ 'menu_name' => strip_tags( $name ),
+
+ 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) ),
);
$args = array(
- 'labels' => $labels,
- 'hierarchical' => true,
- 'rewrite' => array( 'slug' => $id, 'with_front' => false ),
- 'editable' => 1
+ 'labels' => $labels,
+ 'hierarchical' => true,
+ 'rewrite' => array(
+ 'slug' => $id,
+ 'with_front' => false,
+ ),
+ 'editable' => 1,
);
$tax = array( $id => $args );
@@ -229,17 +240,17 @@ function notices() {
$format = '';
if ( isset( $_REQUEST['created'] ) && 'true' == $_REQUEST['created'] ) {
- printf( $format, __('New taxonomy successfully created!', 'wp-listings') );
+ printf( $format, __( 'New taxonomy successfully created!', 'wp-listings' ) );
return;
}
if ( isset( $_REQUEST['edited'] ) && 'true' == $_REQUEST['edited'] ) {
- printf( $format, __('Taxonomy successfully edited!', 'wp-listings') );
+ printf( $format, __( 'Taxonomy successfully edited!', 'wp-listings' ) );
return;
}
if ( isset( $_REQUEST['deleted'] ) && 'true' == $_REQUEST['deleted'] ) {
- printf( $format, __('Taxonomy successfully deleted.', 'wp-listings') );
+ printf( $format, __( 'Taxonomy successfully deleted.', 'wp-listings' ) );
return;
}
@@ -252,33 +263,36 @@ function notices() {
*/
function listing_status_taxonomy() {
- $name = __( 'Status', 'wp-listings' );
+ $name = __( 'Status', 'wp-listings' );
$singular_name = __( 'Status', 'wp-listings' );
return array(
'status' => array(
- 'labels' => array(
- 'name' => strip_tags( $name ),
- 'singular_name' => strip_tags( $singular_name ),
- 'menu_name' => strip_tags( $name ),
-
- 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
- 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
- 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
- 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
- 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) )
+ 'labels' => array(
+ 'name' => strip_tags( $name ),
+ 'singular_name' => strip_tags( $singular_name ),
+ 'menu_name' => strip_tags( $name ),
+
+ 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) ),
),
- 'hierarchical' => true,
- 'rewrite' => array( __( 'status', 'wp-listings' ), 'with_front' => false ),
- 'editable' => 0,
- 'show_in_rest' => true,
- 'rest_base' => 'listing-status',
- 'rest_controller_class' => 'WP_REST_Terms_Controller'
- )
+ 'hierarchical' => true,
+ 'rewrite' => array(
+ __( 'status', 'wp-listings' ),
+ 'with_front' => false,
+ ),
+ 'editable' => 0,
+ 'show_in_rest' => true,
+ 'rest_base' => 'listing-status',
+ 'rest_controller_class' => 'WP_REST_Terms_Controller',
+ ),
);
}
@@ -288,33 +302,36 @@ function listing_status_taxonomy() {
*/
function property_type_taxonomy() {
- $name = __( 'Property Types', 'wp-listings' );
+ $name = __( 'Property Types', 'wp-listings' );
$singular_name = __( 'Property Type', 'wp-listings' );
return array(
'property-types' => array(
- 'labels' => array(
- 'name' => strip_tags( $name ),
- 'singular_name' => strip_tags( $singular_name ),
- 'menu_name' => strip_tags( $name ),
-
- 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
- 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
- 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
- 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
- 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) )
+ 'labels' => array(
+ 'name' => strip_tags( $name ),
+ 'singular_name' => strip_tags( $singular_name ),
+ 'menu_name' => strip_tags( $name ),
+
+ 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) ),
),
- 'hierarchical' => true,
- 'rewrite' => array( __( 'property-types', 'wp-listings' ), 'with_front' => false ),
- 'editable' => 0,
- 'show_in_rest' => true,
- 'rest_base' => 'property-types',
- 'rest_controller_class' => 'WP_REST_Terms_Controller'
- )
+ 'hierarchical' => true,
+ 'rewrite' => array(
+ __( 'property-types', 'wp-listings' ),
+ 'with_front' => false,
+ ),
+ 'editable' => 0,
+ 'show_in_rest' => true,
+ 'rest_base' => 'property-types',
+ 'rest_controller_class' => 'WP_REST_Terms_Controller',
+ ),
);
}
@@ -324,33 +341,36 @@ function property_type_taxonomy() {
*/
function listing_location_taxonomy() {
- $name = __( 'Locations', 'wp-listings' );
+ $name = __( 'Locations', 'wp-listings' );
$singular_name = __( 'Location', 'wp-listings' );
return array(
'locations' => array(
- 'labels' => array(
- 'name' => strip_tags( $name ),
- 'singular_name' => strip_tags( $singular_name ),
- 'menu_name' => strip_tags( $name ),
-
- 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
- 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
- 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
- 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
- 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) )
+ 'labels' => array(
+ 'name' => strip_tags( $name ),
+ 'singular_name' => strip_tags( $singular_name ),
+ 'menu_name' => strip_tags( $name ),
+
+ 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) ),
),
- 'hierarchical' => true,
- 'rewrite' => array( __( 'locations', 'wp-listings' ), 'with_front' => false ),
- 'editable' => 0,
- 'show_in_rest' => true,
- 'rest_base' => 'locations',
- 'rest_controller_class' => 'WP_REST_Terms_Controller'
- )
+ 'hierarchical' => true,
+ 'rewrite' => array(
+ __( 'locations', 'wp-listings' ),
+ 'with_front' => false,
+ ),
+ 'editable' => 0,
+ 'show_in_rest' => true,
+ 'rest_base' => 'locations',
+ 'rest_controller_class' => 'WP_REST_Terms_Controller',
+ ),
);
}
@@ -360,33 +380,36 @@ function listing_location_taxonomy() {
*/
function property_features_taxonomy() {
- $name = __( 'Features', 'wp-listings' );
+ $name = __( 'Features', 'wp-listings' );
$singular_name = __( 'Feature', 'wp-listings' );
return array(
'features' => array(
- 'labels' => array(
- 'name' => strip_tags( $name ),
- 'singular_name' => strip_tags( $singular_name ),
- 'menu_name' => strip_tags( $name ),
-
- 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
- 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
- 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
- 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
- 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
- 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) )
+ 'labels' => array(
+ 'name' => strip_tags( $name ),
+ 'singular_name' => strip_tags( $singular_name ),
+ 'menu_name' => strip_tags( $name ),
+
+ 'search_items' => sprintf( __( 'Search %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'popular_items' => sprintf( __( 'Popular %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'all_items' => sprintf( __( 'All %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'edit_item' => sprintf( __( 'Edit %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'update_item' => sprintf( __( 'Update %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_new_item' => sprintf( __( 'Add New %s', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'new_item_name' => sprintf( __( 'New %s Name', 'wp-listings' ), strip_tags( $singular_name ) ),
+ 'add_or_remove_items' => sprintf( __( 'Add or Remove %s', 'wp-listings' ), strip_tags( $name ) ),
+ 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'wp-listings' ), strip_tags( $name ) ),
),
- 'hierarchical' => 0,
- 'rewrite' => array( __( 'features', 'wp-listings' ), 'with_front' => false ),
- 'editable' => 0,
- 'show_in_rest' => true,
- 'rest_base' => 'features',
- 'rest_controller_class' => 'WP_REST_Terms_Controller'
- )
+ 'hierarchical' => 0,
+ 'rewrite' => array(
+ __( 'features', 'wp-listings' ),
+ 'with_front' => false,
+ ),
+ 'editable' => 0,
+ 'show_in_rest' => true,
+ 'rest_base' => 'features',
+ 'rest_controller_class' => 'WP_REST_Terms_Controller',
+ ),
);
}
@@ -396,7 +419,7 @@ function property_features_taxonomy() {
*/
function register_taxonomies() {
- foreach( (array) $this->get_taxonomies() as $id => $data ) {
+ foreach ( (array) $this->get_taxonomies() as $id => $data ) {
register_taxonomy( $id, array( 'listing' ), $data );
}
@@ -413,33 +436,54 @@ function get_taxonomies() {
/**
* Create the default terms
+ *
* @uses wp_listings_default_status_terms filter to add or remove default taxonomy terms
* @uses wp_listings_default_property_type_terms filter to add or remove default taxonomy terms
*/
function create_terms() {
/** Default terms for status */
- $status_terms = apply_filters( 'wp_listings_default_status_terms', array('Active' => 'active', 'Pending' => 'pending', 'For Rent' => 'for-rent', 'Sold' => 'sold', 'Featured' => 'featured', 'New' => 'new', 'Reduced' => 'reduced') );
- foreach ($status_terms as $term => $slug) {
- if (term_exists($term, 'status')) {
+ $status_terms = apply_filters(
+ 'wp_listings_default_status_terms',
+ array(
+ 'Active' => 'active',
+ 'Pending' => 'pending',
+ 'For Rent' => 'for-rent',
+ 'Sold' => 'sold',
+ 'Featured' => 'featured',
+ 'New' => 'new',
+ 'Reduced' => 'reduced',
+ )
+ );
+ foreach ( $status_terms as $term => $slug ) {
+ if ( term_exists( $term, 'status' ) ) {
continue;
}
- wp_insert_term($term,'status',array('slug' => $slug));
+ wp_insert_term( $term, 'status', array( 'slug' => $slug ) );
}
/** Default terms for property-type */
- $property_type_terms = apply_filters( 'wp_listings_default_property_type_terms', array('Residential' => 'residential', 'Condo' => 'condo', 'Townhome' => 'townhome', 'Commercial' => 'commercial' ) );
- foreach ($property_type_terms as $term => $slug) {
- if (term_exists($term, 'property-types')) {
+ $property_type_terms = apply_filters(
+ 'wp_listings_default_property_type_terms',
+ array(
+ 'Residential' => 'residential',
+ 'Condo' => 'condo',
+ 'Townhome' => 'townhome',
+ 'Commercial' => 'commercial',
+ )
+ );
+ foreach ( $property_type_terms as $term => $slug ) {
+ if ( term_exists( $term, 'property-types' ) ) {
continue;
}
- wp_insert_term($term,'property-types', array('slug' => $slug));
+ wp_insert_term( $term, 'property-types', array( 'slug' => $slug ) );
}
}
/**
* Register term meta for a featured image
+ *
* @return [type] [description]
*/
function register_term_meta() {
@@ -448,6 +492,7 @@ function register_term_meta() {
/**
* Callback to retrieve the term image
+ *
* @return [type] [description]
*/
function wp_listings_sanitize_term_image( $wpl_term_image ) {
@@ -456,6 +501,7 @@ function wp_listings_sanitize_term_image( $wpl_term_image ) {
/**
* Get the term featured image id
+ *
* @param $html bool whether to use html wrapper
* @uses wp_get_attachment_image to return image id wrapped in markup
*/
@@ -466,35 +512,38 @@ function wp_listings_get_term_image( $term_id, $html = true ) {
/**
* Save the image uploaded
+ *
* @param string $term_id term slug
*/
function wp_listings_save_term_image( $term_id ) {
- if ( ! isset( $_POST['wpl_term_image_nonce'] ) || ! wp_verify_nonce( $_POST['wpl_term_image_nonce'], basename( __FILE__ ) ) )
- return;
+ if ( ! isset( $_POST['wpl_term_image_nonce'] ) || ! wp_verify_nonce( $_POST['wpl_term_image_nonce'], basename( __FILE__ ) ) ) {
+ return;
+ }
- $old_image = $this->wp_listings_get_term_image( $term_id );
- $new_image = isset( $_POST['wpl-term-image'] ) ? $_POST['wpl-term-image'] : '';
+ $old_image = $this->wp_listings_get_term_image( $term_id );
+ $new_image = isset( $_POST['wpl-term-image'] ) ? $_POST['wpl-term-image'] : '';
- if ( $old_image && '' === $new_image )
- delete_term_meta( $term_id, 'wpl_term_image' );
+ if ( $old_image && '' === $new_image ) {
+ delete_term_meta( $term_id, 'wpl_term_image' );
- else if ( $old_image !== $new_image )
- update_term_meta( $term_id, 'wpl_term_image', $new_image );
+ } elseif ( $old_image !== $new_image ) {
+ update_term_meta( $term_id, 'wpl_term_image', $new_image );
+ }
- return $term_id;
+ return $term_id;
}
/**
* Filter the edit term columns
*/
-
+
function wp_listings_edit_term_columns( $columns ) {
- $columns['wpl_term_image'] = __( 'Image', 'wp-listings' );
+ $columns['wpl_term_image'] = __( 'Image', 'wp-listings' );
- return $columns;
+ return $columns;
}
/**
@@ -502,19 +551,20 @@ function wp_listings_edit_term_columns( $columns ) {
*/
function wp_listings_manage_term_custom_column( $out, $column, $term_id ) {
- if ( 'wpl_term_image' === $column ) {
+ if ( 'wpl_term_image' === $column ) {
- $image_id = $this->wp_listings_get_term_image( $term_id, false );
+ $image_id = $this->wp_listings_get_term_image( $term_id, false );
- if (!$image_id)
- return $out;
+ if ( ! $image_id ) {
+ return $out;
+ }
- $image_markup = wp_get_attachment_image( $image_id, 'thumbnail', true, array('class' => 'wpl-term-image'));
+ $image_markup = wp_get_attachment_image( $image_id, 'thumbnail', true, array( 'class' => 'wpl-term-image' ) );
- $out = $image_markup;
- }
+ $out = $image_markup;
+ }
- return $out;
+ return $out;
}
/**
@@ -522,21 +572,23 @@ function wp_listings_manage_term_custom_column( $out, $column, $term_id ) {
*/
function wp_listings_filter_post_type_by_taxonomy() {
global $typenow;
- $post_type = 'listing';
- $taxonomies = array('property-types', 'status', 'locations');
- foreach($taxonomies as $taxonomy) {
- if ($typenow == $post_type) {
- $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
- $info_taxonomy = get_taxonomy($taxonomy);
- wp_dropdown_categories(array(
- 'show_option_all' => __("Show All {$info_taxonomy->label}"),
- 'taxonomy' => $taxonomy,
- 'name' => $taxonomy,
- 'orderby' => 'name',
- 'selected' => $selected,
- 'show_count' => true,
- 'hide_empty' => true,
- ));
+ $post_type = 'listing';
+ $taxonomies = array( 'property-types', 'status', 'locations' );
+ foreach ( $taxonomies as $taxonomy ) {
+ if ( $typenow == $post_type ) {
+ $selected = isset( $_GET[ $taxonomy ] ) ? $_GET[ $taxonomy ] : '';
+ $info_taxonomy = get_taxonomy( $taxonomy );
+ wp_dropdown_categories(
+ array(
+ 'show_option_all' => __( "Show All {$info_taxonomy->label}" ),
+ 'taxonomy' => $taxonomy,
+ 'name' => $taxonomy,
+ 'orderby' => 'name',
+ 'selected' => $selected,
+ 'show_count' => true,
+ 'hide_empty' => true,
+ )
+ );
};
}
}
@@ -544,15 +596,15 @@ function wp_listings_filter_post_type_by_taxonomy() {
/**
* Filter posts by taxonomy in admin
*/
- function wp_listings_convert_id_to_term_in_query($query) {
+ function wp_listings_convert_id_to_term_in_query( $query ) {
global $pagenow;
- $post_type = 'listing';
- $taxonomies = array('property-types', 'status', 'locations');
- $q_vars = &$query->query_vars;
- foreach($taxonomies as $taxonomy) {
- if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
- $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
- $q_vars[$taxonomy] = $term->slug;
+ $post_type = 'listing';
+ $taxonomies = array( 'property-types', 'status', 'locations' );
+ $q_vars = &$query->query_vars;
+ foreach ( $taxonomies as $taxonomy ) {
+ if ( $pagenow == 'edit.php' && isset( $q_vars['post_type'] ) && $q_vars['post_type'] == $post_type && isset( $q_vars[ $taxonomy ] ) && is_numeric( $q_vars[ $taxonomy ] ) && $q_vars[ $taxonomy ] != 0 ) {
+ $term = get_term_by( 'id', $q_vars[ $taxonomy ], $taxonomy );
+ $q_vars[ $taxonomy ] = $term->slug;
}
}
}
@@ -562,13 +614,13 @@ function wp_listings_convert_id_to_term_in_query($query) {
*/
function wp_listings_new_term_image_field( $term ) {
- $image_id = '';
+ $image_id = '';
- wp_nonce_field( basename( __FILE__ ), 'wpl_term_image_nonce' ); ?>
+ wp_nonce_field( basename( __FILE__ ), 'wpl_term_image_nonce' ); ?>
-
-
-
+
-
+ wp_listings_get_term_image( $term->term_id, false );
- $image_url = wp_get_attachment_url($image_id);
+ $image_id = $this->wp_listings_get_term_image( $term->term_id, false );
+ $image_url = wp_get_attachment_url( $image_id );
- if ( ! $image_url )
- $image_url = ''; ?>
+ if ( ! $image_url ) {
+ $image_url = '';
+ }
+ ?>
-
- |
-
-
-
+ |
+ |
+
+
+
@@ -602,30 +657,33 @@ function wp_listings_edit_term_image_field( $term ) {
- |
-
-
+
+
+ }
+ ?>
-
+
@@ -637,24 +695,24 @@ function tax_reorder() {
- is_search && get_post_type() == 'listing' ) {
- if ( file_exists(get_stylesheet_directory() . '/search-' . $post_type . '.php') ) {
+ if ( file_exists( get_stylesheet_directory() . '/search-' . $post_type . '.php' ) ) {
$template = get_stylesheet_directory() . '/search-' . $post_type . '.php';
return $template;
} else {
return dirname( __FILE__ ) . '/views/archive-' . $post_type . '.php';
}
}
- if ( wp_listings_is_taxonomy_of($post_type) ) {
- if ( file_exists(get_stylesheet_directory() . '/taxonomy-' . $post_type . '.php' ) ) {
- return get_stylesheet_directory() . '/taxonomy-' . $post_type . '.php';
- } elseif ( file_exists(get_stylesheet_directory() . '/archive-' . $post_type . '.php' ) ) {
- return get_stylesheet_directory() . '/archive-' . $post_type . '.php';
- } else {
- return dirname( __FILE__ ) . '/views/archive-' . $post_type . '.php';
- }
- }
+ if ( wp_listings_is_taxonomy_of( $post_type ) ) {
+ if ( file_exists( get_stylesheet_directory() . '/taxonomy-' . $post_type . '.php' ) ) {
+ return get_stylesheet_directory() . '/taxonomy-' . $post_type . '.php';
+ } elseif ( file_exists( get_stylesheet_directory() . '/archive-' . $post_type . '.php' ) ) {
+ return get_stylesheet_directory() . '/archive-' . $post_type . '.php';
+ } else {
+ return dirname( __FILE__ ) . '/views/archive-' . $post_type . '.php';
+ }
+ }
if ( is_post_type_archive( $post_type ) ) {
- if ( file_exists(get_stylesheet_directory() . '/archive-' . $post_type . '.php') ) {
+ if ( file_exists( get_stylesheet_directory() . '/archive-' . $post_type . '.php' ) ) {
$template = get_stylesheet_directory() . '/archive-' . $post_type . '.php';
return $template;
} else {
@@ -49,17 +48,17 @@ function wp_listings_template_include( $template ) {
/** Prevent directory traversal */
$custom_template = str_replace( '..', '', $custom_template );
- if( ! $custom_template )
- if( file_exists(get_stylesheet_directory() . '/single-' . $post_type . '.php') )
+ if ( ! $custom_template ) {
+ if ( file_exists( get_stylesheet_directory() . '/single-' . $post_type . '.php' ) ) {
return $template;
- else
+ } else {
return dirname( __FILE__ ) . '/views/single-' . $post_type . '.php';
- else
- if( file_exists( get_stylesheet_directory() . "/{$custom_template}" ) )
+ }
+ } elseif ( file_exists( get_stylesheet_directory() . "/{$custom_template}" ) ) {
$template = get_stylesheet_directory() . "/{$custom_template}";
- elseif( file_exists( get_template_directory() . "/{$custom_template}" ) )
- $template = get_template_directory() . "/{$custom_template}";
-
+ } elseif ( file_exists( get_template_directory() . "/{$custom_template}" ) ) {
+ $template = get_template_directory() . "/{$custom_template}";
+ }
}
return $template;
@@ -68,23 +67,23 @@ function wp_listings_template_include( $template ) {
/**
* Controls output of default state for the state custom field if there is one set
*/
-function wp_listings_get_state($post_id = null) {
- $options = get_option('plugin_wp_listings_settings');
+function wp_listings_get_state( $post_id = null ) {
+ $options = get_option( 'plugin_wp_listings_settings' );
if ( null == $post_id ) {
global $post;
$post_id = $post->ID;
}
- $state = get_post_meta($post_id, '_listing_state', true);
- if (isset($options['wp_listings_default_state'])) {
+ $state = get_post_meta( $post_id, '_listing_state', true );
+ if ( isset( $options['wp_listings_default_state'] ) ) {
$default_state = $options['wp_listings_default_state'];
}
- if ( empty($default_state) ) {
+ if ( empty( $default_state ) ) {
$default_state = 'ST';
}
- if ( empty($state) ) {
+ if ( empty( $state ) ) {
return $default_state;
}
@@ -93,13 +92,13 @@ function wp_listings_get_state($post_id = null) {
/**
* Controls output of city name
*/
-function wp_listings_get_city($post_id = null) {
+function wp_listings_get_city( $post_id = null ) {
if ( null == $post_id ) {
global $post;
$post_id = $post->ID;
}
- $city = get_post_meta($post_id, '_listing_city', true);
+ $city = get_post_meta( $post_id, '_listing_city', true );
if ( '' == $city ) {
$city = 'Cityname';
}
@@ -109,13 +108,13 @@ function wp_listings_get_city($post_id = null) {
/**
* Controls output of address
*/
-function wp_listings_get_address($post_id = null) {
+function wp_listings_get_address( $post_id = null ) {
if ( null == $post_id ) {
global $post;
$post_id = $post->ID;
}
- $address = get_post_meta($post_id, '_listing_address', true);
+ $address = get_post_meta( $post_id, '_listing_address', true );
if ( '' == $address ) {
$address = 'Address Unavailable';
}
@@ -125,22 +124,22 @@ function wp_listings_get_address($post_id = null) {
/**
* Displays the status (active, pending, sold, for rent) of a listing
*/
-function wp_listings_get_status($post_id = null, $single = 0) {
+function wp_listings_get_status( $post_id = null, $single = 0 ) {
if ( null == $post_id ) {
global $post;
$post_id = $post->ID;
}
- $listing_status = wp_get_object_terms($post_id, 'status');
- if ( empty($listing_status) || is_wp_error($listing_status) ) {
+ $listing_status = wp_get_object_terms( $post_id, 'status' );
+ if ( empty( $listing_status ) || is_wp_error( $listing_status ) ) {
return;
}
$status = null;
- foreach($listing_status as $term) {
- if ( $term->name != 'Featured') {
+ foreach ( $listing_status as $term ) {
+ if ( $term->name != 'Featured' ) {
$status .= $term->name;
- if($single == 0) {
+ if ( $single == 0 ) {
return $status;
}
$status .= '
';
@@ -152,51 +151,51 @@ function wp_listings_get_status($post_id = null, $single = 0) {
/**
* Displays the property type (residential, condo, comemrcial, etc) of a listing
*/
-function wp_listings_get_property_types($post_id = null) {
+function wp_listings_get_property_types( $post_id = null ) {
if ( null == $post_id ) {
global $post;
$post_id = $post->ID;
}
- $listing_property_types = wp_get_object_terms($post_id, 'property-types');
- if ( empty($listing_property_types) || is_wp_error($listing_property_types) ) {
+ $listing_property_types = wp_get_object_terms( $post_id, 'property-types' );
+ if ( empty( $listing_property_types ) || is_wp_error( $listing_property_types ) ) {
return;
}
- foreach($listing_property_types as $type) {
+ foreach ( $listing_property_types as $type ) {
return $type->name;
}
}
/**
* Displays the location term of a listing
*/
-function wp_listings_get_locations($post_id = null) {
+function wp_listings_get_locations( $post_id = null ) {
if ( null == $post_id ) {
global $post;
$post_id = $post->ID;
}
- $listing_locations = wp_get_object_terms($post_id, 'locations');
- if ( empty($listing_locations) || is_wp_error($listing_locations) ) {
+ $listing_locations = wp_get_object_terms( $post_id, 'locations' );
+ if ( empty( $listing_locations ) || is_wp_error( $listing_locations ) ) {
return;
}
- foreach($listing_locations as $location) {
+ foreach ( $listing_locations as $location ) {
return $location->name;
}
}
function wp_listings_post_number( $query ) {
- if ( !$query->is_main_query() || is_admin() || !is_post_type_archive('listing') ) {
+ if ( ! $query->is_main_query() || is_admin() || ! is_post_type_archive( 'listing' ) ) {
return;
}
- $options = get_option('plugin_wp_listings_settings');
+ $options = get_option( 'plugin_wp_listings_settings' );
$archive_posts_num = $options['wp_listings_archive_posts_num'];
- if ( empty($archive_posts_num) ) {
+ if ( empty( $archive_posts_num ) ) {
$archive_posts_num = '9';
}
@@ -211,44 +210,46 @@ function wp_listings_post_number( $query ) {
add_filter( 'dashboard_glance_items', 'impress_listings_glance_items', 10, 1 );
function impress_listings_glance_items( $items = array() ) {
- $post_types = array( 'listing' );
+ $post_types = array( 'listing' );
- foreach( $post_types as $type ) {
+ foreach ( $post_types as $type ) {
- if( ! post_type_exists( $type ) ) continue;
+ if ( ! post_type_exists( $type ) ) {
+ continue;
+ }
- $num_posts = wp_count_posts( $type );
+ $num_posts = wp_count_posts( $type );
- if( $num_posts ) {
+ if ( $num_posts ) {
- $published = intval( $num_posts->publish );
- $post_type = get_post_type_object( $type );
+ $published = intval( $num_posts->publish );
+ $post_type = get_post_type_object( $type );
- $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'wp-listings' );
- $text = sprintf( $text, number_format_i18n( $published ) );
+ $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'wp-listings' );
+ $text = sprintf( $text, number_format_i18n( $published ) );
- if ( current_user_can( $post_type->cap->edit_posts ) ) {
- $items[] = sprintf( '
%2$s', $type, $text ) . "\n";
- } else {
- $items[] = sprintf( '
%2$s', $type, $text ) . "\n";
- }
- }
- }
+ if ( current_user_can( $post_type->cap->edit_posts ) ) {
+ $items[] = sprintf( '
%2$s', $type, $text ) . "\n";
+ } else {
+ $items[] = sprintf( '
%2$s', $type, $text ) . "\n";
+ }
+ }
+ }
- return $items;
+ return $items;
}
/**
* Better Jetpack Related Posts Support for Listings
*/
function wp_listings_jetpack_relatedposts( $headline ) {
- if ( is_singular( 'listing' ) ) {
- $headline = sprintf(
- '
%s
',
- esc_html( 'Similar Listings' )
- );
- }
- return $headline;
+ if ( is_singular( 'listing' ) ) {
+ $headline = sprintf(
+ '
%s
',
+ esc_html( 'Similar Listings' )
+ );
+ }
+ return $headline;
}
add_filter( 'jetpack_relatedposts_filter_headline', 'wp_listings_jetpack_relatedposts' );
@@ -270,11 +271,12 @@ function wp_listings_jetpack_sitemap() {
/**
* Function to return term image for use on front end
- * @param num $term_id the id of the term
+ *
+ * @param num $term_id the id of the term
* @param boolean $html use html wrapper with wp_get_attachment_image
* @return mixed the image with html markup or the image id
*/
function wp_listings_term_image( $term_id, $html = true, $size = 'full' ) {
$image_id = get_term_meta( $term_id, 'wpl_term_image', true );
- return $image_id && $html ? wp_get_attachment_image( $image_id, $size, false, array('class' => 'wp-listings-term-image') ) : $image_id;
+ return $image_id && $html ? wp_get_attachment_image( $image_id, $size, false, array( 'class' => 'wp-listings-term-image' ) ) : $image_id;
}
diff --git a/includes/helpers.php b/includes/helpers.php
index 43655f2..dc77111 100755
--- a/includes/helpers.php
+++ b/includes/helpers.php
@@ -6,17 +6,18 @@
* Adds the taxonomy title and a list of the terms associated with that taxonomy
* used in custom post type templates.
*/
-function wp_listings_list_terms($taxonomy) {
- $the_tax_object = get_taxonomy($taxonomy);
- $terms = get_terms($taxonomy);
- $term_list = '';
-
- $count = count($terms); $i=0;
- if ($count > 0) {
- foreach ($terms as $term) {
- $i++;
- $term_list .= '
' . $term->name . ' (' . $term->count . ')';
- }
+function wp_listings_list_terms( $taxonomy ) {
+ $the_tax_object = get_taxonomy( $taxonomy );
+ $terms = get_terms( $taxonomy );
+ $term_list = '';
+
+ $count = count( $terms );
+ $i = 0;
+ if ( $count > 0 ) {
+ foreach ( $terms as $term ) {
+ $i++;
+ $term_list .= '
' . $term->name . ' (' . $term->count . ')';
+ }
echo '
';
echo '
' . $the_tax_object->label . '
';
echo "
";
@@ -28,11 +29,11 @@ function wp_listings_list_terms($taxonomy) {
/**
* Returns true if the queried taxonomy is a taxonomy of the given post type
*/
-function wp_listings_is_taxonomy_of($post_type) {
- $taxonomies = get_object_taxonomies($post_type);
- $queried_tax = get_query_var('taxonomy');
+function wp_listings_is_taxonomy_of( $post_type ) {
+ $taxonomies = get_object_taxonomies( $post_type );
+ $queried_tax = get_query_var( 'taxonomy' );
- if ( in_array($queried_tax, $taxonomies) ) {
+ if ( in_array( $queried_tax, $taxonomies ) ) {
return true;
}
@@ -98,27 +99,29 @@ function wp_listings_paging_nav() {
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
// Set up paginated links.
- $links = paginate_links( array(
- 'base' => $pagenum_link,
- 'format' => $format,
- 'total' => $GLOBALS['wp_query']->max_num_pages,
- 'current' => $paged,
- 'mid_size' => 1,
- 'add_args' => array_map( 'urlencode', $query_args ),
- 'prev_text' => __( '← Previous', 'wp-listings' ),
- 'next_text' => __( 'Next →', 'wp-listings' ),
- ) );
+ $links = paginate_links(
+ array(
+ 'base' => $pagenum_link,
+ 'format' => $format,
+ 'total' => $GLOBALS['wp_query']->max_num_pages,
+ 'current' => $paged,
+ 'mid_size' => 1,
+ 'add_args' => array_map( 'urlencode', $query_args ),
+ 'prev_text' => __( '← Previous', 'wp-listings' ),
+ 'next_text' => __( 'Next →', 'wp-listings' ),
+ )
+ );
if ( $links ) :
- ?>
+ ?>
- 6 ) ? 6 : (int)$columns;
-
- // column class
- switch ($columns) {
- case 0:
- case 1:
- $column_class = '';
- break;
- case 2:
- $column_class = 'one-half';
- break;
- case 3:
- $column_class = 'one-third';
- break;
- case 4:
- $column_class = 'one-fourth';
- break;
- case 5:
- $column_class = 'one-fifth';
- break;
- case 6:
- $column_class = 'one-sixth';
- break;
- }
-
- return $column_class;
+function get_column_class( $columns ) {
+ $column_class = '';
+
+ // Max of six columns
+ $columns = ( $columns > 6 ) ? 6 : (int) $columns;
+
+ // column class
+ switch ( $columns ) {
+ case 0:
+ case 1:
+ $column_class = '';
+ break;
+ case 2:
+ $column_class = 'one-half';
+ break;
+ case 3:
+ $column_class = 'one-third';
+ break;
+ case 4:
+ $column_class = 'one-fourth';
+ break;
+ case 5:
+ $column_class = 'one-fifth';
+ break;
+ case 6:
+ $column_class = 'one-sixth';
+ break;
+ }
+
+ return $column_class;
}
diff --git a/includes/recaptcha.php b/includes/recaptcha.php
index 397026c..5aabcff 100644
--- a/includes/recaptcha.php
+++ b/includes/recaptcha.php
@@ -1,38 +1,45 @@
'',
- 'taxonomy' => '',
- 'term' => '',
- 'limit' => '',
- 'columns' => ''
- ), $atts ) );
+function wp_listings_shortcode( $atts, $content = null ) {
+ extract(
+ shortcode_atts(
+ array(
+ 'id' => '',
+ 'taxonomy' => '',
+ 'term' => '',
+ 'limit' => '',
+ 'columns' => '',
+ ),
+ $atts
+ )
+ );
/**
* if limit is empty set to all
*/
- if(!$limit) {
+ if ( ! $limit ) {
$limit = -1;
}
/**
* if columns is empty set to 0
*/
- if(!$columns) {
+ if ( ! $columns ) {
$columns = 0;
}
@@ -33,28 +38,28 @@ function wp_listings_shortcode($atts, $content = null) {
* query args based on parameters
*/
$query_args = array(
- 'post_type' => 'listing',
- 'posts_per_page' => $limit
+ 'post_type' => 'listing',
+ 'posts_per_page' => $limit,
);
- if($id) {
+ if ( $id ) {
$query_args = array(
- 'post_type' => 'listing',
- 'post__in' => explode(',', $id)
+ 'post_type' => 'listing',
+ 'post__in' => explode( ',', $id ),
);
}
- if($term && $taxonomy) {
+ if ( $term && $taxonomy ) {
$query_args = array(
- 'post_type' => 'listing',
- 'posts_per_page' => $limit,
- 'tax_query' => array(
+ 'post_type' => 'listing',
+ 'posts_per_page' => $limit,
+ 'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
- 'terms' => $term
- )
- )
+ 'terms' => $term,
+ ),
+ ),
);
}
@@ -69,16 +74,17 @@ function wp_listings_shortcode($atts, $content = null) {
$output = '
';
- foreach ( $listings_array as $post ) : setup_postdata( $post );
+ foreach ( $listings_array as $post ) :
+ setup_postdata( $post );
$count = ( $count == $columns ) ? 1 : $count + 1;
$first_class = ( 1 == $count ) ? 'first' : '';
- $output .= '
' . get_the_post_thumbnail( $post->ID, 'listings' ) . '';
+ $output .= '
';
if ( '' != get_post_meta( $post->ID, '_listing_open_house', true ) ) {
- $output .= '
' . __( "Open House", 'wp-listings' ) . ': ' . get_post_meta( $post->ID, '_listing_open_house', true ) . '';
+ $output .= '
' . __( 'Open House', 'wp-listings' ) . ': ' . get_post_meta( $post->ID, '_listing_open_house', true ) . '';
}
$output .= '
';
@@ -116,20 +122,26 @@ function wp_listings_shortcode($atts, $content = null) {
wp_reset_postdata();
return $output;
-
+
}
-add_shortcode('wp_listings_meta', 'wp_listings_meta_shortcode');
+add_shortcode( 'wp_listings_meta', 'wp_listings_meta_shortcode' );
/**
* Returns meta data for listings
+ *
* @param array $atts meta key
* @return string meta value wrapped in span
*/
-function wp_listings_meta_shortcode($atts) {
- extract(shortcode_atts(array(
- 'key' => ''
- ), $atts ) );
+function wp_listings_meta_shortcode( $atts ) {
+ extract(
+ shortcode_atts(
+ array(
+ 'key' => '',
+ ),
+ $atts
+ )
+ );
$postid = get_the_id();
- return '
' . get_post_meta($postid, '_listing_' . $key, true) . '';
+ return '
' . get_post_meta( $postid, '_listing_' . $key, true ) . '';
}
diff --git a/includes/views/agentevo-metabox.php b/includes/views/agentevo-metabox.php
index 799252a..c74c814 100755
--- a/includes/views/agentevo-metabox.php
+++ b/includes/views/agentevo-metabox.php
@@ -1,2 +1,2 @@

';
\ No newline at end of file
+echo '

';
diff --git a/includes/views/archive-listing.php b/includes/views/archive-listing.php
index b9f87d2..16745ee 100755
--- a/includes/views/archive-listing.php
+++ b/includes/views/archive-listing.php
@@ -16,69 +16,68 @@ function archive_listing_loop() {
// Uncomment to use term image in your theme
// echo '
' . wp_listings_term_image(get_queried_object()->term_id, true, 'full') . '
';
-
// Start the Loop.
- while ( have_posts() ) : the_post();
-
- $count++; // add 1 to counter on each loop
- $first = ($count == 1) ? 'first' : ''; // if counter is 1 add class of first
+ while ( have_posts() ) :
+ the_post();
+ $count++; // add 1 to counter on each loop
+ $first = ( $count == 1 ) ? 'first' : ''; // if counter is 1 add class of first
- $loop = sprintf( '
' );
- if ( '' != get_post_meta( $post->ID, '_listing_open_house', true ) ) {
- $loop .= sprintf( '
Open House: %s', get_post_meta( $post->ID, '_listing_open_house', true ) );
- }
+ if ( '' != get_post_meta( $post->ID, '_listing_open_house', true ) ) {
+ $loop .= sprintf( '
Open House: %s', get_post_meta( $post->ID, '_listing_open_house', true ) );
+ }
- $loop .= sprintf( '
', get_permalink(), get_the_title() );
- $loop .= sprintf( '
%s
', wp_listings_get_address() );
- $loop .= sprintf( '%s, %s %s
', wp_listings_get_city(), wp_listings_get_state(), get_post_meta( $post->ID, '_listing_zip', true ) );
+ $loop .= sprintf( '
', get_permalink(), get_the_title() );
+ $loop .= sprintf( '
%s
', wp_listings_get_address() );
+ $loop .= sprintf( '%s, %s %s
', wp_listings_get_city(), wp_listings_get_state(), get_post_meta( $post->ID, '_listing_zip', true ) );
- if ( '' != get_post_meta( $post->ID, '_listing_bedrooms', true ) || '' != get_post_meta( $post->ID, '_listing_bathrooms', true ) || '' != get_post_meta( $post->ID, '_listing_sqft', true )) {
- $loop .= sprintf( '
', get_post_meta( $post->ID, '_listing_bedrooms', true ), get_post_meta( $post->ID, '_listing_bathrooms', true ), get_post_meta( $post->ID, '_listing_sqft', true ) );
- }
+ if ( '' != get_post_meta( $post->ID, '_listing_bedrooms', true ) || '' != get_post_meta( $post->ID, '_listing_bathrooms', true ) || '' != get_post_meta( $post->ID, '_listing_sqft', true ) ) {
+ $loop .= sprintf( '
', get_post_meta( $post->ID, '_listing_bedrooms', true ), get_post_meta( $post->ID, '_listing_bathrooms', true ), get_post_meta( $post->ID, '_listing_sqft', true ) );
+ }
- $loop .= sprintf('
');
+ $loop .= sprintf( '
' );
- $loop .= sprintf( '
%s', get_permalink(), __( 'View Listing', 'wp-listings' ) );
+ $loop .= sprintf( '
%s', get_permalink(), __( 'View Listing', 'wp-listings' ) );
- /** wrap in div with column class, and output **/
- printf( '
%s
', get_the_id(), $first, apply_filters( 'wp_listings_featured_listings_widget_loop', $loop ) );
+ /** wrap in div with column class, and output */
+ printf( '
%s
', get_the_id(), $first, apply_filters( 'wp_listings_featured_listings_widget_loop', $loop ) );
- if ( 3 == $count ) { // if counter is 3, reset to 0
- $count = 0;
- }
+ if ( 3 == $count ) { // if counter is 3, reset to 0
+ $count = 0;
+ }
endwhile;
- if (function_exists('equity')) {
- equity_posts_nav();
- } elseif (function_exists('genesis_init')) {
- genesis_posts_nav();
- } else {
- wp_listings_paging_nav();
- }
+ if ( function_exists( 'equity' ) ) {
+ equity_posts_nav();
+ } elseif ( function_exists( 'genesis_init' ) ) {
+ genesis_posts_nav();
+ } else {
+ wp_listings_paging_nav();
+ }
}
-if (function_exists('equity')) {
+if ( function_exists( 'equity' ) ) {
add_filter( 'equity_pre_get_option_site_layout', '__equity_return_full_width_content' );
remove_action( 'equity_entry_header', 'equity_post_info', 12 );
@@ -89,7 +88,7 @@ function archive_listing_loop() {
equity();
-} elseif (function_exists('genesis_init')) {
+} elseif ( function_exists( 'genesis_init' ) ) {
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
@@ -104,7 +103,7 @@ function archive_listing_loop() {
} else {
-get_header(); ?>
+ get_header(); ?>
@@ -115,20 +114,26 @@ function archive_listing_loop() {
label) ) {
+ if ( ! isset( $object->label ) ) {
$title = '
' . $object->name . '
';
} else {
- $title = '' . get_bloginfo('name') . ' Listings
';
+ $title = '' . get_bloginfo( 'name' ) . ' Listings
';
}
- echo $title; ?>
+ echo $title;
+ ?>
- ',''); } ?>
+
+ ', '' ); }
+ ?>
+
-
-
|
- |
- |
+ |
+ |
@@ -32,9 +32,17 @@
$listing_taxonomies = array_merge( $this->property_features_taxonomy(), $this->listing_status_taxonomy(), $this->property_type_taxonomy(), $this->listing_location_taxonomy(), get_option( $this->settings_field ) );
foreach ( (array) $listing_taxonomies as $id => $data ) :
- ?>
-
- >
+ ?>
+
+
+ >
|
@@ -51,8 +59,8 @@
|
- |
- |
+ |
+ |
@@ -97,4 +105,4 @@
-
\ No newline at end of file
+
diff --git a/includes/views/edit-tax.php b/includes/views/edit-tax.php
index 82d8950..a5d26f4 100755
--- a/includes/views/edit-tax.php
+++ b/includes/views/edit-tax.php
@@ -2,7 +2,7 @@
$options = get_option( $this->settings_field );
if ( array_key_exists( $_REQUEST['id'], (array) $options ) ) {
- $taxonomy = stripslashes_deep( $options[$_REQUEST['id']] );
+ $taxonomy = stripslashes_deep( $options[ $_REQUEST['id'] ] );
} else {
wp_die( __( "Nice try, partner. But that taxonomy doesn't exist or can't be edited. Click back and try again.", 'wp-listings' ) );
}
@@ -39,4 +39,4 @@
-
\ No newline at end of file
+
diff --git a/includes/views/idx-metabox.php b/includes/views/idx-metabox.php
index 3636c60..3f35547 100755
--- a/includes/views/idx-metabox.php
+++ b/includes/views/idx-metabox.php
@@ -1,2 +1,2 @@

';
\ No newline at end of file
+echo '

';
diff --git a/includes/views/listing-details-metabox.php b/includes/views/listing-details-metabox.php
index fa42c72..fc7efff 100755
--- a/includes/views/listing-details-metabox.php
+++ b/includes/views/listing-details-metabox.php
@@ -7,112 +7,116 @@
echo '
';
- foreach ( (array) $this->property_details['col1'] as $label => $key ) {
- printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ) );
- }
+foreach ( (array) $this->property_details['col1'] as $label => $key ) {
+ printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ) );
+}
echo '
';
echo '
';
- foreach ( (array) $this->property_details['col2'] as $label => $key ) {
- printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ) );
- }
+foreach ( (array) $this->property_details['col2'] as $label => $key ) {
+ printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ) );
+}
echo '
';
$pattern = '
';
-_e('
Extended Details:
', 'wp-listings');
+_e( '
Extended Details:
', 'wp-listings' );
echo '
';
- foreach ( (array) $this->extended_property_details['col1'] as $label => $key ) {
- printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ), esc_attr( get_post_meta( $post->ID, $key, true ) ) );
- }
+foreach ( (array) $this->extended_property_details['col1'] as $label => $key ) {
+ printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ), esc_attr( get_post_meta( $post->ID, $key, true ) ) );
+}
echo '
';
echo '
';
- foreach ( (array) $this->extended_property_details['col2'] as $label => $key ) {
- printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ), esc_attr( get_post_meta( $post->ID, $key, true ) ) );
- }
+foreach ( (array) $this->extended_property_details['col2'] as $label => $key ) {
+ printf( $pattern, esc_html( $label ), $key, esc_attr( get_post_meta( $post->ID, $key, true ) ), esc_attr( get_post_meta( $post->ID, $key, true ) ) );
+}
echo '
';
echo '
';
- _e('
Price Options
', 'wp-listings');
- printf( __('
'),
- checked( get_post_meta( $post->ID, '_listing_hide_price', true ), 1, 0 ) );
+ _e( '
Price Options
', 'wp-listings' );
+ printf(
+ __( '
' ),
+ checked( get_post_meta( $post->ID, '_listing_hide_price', true ), 1, 0 )
+ );
- _e('
', 'wp-listings' ), htmlentities( get_post_meta( $post->ID, '_listing_price_alt', true) ) );
-echo '
';
+ _e( '
', 'wp-listings' ), htmlentities( get_post_meta( $post->ID, '_listing_price_alt', true ) ) );
+ echo '
';
-echo '
';
+ echo '
';
- _e('
Custom Overlay Text
', 'wp-listings');
- _e('
', 'wp-listings' ), htmlentities( get_post_meta( $post->ID, '_listing_text', true) ) );
+ _e( '
Custom Overlay Text
', 'wp-listings' );
+ _e( '
', 'wp-listings' ), htmlentities( get_post_meta( $post->ID, '_listing_text', true ) ) );
-echo '
';
+ echo '
';
-echo '
';
+ echo '
';
- _e('
';
+ echo '
';
-echo '
';
+ echo '
';
- _e('
Enter Video or Virtual Tour Embed Code (Jetpack offers several video shortcodes.):
', 'wp-listings');
- printf( __( '
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_video', true) ) );
+ _e( '
Enter Video or Virtual Tour Embed Code (Jetpack offers several video shortcodes.):
', 'wp-listings' );
+ printf( __( '
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_video', true ) ) );
-echo '
';
+ echo '
';
-echo '
';
+ echo '
';
-echo '
';
- _e('
Map Options
', 'wp-listings');
+ echo '
';
+ _e( '
Map Options
', 'wp-listings' );
- if(get_post_meta($post->ID, '_listing_automap', 1) == FALSE) {
- update_post_meta($post->ID, '_listing_automap', 'y');
- }
- printf( __('
Automatically insert map based on latitude/longitude? Will be overridden if a shortode is entered below.
Yes No
'),
+ if ( get_post_meta( $post->ID, '_listing_automap', 1 ) == false ) {
+ update_post_meta( $post->ID, '_listing_automap', 'y' );
+ }
+ printf(
+ __( '
Automatically insert map based on latitude/longitude? Will be overridden if a shortode is entered below.
Yes No
' ),
checked( get_post_meta( $post->ID, '_listing_automap', true ), 'y', 0 ),
- checked( get_post_meta( $post->ID, '_listing_automap', true ), 'n', 0 ) );
-echo '
';
-echo '
';
- printf( __('
Latitude:
', 'wp-listings'), get_post_meta( $post->ID, '_listing_latitude', true) );
-echo '
';
-echo '
';
- printf( __('
Longitude:
', 'wp-listings'), get_post_meta( $post->ID, '_listing_longitude', true) );
-echo '
';
+ checked( get_post_meta( $post->ID, '_listing_automap', true ), 'n', 0 )
+ );
+ echo '
';
+ echo '
';
+ printf( __( '
Latitude:
', 'wp-listings' ), get_post_meta( $post->ID, '_listing_latitude', true ) );
+ echo '
';
+ echo '
';
+ printf( __( '
Longitude:
', 'wp-listings' ), get_post_meta( $post->ID, '_listing_longitude', true ) );
+ echo '
';
- _e('
Or enter Map Embed Code or shortcode from Map plugin (such as Jetpack Shortcodes, Simple Google Maps Short Code or MapPress):
Recommend size: 660x300 (If possible, use 100% width, or your themes content width)
', 'wp-listings');
- printf( __( '
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_map', true) ) );
+ _e( '
Or enter Map Embed Code or shortcode from Map plugin (such as Jetpack Shortcodes, Simple Google Maps Short Code or MapPress):
Recommend size: 660x300 (If possible, use 100% width, or your themes content width)
', 'wp-listings' );
+ printf( __( '
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_map', true ) ) );
-echo '
';
+ echo '
';
-echo '
';
- _e('
Contact Form
', 'wp-listings');
+ echo '
';
+ _e( '
Contact Form
', 'wp-listings' );
- _e('
If you use a Contact Form plugin, you may enter the Contact Form shortcode here. Otherwise, the single listing template will use a default contact form:
', 'wp-listings');
- printf( __( '
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_contact_form', true) ) );
+ _e( '
If you use a Contact Form plugin, you may enter the Contact Form shortcode here. Otherwise, the single listing template will use a default contact form:
', 'wp-listings' );
+ printf( __( '
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_contact_form', true ) ) );
-echo '
';
+ echo '
';
diff --git a/includes/views/listing-features-metabox.php b/includes/views/listing-features-metabox.php
index 1011edc..466edea 100755
--- a/includes/views/listing-features-metabox.php
+++ b/includes/views/listing-features-metabox.php
@@ -5,49 +5,48 @@
echo '
';
- printf( __( '
Featured on (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_featured_on', true) ) );
+ printf( __( '
Featured on (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_featured_on', true ) ) );
echo '
';
// Home Summary
-
echo '
';
- printf( __( '
Home Summary (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_home_sum', true) ) );
+ printf( __( '
Home Summary (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_home_sum', true ) ) );
echo '
';
// Kitchen Summary
echo '
';
- printf( __( '
Kitchen Summary (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_kitchen_sum', true) ) );
+ printf( __( '
Kitchen Summary (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_kitchen_sum', true ) ) );
echo '
';
// Living Room
echo '
';
- printf( __( '
Living Room (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_living_room', true) ) );
+ printf( __( '
Living Room (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_living_room', true ) ) );
echo '
';
// Master Suite
echo '
';
- printf( __( '
Master Suite (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_master_suite', true) ) );
+ printf( __( '
Master Suite (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_master_suite', true ) ) );
echo '
';
// School and Neighborhood Info
echo '
';
- printf( __( '
School and Neighborhood Info (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_school_neighborhood', true) ) );
+ printf( __( '
School and Neighborhood Info (allows shortcodes):
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_school_neighborhood', true ) ) );
echo '
';
// Disclaimer
echo '
';
- printf( __( '
Disclaimer:
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_disclaimer', true) ) );
+ printf( __( '
Disclaimer:
', 'wp-listings' ), 'width: 99%;', htmlentities( get_post_meta( $post->ID, '_listing_disclaimer', true ) ) );
echo '
';
diff --git a/includes/views/reorder-tax.php b/includes/views/reorder-tax.php
index ed4004e..698eed7 100755
--- a/includes/views/reorder-tax.php
+++ b/includes/views/reorder-tax.php
@@ -12,31 +12,32 @@
* @since 0.1.0
*/
-add_action('admin_menu', 'wp_listings_tax_reorder_init', 20);
+add_action( 'admin_menu', 'wp_listings_tax_reorder_init', 20 );
function wp_listings_tax_reorder_init() {
- add_submenu_page( 'edit.php?post_type=listing', __( 'Reorder Taxonomies', 'wp-listings' ), __( 'Reorder Taxonomies', 'wp-listings' ), 'manage_options', 'wplistings-tax-reorder', 'wp_listings_tax_reorder');
+ add_submenu_page( 'edit.php?post_type=listing', __( 'Reorder Taxonomies', 'wp-listings' ), __( 'Reorder Taxonomies', 'wp-listings' ), 'manage_options', 'wplistings-tax-reorder', 'wp_listings_tax_reorder' );
}
add_action( 'admin_enqueue_scripts', 'wp_listings_tax_reorder_enqueue' );
function wp_listings_tax_reorder_enqueue() {
- wp_enqueue_script('jquery-ui-sortable');
+ wp_enqueue_script( 'jquery-ui-sortable' );
}
function wp_listings_tax_reorder() {
- $wp_listings_taxes = get_option('wp_listings_taxonomies');
+ $wp_listings_taxes = get_option( 'wp_listings_taxonomies' );
- if($_POST) {
- $new_order = $_POST['wplistings-tax'];
+ if ( $_POST ) {
+ $new_order = $_POST['wplistings-tax'];
$wp_listings_taxes_reordered = array();
- foreach( $new_order as $tax ) {
- if($wp_listings_taxes[$tax])
- $wp_listings_taxes_reordered[$tax] = $wp_listings_taxes[$tax];
+ foreach ( $new_order as $tax ) {
+ if ( $wp_listings_taxes[ $tax ] ) {
+ $wp_listings_taxes_reordered[ $tax ] = $wp_listings_taxes[ $tax ];
+ }
}
$wp_listings_taxes = $wp_listings_taxes_reordered;
- update_option('wp_listings_taxonomies', $wp_listings_taxes_reordered);
-
+ update_option( 'wp_listings_taxonomies', $wp_listings_taxes_reordered );
+
}
-screen_icon( 'themes' ); ?>
+ screen_icon( 'themes' ); ?>