Editprofile
4 years ago
Login
5 years ago
Melange
3 years ago
Passwordreset
3 years ago
Registration
5 years ago
Userprofile
4 years ago
EditProfileThemeInterface.php
5 years ago
LoginThemeInterface.php
5 years ago
MelangeThemeInterface.php
5 years ago
PasswordResetThemeInterface.php
5 years ago
RegistrationThemeInterface.php
5 years ago
ThemeInterface.php
5 years ago
ThemesRepository.php
1 year ago
index.php
5 years ago
ThemesRepository.php
373 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Themes\Shortcode; |
| 4 | |
| 5 | |
| 6 | use ProfilePress\Core\Classes\FormRepository; |
| 7 | |
| 8 | class ThemesRepository |
| 9 | { |
| 10 | private static $themes; |
| 11 | |
| 12 | public static function defaultThemes() |
| 13 | { |
| 14 | if (is_null(self::$themes)) { |
| 15 | self::$themes = apply_filters('ppress_registered_shortcode_themes', |
| 16 | array_merge(self::freeThemes(), self::premiumThemes()) |
| 17 | ); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | public static function freeThemes() |
| 22 | { |
| 23 | return [ |
| 24 | [ |
| 25 | 'name' => 'Perfecto Lite', |
| 26 | 'theme_class' => 'PerfectoLite', |
| 27 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 28 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-login.png' |
| 29 | ], |
| 30 | [ |
| 31 | 'name' => 'Fobuk', |
| 32 | 'theme_class' => 'Fzbuk', |
| 33 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 34 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/fzbuk-login.png' |
| 35 | ], |
| 36 | |
| 37 | [ |
| 38 | 'name' => 'Perfecto Lite', |
| 39 | 'theme_class' => 'PerfectoLite', |
| 40 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 41 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-registration.png' |
| 42 | ], |
| 43 | [ |
| 44 | 'name' => 'Fzbuk', |
| 45 | 'theme_class' => 'Fzbuk', |
| 46 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 47 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/fzbuk-registration.png' |
| 48 | ], |
| 49 | [ |
| 50 | 'name' => 'Boson', |
| 51 | 'theme_class' => 'Boson', |
| 52 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 53 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/boson-registration.png' |
| 54 | ], |
| 55 | |
| 56 | [ |
| 57 | 'name' => 'Fzbuk', |
| 58 | 'theme_class' => 'Fzbuk', |
| 59 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 60 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/fzbuk-password-reset.png' |
| 61 | ], |
| 62 | [ |
| 63 | 'name' => 'Perfecto', |
| 64 | 'theme_class' => 'Perfecto', |
| 65 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 66 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-password-reset.png' |
| 67 | ], |
| 68 | |
| 69 | [ |
| 70 | 'name' => 'Boson', |
| 71 | 'theme_class' => 'Boson', |
| 72 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 73 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/boson-edit-profile.png' |
| 74 | ], |
| 75 | [ |
| 76 | 'name' => 'Perfecto', |
| 77 | 'theme_class' => 'Perfecto', |
| 78 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 79 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-edit-profile.png' |
| 80 | ], |
| 81 | |
| 82 | [ |
| 83 | 'name' => 'Dixon', |
| 84 | 'theme_class' => 'Dixon', |
| 85 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 86 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/dixon-profile.png' |
| 87 | ], |
| 88 | [ |
| 89 | 'name' => 'Daisy', |
| 90 | 'theme_class' => 'Daisy', |
| 91 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 92 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/daisy-profile.png' |
| 93 | ], |
| 94 | |
| 95 | [ |
| 96 | 'name' => 'Lucid Tab Widget', |
| 97 | 'theme_class' => 'Lucid', |
| 98 | 'theme_type' => FormRepository::MELANGE_TYPE, |
| 99 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/lucid-tab-widget.png' |
| 100 | ] |
| 101 | ]; |
| 102 | } |
| 103 | |
| 104 | public static function premiumThemes() |
| 105 | { |
| 106 | return [ |
| 107 | [ |
| 108 | 'name' => 'Smiley', |
| 109 | 'theme_class' => 'Smiley', |
| 110 | 'flag' => 'premium', |
| 111 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 112 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-login.png' |
| 113 | ], |
| 114 | [ |
| 115 | 'name' => 'Perfecto Pro', |
| 116 | 'theme_class' => 'PerfectoPro', |
| 117 | 'flag' => 'premium', |
| 118 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 119 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectopro-login.png' |
| 120 | ], |
| 121 | [ |
| 122 | 'name' => 'Parallel', |
| 123 | 'theme_class' => 'Parallel', |
| 124 | 'flag' => 'premium', |
| 125 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 126 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/parallel-login.gif' |
| 127 | ], |
| 128 | [ |
| 129 | 'name' => 'Pinnacle', |
| 130 | 'theme_class' => 'Pinnacle', |
| 131 | 'flag' => 'premium', |
| 132 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 133 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-login-registration.png' |
| 134 | ], |
| 135 | [ |
| 136 | 'name' => 'Bash', |
| 137 | 'theme_class' => 'Bash', |
| 138 | 'flag' => 'premium', |
| 139 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 140 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/bash-login.png' |
| 141 | ], |
| 142 | [ |
| 143 | 'name' => 'Jakhu', |
| 144 | 'theme_class' => 'Jakhu', |
| 145 | 'flag' => 'premium', |
| 146 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 147 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/jakhu-login.png' |
| 148 | ], |
| 149 | [ |
| 150 | 'name' => 'Sukan', |
| 151 | 'theme_class' => 'Sukan', |
| 152 | 'flag' => 'premium', |
| 153 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 154 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/sukan-login.png' |
| 155 | ], |
| 156 | |
| 157 | [ |
| 158 | 'name' => 'Smiley', |
| 159 | 'theme_class' => 'Smiley', |
| 160 | 'flag' => 'premium', |
| 161 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 162 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-registration.png' |
| 163 | ], |
| 164 | [ |
| 165 | 'name' => 'Perfecto Pro', |
| 166 | 'theme_class' => 'PerfectoPro', |
| 167 | 'flag' => 'premium', |
| 168 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 169 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectopro-registration.png' |
| 170 | ], |
| 171 | [ |
| 172 | 'name' => 'Lavender', |
| 173 | 'theme_class' => 'Lavender', |
| 174 | 'flag' => 'premium', |
| 175 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 176 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/lavender-registration.png' |
| 177 | ], |
| 178 | [ |
| 179 | 'name' => 'Parallel', |
| 180 | 'theme_class' => 'Parallel', |
| 181 | 'flag' => 'premium', |
| 182 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 183 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/parallel-registration.gif' |
| 184 | ], |
| 185 | [ |
| 186 | 'name' => 'Pinnacle', |
| 187 | 'theme_class' => 'Pinnacle', |
| 188 | 'flag' => 'premium', |
| 189 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 190 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-login-registration.png' |
| 191 | ], |
| 192 | [ |
| 193 | 'name' => 'Bash', |
| 194 | 'theme_class' => 'Bash', |
| 195 | 'flag' => 'premium', |
| 196 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 197 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/bash-registration.png' |
| 198 | ], |
| 199 | [ |
| 200 | 'name' => 'Jakhu', |
| 201 | 'theme_class' => 'Jakhu', |
| 202 | 'flag' => 'premium', |
| 203 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 204 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/jakhu-registration.png' |
| 205 | ], |
| 206 | |
| 207 | [ |
| 208 | 'name' => 'Smiley', |
| 209 | 'theme_class' => 'Smiley', |
| 210 | 'flag' => 'premium', |
| 211 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 212 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-password-reset.png' |
| 213 | ], |
| 214 | [ |
| 215 | 'name' => 'Bash', |
| 216 | 'theme_class' => 'Bash', |
| 217 | 'flag' => 'premium', |
| 218 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 219 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/bash-password-reset.png' |
| 220 | ], |
| 221 | [ |
| 222 | 'name' => 'Parallel', |
| 223 | 'theme_class' => 'Parallel', |
| 224 | 'flag' => 'premium', |
| 225 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 226 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/parallel-password-reset.gif' |
| 227 | ], |
| 228 | [ |
| 229 | 'name' => 'Pinnacle', |
| 230 | 'theme_class' => 'Pinnacle', |
| 231 | 'flag' => 'premium', |
| 232 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 233 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-password-reset.png' |
| 234 | ], |
| 235 | [ |
| 236 | 'name' => 'Jakhu', |
| 237 | 'theme_class' => 'Jakhu', |
| 238 | 'flag' => 'premium', |
| 239 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 240 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/jakhu-password-reset.png' |
| 241 | ], |
| 242 | |
| 243 | [ |
| 244 | 'name' => 'Smiley', |
| 245 | 'theme_class' => 'Smiley', |
| 246 | 'flag' => 'premium', |
| 247 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 248 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-edit-profile.png' |
| 249 | ], |
| 250 | [ |
| 251 | 'name' => 'Pinnacle', |
| 252 | 'theme_class' => 'Pinnacle', |
| 253 | 'flag' => 'premium', |
| 254 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 255 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-edit-profile.png' |
| 256 | ], |
| 257 | |
| 258 | [ |
| 259 | 'name' => 'Smiley', |
| 260 | 'theme_class' => 'Smiley', |
| 261 | 'flag' => 'premium', |
| 262 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 263 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-profile.png' |
| 264 | ], |
| 265 | [ |
| 266 | 'name' => 'Monochrome', |
| 267 | 'theme_class' => 'Monochrome', |
| 268 | 'flag' => 'premium', |
| 269 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 270 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/monochrome-profile.png' |
| 271 | ], |
| 272 | |
| 273 | [ |
| 274 | 'name' => 'Montserrat', |
| 275 | 'theme_class' => 'Montserrat', |
| 276 | 'flag' => 'premium', |
| 277 | 'theme_type' => FormRepository::MELANGE_TYPE, |
| 278 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/montserrat-form.gif' |
| 279 | ], |
| 280 | [ |
| 281 | 'name' => 'Bash', |
| 282 | 'theme_class' => 'Bash', |
| 283 | 'flag' => 'premium', |
| 284 | 'theme_type' => FormRepository::MELANGE_TYPE, |
| 285 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/bash-account-form.gif' |
| 286 | ], |
| 287 | [ |
| 288 | 'name' => 'Stride', |
| 289 | 'theme_class' => 'Stride', |
| 290 | 'flag' => 'premium', |
| 291 | 'theme_type' => FormRepository::MELANGE_TYPE, |
| 292 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/stride.gif' |
| 293 | ], |
| 294 | |
| 295 | [ |
| 296 | 'name' => 'Tablefy', |
| 297 | 'theme_class' => 'Tablefy', |
| 298 | 'theme_type' => FormRepository::MEMBERS_DIRECTORY_TYPE, |
| 299 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/tablefy-member-directory.png' |
| 300 | ] |
| 301 | ]; |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * All Optin themes available. |
| 306 | * |
| 307 | * @return mixed |
| 308 | */ |
| 309 | public static function get_all() |
| 310 | { |
| 311 | self::defaultThemes(); |
| 312 | |
| 313 | return self::$themes; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * Get form themes of a given type. |
| 318 | * |
| 319 | * @param string $form_type |
| 320 | * |
| 321 | * @return mixed |
| 322 | */ |
| 323 | public static function get_by_type($form_type) |
| 324 | { |
| 325 | $all = self::get_all(); |
| 326 | |
| 327 | return array_reduce($all, function ($carry, $item) use ($form_type) { |
| 328 | |
| 329 | // remove leading & trailing whitespace. |
| 330 | $form_type_array = array_map('trim', explode(',', $item['theme_type'])); |
| 331 | |
| 332 | if (in_array($form_type, $form_type_array)) { |
| 333 | $carry[] = $item; |
| 334 | } |
| 335 | |
| 336 | return $carry; |
| 337 | }); |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * Get form theme by name. |
| 342 | * |
| 343 | * @param string $name |
| 344 | * |
| 345 | * @return mixed |
| 346 | */ |
| 347 | public static function get_by_name($name) |
| 348 | { |
| 349 | $all = self::get_all(); |
| 350 | |
| 351 | return array_reduce($all, function ($carry, $item) use ($name) { |
| 352 | |
| 353 | if ($item['name'] == $name) { |
| 354 | $carry = $item; |
| 355 | } |
| 356 | |
| 357 | return $carry; |
| 358 | }); |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * Add form theme to theme repository. |
| 363 | * |
| 364 | * @param mixed $data |
| 365 | * |
| 366 | * @return void |
| 367 | */ |
| 368 | public static function add($data) |
| 369 | { |
| 370 | self::defaultThemes(); |
| 371 | self::$themes[] = $data; |
| 372 | } |
| 373 | } |