-
Notifications
You must be signed in to change notification settings - Fork 0
/
easy-zillow-reviews.php
192 lines (155 loc) · 7.57 KB
/
easy-zillow-reviews.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* Special thanks to Brad Vincent <[email protected]> and contributors.
* Selections of the following code were derived from the code from FooGallery, which is licensed GPLv2.
* Used with permission.
*
* @link https://www.boltonstudios.com
* @since 1.1.0
* @package Easy_Zillow_Reviews
*
* @wordpress-plugin
* Plugin Name: Easy Zillow Reviews
* Plugin URI: https://wordpress.org/plugins/easy-zillow-reviews/
* Description: Display reviews from Zillow on your site.
* Version: 1.6.2
* Author: Aaron Bolton
* Author URI: https://www.boltonstudios.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: easy-zillow-reviews
* Domain Path: /languages
*
* @fs_premium_only /premium/
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// The Freemius SDK comes with a special mechanism to auto deactivate the free version when activating the paid one.
if ( function_exists( 'ezrwp_fs' ) ) {
ezrwp_fs()->set_basename( true, __FILE__ );
} else {
if ( ! class_exists( 'Easy_Zillow_Reviews' ) ) {
/**
* Current plugin version.
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'EASY_ZILLOW_REVIEWS_VERSION', '1.6.2' );
define( 'EASY_ZILLOW_REVIEWS_BASENAME', plugin_basename( __FILE__ ) );
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-easy-zillow-reviews-activator.php
*/
function activate_easy_zillow_reviews() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-easy-zillow-reviews-activator.php';
Easy_Zillow_Reviews_Activator::activate();
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-easy-zillow-reviews-deactivator.php
*/
function deactivate_easy_zillow_reviews() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-easy-zillow-reviews-deactivator.php';
Easy_Zillow_Reviews_Deactivator::deactivate();
}
register_activation_hook( __FILE__, 'activate_easy_zillow_reviews' );
register_deactivation_hook( __FILE__, 'deactivate_easy_zillow_reviews' );
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
require plugin_dir_path( __FILE__ ) . 'includes/class-easy-zillow-reviews-base.php';
// Create a helper function for easy SDK access.
function ezrwp_fs(){
global $ezrwp_fs;
if( !isset( $ezrwp_fs ) ){
// Include Freemius SDK.
require_once dirname(__FILE__) . '/freemius/start.php';
$ezrwp_fs = fs_dynamic_init(array(
'id' => '4652',
'slug' => 'easy-zillow-reviews',
'type' => 'plugin',
'public_key' => 'pk_5fa54ca20b9465c9db23a010b43f5',
'is_premium' => true,
'premium_suffix' => 'Premium',
'has_premium_version' => true,
'has_addons' => false,
'has_paid_plans' => true,
'menu' => array(
'slug' => 'easy-zillow-reviews'
),
));
}
return $ezrwp_fs;
}
// Init Freemius.
ezrwp_fs();
// Signal that SDK was initiated.
do_action( 'ezrwp_fs_loaded' );
/**
* Easy_Zillow_Reviews Class
*
* @since 1.1.6
* @package Easy_Zillow_Reviews
* @subpackage Easy_Zillow_Reviews/includes
* @author Aaron Bolton <[email protected]>
*/
class Easy_Zillow_Reviews extends Easy_Zillow_Reviews_Base{
/**
* Initialize the plugin by setting localization, filters, and administration functions.
*/
public function __construct() {
// Load the essential plugin features including settings and admin
$plugin = new Easy_Zillow_Reviews_Base( EASY_ZILLOW_REVIEWS_BASENAME );
/*
* Run the upgrader to migrate values from old option name
* to new option name(s) introduced in v1.1.0
*/
new Easy_Zillow_Reviews_Upgrader();
// Get the Zillow Professional data
$zillow_professional_reviews = new Easy_Zillow_Reviews_Professional();
// Define plugin shortcodes
new Easy_Zillow_Reviews_Professional_Shortcodes( $zillow_professional_reviews );
// Define plugin widget
new Easy_Zillow_Reviews_Professional_Widget_Init( $zillow_professional_reviews );
// Define Gutenberg block
$gutenberg = new Easy_Zillow_Reviews_Gutenberg();
$gutenberg->set_zillow_data( $zillow_professional_reviews );
// Add Zillow Professional reviews to Gutenberg block
$plugin->loader->add_filter( 'ezrwp_render_block', $zillow_professional_reviews, 'update_reviews_in_block', 10, 2 );
// This IF block will be auto removed from the Free version.
if ( ezrwp_fs()->is__premium_only() ) {
// This IF will be executed only if the user in a trial mode or have a valid license.
if ( ezrwp_fs()->can_use_premium_code() ) {
// ... premium only logic ...
require_once plugin_dir_path( __FILE__ ) . 'premium/class-easy-zillow-reviews-premium.php';
// Load Premium Features and pass the plugin object to be modified
new Easy_Zillow_Reviews_Premium( $plugin );
// Get the Zillow Professional data
$zillow_lender_reviews = new Easy_Zillow_Reviews_Lender();
// Define Premium shortcodes
new Easy_Zillow_Reviews_Lender_Shortcodes( $zillow_lender_reviews );
// Define Premium widget
new Easy_Zillow_Reviews_Lender_Widget_Init( $zillow_lender_reviews );
// Add Premium options to Gutenberg block
$plugin->loader->add_filter( 'ezrwp_block_options', $zillow_lender_reviews, 'update_options_in_block', 10, 1 );
// Add Zillow Lender reviews to Gutenberg block
$plugin->loader->add_filter( 'ezrwp_render_block', $zillow_lender_reviews, 'update_reviews_in_block', 10, 2 );
}
}
$plugin->run();
}
}
}
// Run Plugin
new Easy_Zillow_Reviews();
}