| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Extension Abstract |
| 5 |
* |
| 6 |
* @package NotificationX\Extensions |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace NotificationX\Types; |
| 10 |
|
| 11 |
use NotificationX\Core\Rules; |
| 12 |
use NotificationX\Types\Traits\Reviews as TraitsReviews; |
| 13 |
use NotificationX\Extensions\GlobalFields; |
| 14 |
use NotificationX\GetInstance; |
| 15 |
use NotificationX\Modules; |
| 16 |
|
| 17 |
/** |
| 18 |
* Extension Abstract for all Extension. |
| 19 |
* @method static Reviews get_instance($args = null) |
| 20 |
*/ |
| 21 |
class Reviews extends Types { |
| 22 |
/** |
| 23 |
* Instance of Admin |
| 24 |
* |
| 25 |
* @var Admin |
| 26 |
*/ |
| 27 |
use GetInstance; |
| 28 |
use TraitsReviews; |
| 29 |
|
| 30 |
public $priority = 20; |
| 31 |
public $themes = []; |
| 32 |
public $res_themes = []; |
| 33 |
public $module = [ |
| 34 |
'modules_wordpress', |
| 35 |
'modules_woocommerce', |
| 36 |
'modules_reviewx', |
| 37 |
'modules_zapier', |
| 38 |
'modules_freemius', |
| 39 |
]; |
| 40 |
public $default_source = 'wp_reviews'; |
| 41 |
public $default_theme = 'reviews_total-rated'; |
| 42 |
public $link_type = 'review_page'; |
| 43 |
|
| 44 |
|
| 45 |
/** |
| 46 |
* Initially Invoked when initialized. |
| 47 |
*/ |
| 48 |
public function __construct() { |
| 49 |
add_filter('nx_link_types', [$this, 'link_types']); |
| 50 |
parent::__construct(); |
| 51 |
$this->id = 'reviews'; |
| 52 |
} |
| 53 |
|
| 54 |
public function init() { |
| 55 |
parent::init(); |
| 56 |
$this->title = __('Reviews', 'notificationx'); |
| 57 |
$this->themes = [ |
| 58 |
'total-rated' => [ |
| 59 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/total-rated.png', |
| 60 |
'image_shape' => 'square', |
| 61 |
'template' => [ |
| 62 |
'first_param' => 'tag_rated', |
| 63 |
'custom_first_param' => __('Someone', 'notificationx'), |
| 64 |
'second_param' => __('people rated', 'notificationx'), |
| 65 |
'third_param' => 'tag_plugin_name', |
| 66 |
'fourth_param' => 'tag_rating', |
| 67 |
'custom_fourth_param' => __('Some time ago', 'notificationx'), |
| 68 |
] |
| 69 |
], |
| 70 |
'reviewed' => [ |
| 71 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/reviewed.png', |
| 72 |
'image_shape' => 'circle', |
| 73 |
'template' => [ |
| 74 |
'first_param' => 'tag_username', |
| 75 |
'custom_first_param' => __('Someone', 'notificationx'), |
| 76 |
'second_param' => __('just reviewed', 'notificationx'), |
| 77 |
'third_param' => 'tag_plugin_name', |
| 78 |
'fourth_param' => 'tag_rating', |
| 79 |
'custom_fourth_param' => __('Some time ago', 'notificationx'), |
| 80 |
] |
| 81 |
], |
| 82 |
'review_saying' => [ |
| 83 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/saying-review.png', |
| 84 |
'image_shape' => 'circle', |
| 85 |
'template' => [ |
| 86 |
'first_param' => 'tag_username', |
| 87 |
'custom_first_param' => __('Someone', 'notificationx'), |
| 88 |
'second_param' => __('saying', 'notificationx'), |
| 89 |
'third_param' => 'tag_title', |
| 90 |
'custom_third_param' => __('Excellent', 'notificationx'), |
| 91 |
'review_fourth_param' => __('about', 'notificationx'), |
| 92 |
'fifth_param' => 'tag_plugin_name', |
| 93 |
'sixth_param' => 'tag_custom', |
| 94 |
'custom_sixth_param' => __('Try it now', 'notificationx'), |
| 95 |
] |
| 96 |
], |
| 97 |
'review-comment' => [ |
| 98 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/review-with-comment.jpg', |
| 99 |
'image_shape' => 'rounded', |
| 100 |
'template' => [ |
| 101 |
'first_param' => 'tag_username', |
| 102 |
'custom_first_param' => __('Someone', 'notificationx'), |
| 103 |
'second_param' => __('just reviewed', 'notificationx'), |
| 104 |
'third_param' => 'tag_plugin_review', |
| 105 |
'fourth_param' => 'tag_rating', |
| 106 |
'custom_fourth_param' => __('Some time ago', 'notificationx'), |
| 107 |
] |
| 108 |
], |
| 109 |
'review-comment-2' => [ |
| 110 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/review-with-comment-2.jpg', |
| 111 |
'template' => [ |
| 112 |
'first_param' => 'tag_username', |
| 113 |
'custom_first_param' => __('Someone', 'notificationx'), |
| 114 |
'second_param' => __('just reviewed', 'notificationx'), |
| 115 |
'third_param' => 'tag_plugin_review', |
| 116 |
'fourth_param' => 'tag_rating', |
| 117 |
'custom_fourth_param' => __('Some time ago', 'notificationx'), |
| 118 |
] |
| 119 |
], |
| 120 |
'review-comment-3' => [ |
| 121 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/review-with-comment-3.jpg', |
| 122 |
'image_shape' => 'circle', |
| 123 |
'template' => [ |
| 124 |
'first_param' => 'tag_username', |
| 125 |
'custom_first_param' => __('Someone', 'notificationx'), |
| 126 |
'second_param' => __('just reviewed', 'notificationx'), |
| 127 |
'third_param' => 'tag_plugin_review', |
| 128 |
'fourth_param' => 'tag_time', |
| 129 |
'custom_fourth_param' => __('Some time ago', 'notificationx'), |
| 130 |
] |
| 131 |
], |
| 132 |
]; |
| 133 |
$this->res_themes = [ |
| 134 |
'res-theme-one' => [ |
| 135 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_reviews/nx-review-res-theme-1.png', |
| 136 |
'image_shape' => 'square', |
| 137 |
'template' => [ |
| 138 |
'res_first_param' => 'tag_rated', |
| 139 |
'res_second_param' => __('people rated', 'notificationx'), |
| 140 |
'res_third_param' => 'tag_plugin_name', |
| 141 |
], |
| 142 |
'is_pro' => true, |
| 143 |
], |
| 144 |
'res-theme-two' => [ |
| 145 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_reviews/nx-review-res-theme-2.png', |
| 146 |
'image_shape' => 'square', |
| 147 |
'template' => [ |
| 148 |
'res_first_param' => 'tag_username', |
| 149 |
'res_second_param' => __('just reviewed', 'notificationx'), |
| 150 |
'res_third_param' => 'tag_plugin_name', |
| 151 |
], |
| 152 |
'is_pro' => true, |
| 153 |
], |
| 154 |
'res-theme-three' => [ |
| 155 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_reviews/nx-review-res-theme-3.png', |
| 156 |
'image_shape' => 'square', |
| 157 |
'template' => [ |
| 158 |
'res_first_param' => 'tag_username', |
| 159 |
'res_second_param' => __('just reviewed', 'notificationx'), |
| 160 |
'res_third_param' => 'tag_plugin_name', |
| 161 |
], |
| 162 |
'is_pro' => true, |
| 163 |
], |
| 164 |
'rating-res-theme-four' => [ |
| 165 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_reviews/nx-review-res-theme-4.png', |
| 166 |
'image_shape' => 'square', |
| 167 |
'template' => [ |
| 168 |
'res_first_param' => 'tag_username', |
| 169 |
'res_second_param' => __('just reviewed', 'notificationx'), |
| 170 |
'res_third_param' => 'tag_rating', |
| 171 |
], |
| 172 |
'is_pro' => true, |
| 173 |
], |
| 174 |
'rating-res-theme-five' => [ |
| 175 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_reviews/nx-review-res-theme-5.png', |
| 176 |
'image_shape' => 'square', |
| 177 |
'template' => [ |
| 178 |
'res_first_param' => 'tag_username', |
| 179 |
'res_second_param' => __('just reviewed', 'notificationx'), |
| 180 |
'res_third_param' => 'tag_rating', |
| 181 |
], |
| 182 |
'is_pro' => true, |
| 183 |
], |
| 184 |
'rating-res-theme-six' => [ |
| 185 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_reviews/nx-review-res-theme-6.png', |
| 186 |
'image_shape' => 'square', |
| 187 |
'template' => [ |
| 188 |
'res_first_param' => 'tag_username', |
| 189 |
'res_second_param' => __('just reviewed', 'notificationx'), |
| 190 |
'res_third_param' => 'tag_rating', |
| 191 |
], |
| 192 |
'is_pro' => true, |
| 193 |
], |
| 194 |
]; |
| 195 |
|
| 196 |
$this->templates = [ |
| 197 |
'wp_reviews_template_new' => [ |
| 198 |
'first_param' => [ |
| 199 |
'tag_username' => __('Username', 'notificationx'), |
| 200 |
'tag_rated' => __('Rated', 'notificationx'), |
| 201 |
], |
| 202 |
'third_param' => [ |
| 203 |
'tag_plugin_name' => __('Plugin Name', 'notificationx'), |
| 204 |
'tag_plugin_review' => __('Review', 'notificationx'), |
| 205 |
'tag_anonymous_title' => __('Anonymous Title', 'notificationx'), |
| 206 |
], |
| 207 |
'fourth_param' => [ |
| 208 |
'tag_rating' => __('Rating', 'notificationx'), |
| 209 |
'tag_time' => __('Definite Time', 'notificationx'), |
| 210 |
], |
| 211 |
'_themes' => [ |
| 212 |
'reviews_total-rated', |
| 213 |
'reviews_reviewed', |
| 214 |
'reviews_review-comment', |
| 215 |
'reviews_review-comment-2', |
| 216 |
'reviews_review-comment-3', |
| 217 |
], |
| 218 |
], |
| 219 |
'review_saying_template_new' => [ |
| 220 |
'first_param' => [ |
| 221 |
'tag_username' => __('Username', 'notificationx'), |
| 222 |
], |
| 223 |
'third_param' => [ |
| 224 |
'tag_title' => __('Review Title', 'notificationx'), |
| 225 |
'tag_anonymous_title' => __('Anonymous Title', 'notificationx'), |
| 226 |
], |
| 227 |
'fifth_param' => [ |
| 228 |
'tag_plugin_name' => __('Plugin Name', 'notificationx'), |
| 229 |
], |
| 230 |
'sixth_param' => [ |
| 231 |
// @todo maybe add some predefined texts. |
| 232 |
], |
| 233 |
'_themes' => [ |
| 234 |
'reviews_review_saying', |
| 235 |
], |
| 236 |
], |
| 237 |
]; |
| 238 |
add_filter("nx_filtered_entry_{$this->id}", array($this, 'conversion_data'), 11, 2); |
| 239 |
} |
| 240 |
|
| 241 |
/** |
| 242 |
* Hooked to nx_before_metabox_load action. |
| 243 |
* |
| 244 |
* @return void |
| 245 |
*/ |
| 246 |
public function init_fields() { |
| 247 |
parent::init_fields(); |
| 248 |
add_filter('nx_notification_template', [$this, 'review_templates'], 7); |
| 249 |
add_filter('nx_content_trim_length_dependency', [$this, 'content_trim_length_dependency']); |
| 250 |
} |
| 251 |
|
| 252 |
} |
| 253 |
|