EditProfile
5 years ago
Login
3 years ago
MemberDirectory
7 months ago
PasswordReset
5 years ago
Registration
3 years ago
UserProfile
1 year ago
AbstractBuildScratch.php
7 months ago
AbstractMemberDirectoryTheme.php
4 months ago
AbstractTheme.php
11 months ago
FieldListing.php
7 months ago
MemberDirectoryListing.php
2 months ago
MemberDirectoryTrait.php
1 year ago
ProfileFieldListing.php
2 months ago
ThemeInterface.php
5 years ago
ThemesRepository.php
1 year ago
index.php
5 years ago
ThemesRepository.php
319 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Themes\DragDrop; |
| 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_dragdrop_themes', |
| 16 | array_merge(self::freeThemes(), self::premiumThemes()) |
| 17 | ); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | public static function freeThemes() |
| 22 | { |
| 23 | return [ |
| 24 | [ |
| 25 | 'name' => 'Tulip', |
| 26 | 'theme_class' => 'Tulip', |
| 27 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 28 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/tulip-registration.png' |
| 29 | ], |
| 30 | [ |
| 31 | 'name' => 'Perfecto Lite', |
| 32 | 'theme_class' => 'PerfectoLite', |
| 33 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 34 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-registration.png' |
| 35 | ], |
| 36 | |
| 37 | [ |
| 38 | 'name' => 'Tulip', |
| 39 | 'theme_class' => 'Tulip', |
| 40 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 41 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/tulip-edit-profile.png' |
| 42 | ], |
| 43 | |
| 44 | [ |
| 45 | 'name' => 'Tulip', |
| 46 | 'theme_class' => 'Tulip', |
| 47 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 48 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/tulip-login.png' |
| 49 | ], |
| 50 | [ |
| 51 | 'name' => 'Perfecto Lite', |
| 52 | 'theme_class' => 'PerfectoLite', |
| 53 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 54 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-login.png' |
| 55 | ], |
| 56 | |
| 57 | |
| 58 | [ |
| 59 | 'name' => 'Tulip', |
| 60 | 'theme_class' => 'Tulip', |
| 61 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 62 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/tulip-password-reset.png' |
| 63 | ], |
| 64 | |
| 65 | [ |
| 66 | 'name' => 'Default', |
| 67 | 'theme_class' => 'DefaultTemplate', |
| 68 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 69 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/default-user-profile.png' |
| 70 | ], |
| 71 | [ |
| 72 | 'name' => 'Dixon', |
| 73 | 'theme_class' => 'Dixon', |
| 74 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 75 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/dixon-profile.png' |
| 76 | ], |
| 77 | |
| 78 | [ |
| 79 | 'name' => 'Default', |
| 80 | 'theme_class' => 'DefaultTemplate', |
| 81 | 'theme_type' => FormRepository::MEMBERS_DIRECTORY_TYPE, |
| 82 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/default-member-directory.png' |
| 83 | ], |
| 84 | [ |
| 85 | 'name' => 'Gerbera', |
| 86 | 'theme_class' => 'Gerbera', |
| 87 | 'theme_type' => FormRepository::MEMBERS_DIRECTORY_TYPE, |
| 88 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/gerbera-member-directory.png' |
| 89 | ], |
| 90 | ]; |
| 91 | } |
| 92 | |
| 93 | public static function premiumThemes() |
| 94 | { |
| 95 | return [ |
| 96 | [ |
| 97 | 'name' => 'Daffodil', |
| 98 | 'theme_class' => 'Daffodil', |
| 99 | 'flag' => 'premium', |
| 100 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 101 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/daffodil-registration.png' |
| 102 | ], |
| 103 | [ |
| 104 | 'name' => 'Smiley', |
| 105 | 'theme_class' => 'Smiley', |
| 106 | 'flag' => 'premium', |
| 107 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 108 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-registration.png' |
| 109 | ], |
| 110 | [ |
| 111 | 'name' => 'Pinnacle', |
| 112 | 'theme_class' => 'Pinnacle', |
| 113 | 'flag' => 'premium', |
| 114 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 115 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-login-registration.png' |
| 116 | ], |
| 117 | [ |
| 118 | 'name' => 'Bash', |
| 119 | 'theme_class' => 'Bash', |
| 120 | 'flag' => 'premium', |
| 121 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 122 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/bash-registration.png' |
| 123 | ], |
| 124 | [ |
| 125 | 'name' => 'Perfecto Pro', |
| 126 | 'theme_class' => 'PerfectoPro', |
| 127 | 'flag' => 'premium', |
| 128 | 'theme_type' => FormRepository::REGISTRATION_TYPE, |
| 129 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectopro-registration.png' |
| 130 | ], |
| 131 | |
| 132 | [ |
| 133 | 'name' => 'Daffodil', |
| 134 | 'theme_class' => 'Daffodil', |
| 135 | 'flag' => 'premium', |
| 136 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 137 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/daffodil-edit-profile.png' |
| 138 | ], |
| 139 | [ |
| 140 | 'name' => 'Smiley', |
| 141 | 'theme_class' => 'Smiley', |
| 142 | 'flag' => 'premium', |
| 143 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 144 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-edit-profile.png' |
| 145 | ], |
| 146 | [ |
| 147 | 'name' => 'Perfecto', |
| 148 | 'theme_class' => 'Perfecto', |
| 149 | 'flag' => 'premium', |
| 150 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 151 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-edit-profile.png' |
| 152 | ], |
| 153 | [ |
| 154 | 'name' => 'Pinnacle', |
| 155 | 'theme_class' => 'Pinnacle', |
| 156 | 'flag' => 'premium', |
| 157 | 'theme_type' => FormRepository::EDIT_PROFILE_TYPE, |
| 158 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-edit-profile.png' |
| 159 | ], |
| 160 | |
| 161 | [ |
| 162 | 'name' => 'Daffodil', |
| 163 | 'theme_class' => 'Daffodil', |
| 164 | 'flag' => 'premium', |
| 165 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 166 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/daffodil-login.png' |
| 167 | ], |
| 168 | [ |
| 169 | 'name' => 'Bash', |
| 170 | 'theme_class' => 'Bash', |
| 171 | 'flag' => 'premium', |
| 172 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 173 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/bash-login.png' |
| 174 | ], |
| 175 | [ |
| 176 | 'name' => 'Perfecto Pro', |
| 177 | 'theme_class' => 'PerfectoPro', |
| 178 | 'flag' => 'premium', |
| 179 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 180 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectopro-login.png' |
| 181 | ], |
| 182 | [ |
| 183 | 'name' => 'Smiley', |
| 184 | 'theme_class' => 'Smiley', |
| 185 | 'flag' => 'premium', |
| 186 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 187 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-login.png' |
| 188 | ], |
| 189 | [ |
| 190 | 'name' => 'Pinnacle', |
| 191 | 'theme_class' => 'Pinnacle', |
| 192 | 'flag' => 'premium', |
| 193 | 'theme_type' => FormRepository::LOGIN_TYPE, |
| 194 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-login-registration.png' |
| 195 | ], |
| 196 | |
| 197 | [ |
| 198 | 'name' => 'Daffodil', |
| 199 | 'theme_class' => 'Daffodil', |
| 200 | 'flag' => 'premium', |
| 201 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 202 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/daffodil-password-reset.png' |
| 203 | ], |
| 204 | [ |
| 205 | 'name' => 'Smiley', |
| 206 | 'theme_class' => 'Smiley', |
| 207 | 'flag' => 'premium', |
| 208 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 209 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-password-reset.png' |
| 210 | ], |
| 211 | [ |
| 212 | 'name' => 'Bash', |
| 213 | 'theme_class' => 'Bash', |
| 214 | 'flag' => 'premium', |
| 215 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 216 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/bash-password-reset.png' |
| 217 | ], |
| 218 | [ |
| 219 | 'name' => 'Perfecto', |
| 220 | 'theme_class' => 'Perfecto', |
| 221 | 'flag' => 'premium', |
| 222 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 223 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/perfectolite-password-reset.png' |
| 224 | ], |
| 225 | [ |
| 226 | 'name' => 'Pinnacle', |
| 227 | 'theme_class' => 'Pinnacle', |
| 228 | 'flag' => 'premium', |
| 229 | 'theme_type' => FormRepository::PASSWORD_RESET_TYPE, |
| 230 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/pinnacle-password-reset.png' |
| 231 | ], |
| 232 | |
| 233 | [ |
| 234 | 'name' => 'Smiley', |
| 235 | 'theme_class' => 'Smiley', |
| 236 | 'flag' => 'premium', |
| 237 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 238 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/smiley-profile.png' |
| 239 | ], |
| 240 | [ |
| 241 | 'name' => 'Monochrome', |
| 242 | 'theme_class' => 'Monochrome', |
| 243 | 'flag' => 'premium', |
| 244 | 'theme_type' => FormRepository::USER_PROFILE_TYPE, |
| 245 | 'screenshot' => PPRESS_ASSETS_URL . '/images/themes/monochrome-profile.png' |
| 246 | ], |
| 247 | ]; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * All Optin themes available. |
| 252 | * |
| 253 | * @return mixed |
| 254 | */ |
| 255 | public static function get_all() |
| 256 | { |
| 257 | self::defaultThemes(); |
| 258 | |
| 259 | return self::$themes; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Get form themes of a given type. |
| 264 | * |
| 265 | * @param string $form_type |
| 266 | * |
| 267 | * @return mixed |
| 268 | */ |
| 269 | public static function get_by_type($form_type) |
| 270 | { |
| 271 | $all = self::get_all(); |
| 272 | |
| 273 | return array_reduce($all, function ($carry, $item) use ($form_type) { |
| 274 | |
| 275 | // remove leading & trailing whitespace. |
| 276 | $form_type_array = array_map('trim', explode(',', $item['theme_type'])); |
| 277 | |
| 278 | if (in_array($form_type, $form_type_array)) { |
| 279 | $carry[] = $item; |
| 280 | } |
| 281 | |
| 282 | return $carry; |
| 283 | }, []); |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Get form theme by name. |
| 288 | * |
| 289 | * @param string $name |
| 290 | * |
| 291 | * @return mixed |
| 292 | */ |
| 293 | public static function get_by_name($name) |
| 294 | { |
| 295 | $all = self::get_all(); |
| 296 | |
| 297 | return array_reduce($all, function ($carry, $item) use ($name) { |
| 298 | |
| 299 | if ($item['name'] == $name) { |
| 300 | $carry = $item; |
| 301 | } |
| 302 | |
| 303 | return $carry; |
| 304 | }); |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Add form theme to theme repository. |
| 309 | * |
| 310 | * @param mixed $data |
| 311 | * |
| 312 | * @return void |
| 313 | */ |
| 314 | public static function add($data) |
| 315 | { |
| 316 | self::defaultThemes(); |
| 317 | self::$themes[] = $data; |
| 318 | } |
| 319 | } |