| @@ -1,0 +1,284 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Extension Abstract | |
| 5 | + * | |
| 6 | + * @package NotificationX\Extensions | |
| 7 | + */ | |
| 8 | + | |
| 9 | +namespace NotificationX\Types; | |
| 10 | + | |
| 11 | +use NotificationX\Extensions\GlobalFields; | |
| 12 | +use NotificationX\GetInstance; | |
| 13 | +use NotificationX\Modules; | |
| 14 | +use NotificationX\NotificationX; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Extension Abstract for all Extension. | |
| 18 | + * @method static Comments get_instance($args = null) | |
| 19 | + */ | |
| 20 | +class Comments extends Types { | |
| 21 | + /** | |
| 22 | + * Instance of Admin | |
| 23 | + * | |
| 24 | + * @var Admin | |
| 25 | + */ | |
| 26 | + use GetInstance; | |
| 27 | + public $priority = 35; | |
| 28 | + public $module = ['modules_wordpress']; | |
| 29 | + public $id = 'comments'; | |
| 30 | + public $default_source = 'wp_comments'; | |
| 31 | + public $default_theme = 'comments_theme-one'; | |
| 32 | + public $link_type = 'comment_url'; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Initially Invoked when initialized. | |
| 36 | + */ | |
| 37 | + public function __construct() { | |
| 38 | + parent::__construct(); | |
| 39 | + | |
| 40 | + add_filter('nx_link_types', [$this, 'link_types']); | |
| 41 | + } | |
| 42 | + | |
| 43 | + public function init() | |
| 44 | + { | |
| 45 | + parent::init(); | |
| 46 | + $this->title = __('Comments', 'notificationx'); | |
| 47 | + // nx_comment_colored_themes | |
| 48 | + $this->themes = [ | |
| 49 | + 'theme-one' => [ | |
| 50 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/nx-comment-theme-2.jpg', | |
| 51 | + 'image_shape' => 'circle', | |
| 52 | + 'template' => [ | |
| 53 | + 'first_param' => 'tag_name', | |
| 54 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 55 | + 'second_param' => __('commented on', 'notificationx'), | |
| 56 | + 'third_param' => 'tag_post_title', | |
| 57 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 58 | + 'fourth_param' => 'tag_time', | |
| 59 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 60 | + ], | |
| 61 | + ], | |
| 62 | + 'theme-two' => [ | |
| 63 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/nx-comment-theme-1.jpg', | |
| 64 | + 'image_shape' => 'circle', | |
| 65 | + 'template' => [ | |
| 66 | + 'first_param' => 'tag_name', | |
| 67 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 68 | + 'second_param' => __('commented on', 'notificationx'), | |
| 69 | + 'third_param' => 'tag_post_title', | |
| 70 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 71 | + 'fourth_param' => 'tag_time', | |
| 72 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 73 | + ], | |
| 74 | + ], | |
| 75 | + 'theme-three' => [ | |
| 76 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/nx-comment-theme-3.jpg', | |
| 77 | + 'image_shape' => 'square', | |
| 78 | + 'template' => [ | |
| 79 | + 'first_param' => 'tag_name', | |
| 80 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 81 | + 'second_param' => __('commented on', 'notificationx'), | |
| 82 | + 'third_param' => 'tag_post_title', | |
| 83 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 84 | + 'fourth_param' => 'tag_time', | |
| 85 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 86 | + ], | |
| 87 | + ], | |
| 88 | + 'theme-six-free' => [ | |
| 89 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/nx-comment-theme-4.jpg', | |
| 90 | + 'image_shape' => 'rounded', | |
| 91 | + 'template' => [ | |
| 92 | + 'first_param' => 'tag_name', | |
| 93 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 94 | + 'second_param' => __('commented on', 'notificationx'), | |
| 95 | + 'third_param' => 'tag_post_comment', | |
| 96 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 97 | + 'fourth_param' => 'tag_time', | |
| 98 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 99 | + ], | |
| 100 | + ], | |
| 101 | + 'theme-seven-free' => [ | |
| 102 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/nx-comment-theme-5.jpg', | |
| 103 | + 'image_shape' => 'circle', | |
| 104 | + 'template' => [ | |
| 105 | + 'first_param' => 'tag_name', | |
| 106 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 107 | + 'second_param' => __('commented on', 'notificationx'), | |
| 108 | + 'third_param' => 'tag_post_comment', | |
| 109 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 110 | + 'fourth_param' => 'tag_time', | |
| 111 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 112 | + ], | |
| 113 | + ], | |
| 114 | + 'theme-eight-free' => [ | |
| 115 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/nx-comment-theme-6.jpg', | |
| 116 | + 'image_shape' => 'circle', | |
| 117 | + 'template' => [ | |
| 118 | + 'first_param' => 'tag_name', | |
| 119 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 120 | + 'second_param' => __('commented on', 'notificationx'), | |
| 121 | + 'third_param' => 'tag_post_comment', | |
| 122 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 123 | + 'fourth_param' => 'tag_time', | |
| 124 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 125 | + ], | |
| 126 | + ], | |
| 127 | + 'theme-four' => array( | |
| 128 | + 'is_pro' => true, | |
| 129 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/nx-comment-theme-four.png', | |
| 130 | + 'image_shape' => 'circle', | |
| 131 | + 'template' => [ | |
| 132 | + 'first_param' => 'tag_name', | |
| 133 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 134 | + 'second_param' => __('commented on', 'notificationx'), | |
| 135 | + 'third_param' => 'tag_post_title', | |
| 136 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 137 | + 'fourth_param' => 'tag_time', | |
| 138 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 139 | + ], | |
| 140 | + ), | |
| 141 | + 'theme-five' => array( | |
| 142 | + 'is_pro' => true, | |
| 143 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/nx-comment-theme-five.png', | |
| 144 | + 'image_shape' => 'circle', | |
| 145 | + 'template' => [ | |
| 146 | + 'first_param' => 'tag_name', | |
| 147 | + 'custom_first_param' => __('Someone', 'notificationx'), | |
| 148 | + 'second_param' => __('commented on', 'notificationx'), | |
| 149 | + 'third_param' => 'tag_post_title', | |
| 150 | + 'custom_third_param' => __('Anonymous Post', 'notificationx'), | |
| 151 | + 'fourth_param' => 'tag_time', | |
| 152 | + 'custom_fourth_param' => __('Some time ago', 'notificationx'), | |
| 153 | + ], | |
| 154 | + ), | |
| 155 | + // @todo pro fix | |
| 156 | + 'maps_theme' => array( | |
| 157 | + 'is_pro' => true, | |
| 158 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/pro/maps-theme-comments.png', | |
| 159 | + 'image_shape' => 'square', | |
| 160 | + 'show_notification_image' => 'maps_image', | |
| 161 | + ), | |
| 162 | + ]; | |
| 163 | + $this->res_themes = [ | |
| 164 | + 'res-theme-one' => [ | |
| 165 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-1.png', | |
| 166 | + '_template' => 'comments_template_new', | |
| 167 | + 'is_pro' => true, | |
| 168 | + ], | |
| 169 | + 'res-theme-two' => [ | |
| 170 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-2.png', | |
| 171 | + '_template' => 'comments_template_new', | |
| 172 | + 'is_pro' => true, | |
| 173 | + ], | |
| 174 | + 'res-theme-three' => [ | |
| 175 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-3.png', | |
| 176 | + '_template' => 'comments_template_new', | |
| 177 | + 'is_pro' => true, | |
| 178 | + ], | |
| 179 | + 'res-theme-four' => [ | |
| 180 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-4.png', | |
| 181 | + '_template' => 'comments_template_with_comments', | |
| 182 | + 'is_pro' => true, | |
| 183 | + ], | |
| 184 | + 'res-theme-five' => [ | |
| 185 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-5.png', | |
| 186 | + '_template' => 'comments_template_with_comments', | |
| 187 | + 'is_pro' => true, | |
| 188 | + ], | |
| 189 | + 'res-theme-six' => [ | |
| 190 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-6.png', | |
| 191 | + '_template' => 'comments_template_with_comments', | |
| 192 | + 'is_pro' => true, | |
| 193 | + ], | |
| 194 | + 'res-theme-seven' => array( | |
| 195 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-7.png', | |
| 196 | + '_template' => 'comments_template_new', | |
| 197 | + 'is_pro' => true, | |
| 198 | + ), | |
| 199 | + 'res-theme-eight' => array( | |
| 200 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-8.png', | |
| 201 | + '_template' => 'comments_template_new', | |
| 202 | + 'is_pro' => true, | |
| 203 | + ), | |
| 204 | + // @todo pro fix | |
| 205 | + 'res-theme-nine' => array( | |
| 206 | + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_themes/nx-comment-theme-9.png', | |
| 207 | + '_template' => 'maps_template_new', | |
| 208 | + 'is_pro' => true, | |
| 209 | + ), | |
| 210 | + ]; | |
| 211 | + $this->templates = [ | |
| 212 | + 'comments_template_new' => [ | |
| 213 | + 'first_param' => GlobalFields::get_instance()->common_name_fields(true), | |
| 214 | + 'third_param' => [ | |
| 215 | + 'tag_post_title' => __('Post Title', 'notificationx'), | |
| 216 | + ], | |
| 217 | + 'fourth_param' => [ | |
| 218 | + 'tag_time' => __('Definite Time', 'notificationx'), | |
| 219 | + ], | |
| 220 | + '_themes' => [ | |
| 221 | + 'comments_theme-one', | |
| 222 | + 'comments_theme-two', | |
| 223 | + 'comments_theme-three', | |
| 224 | + 'comments_theme-four', | |
| 225 | + 'comments_theme-five', | |
| 226 | + ], | |
| 227 | + ], | |
| 228 | + 'comments_template_with_comments' => [ | |
| 229 | + 'first_param' => GlobalFields::get_instance()->common_name_fields(true), | |
| 230 | + 'third_param' => [ | |
| 231 | + 'tag_post_title' => __('Post Title', 'notificationx'), | |
| 232 | + 'tag_post_comment' => __('Post Comment', 'notificationx'), | |
| 233 | + ], | |
| 234 | + 'fourth_param' => [ | |
| 235 | + 'tag_time' => __('Definite Time', 'notificationx'), | |
| 236 | + ], | |
| 237 | + '_themes' => [ | |
| 238 | + 'comments_theme-six-free', | |
| 239 | + 'comments_theme-seven-free', | |
| 240 | + 'comments_theme-eight-free', | |
| 241 | + ], | |
| 242 | + ], | |
| 243 | + ]; | |
| 244 | + } | |
| 245 | + | |
| 246 | + /** | |
| 247 | + * Hooked to nx_before_metabox_load action. | |
| 248 | + * | |
| 249 | + * @return void | |
| 250 | + */ | |
| 251 | + public function init_fields() { | |
| 252 | + parent::init_fields(); | |
| 253 | + add_filter('nx_content_trim_length_dependency', [$this, 'content_trim_length_dependency']); | |
| 254 | + | |
| 255 | + } | |
| 256 | + | |
| 257 | + /** | |
| 258 | + * Adds option to Link Type field in Content tab. | |
| 259 | + * | |
| 260 | + * @param array $options | |
| 261 | + * @return array | |
| 262 | + */ | |
| 263 | + public function link_types($options){ | |
| 264 | + $_options = GlobalFields::get_instance()->normalize_fields([ | |
| 265 | + 'comment_url' => __('Comment URL', 'notificationx'), | |
| 266 | + ], 'type', $this->id); | |
| 267 | + | |
| 268 | + return array_merge($options, $_options); | |
| 269 | + } | |
| 270 | + | |
| 271 | + | |
| 272 | + /** | |
| 273 | + * This method is an implementable method for All Extension coming forward. | |
| 274 | + * | |
| 275 | + * @param array $args Settings arguments. | |
| 276 | + * @return mixed | |
| 277 | + */ | |
| 278 | + public function content_trim_length_dependency($dependency) { | |
| 279 | + $dependency[] = 'comments_theme-six-free'; | |
| 280 | + $dependency[] = 'comments_theme-seven-free'; | |
| 281 | + $dependency[] = 'comments_theme-eight-free'; | |
| 282 | + return $dependency; | |
| 283 | + } | |
| 284 | +} | |