| @@ -1,0 +1,635 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Admin | |
| 4 | + * | |
| 5 | + * @package GamiPress\Ultimate_Member\Admin | |
| 6 | + * @since 1.0.0 | |
| 7 | + */ | |
| 8 | +// Exit if accessed directly | |
| 9 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Shortcut function to get plugin options | |
| 13 | + * | |
| 14 | + * @since 1.0.0 | |
| 15 | + * | |
| 16 | + * @param string $option_name | |
| 17 | + * @param bool $default | |
| 18 | + * | |
| 19 | + * @return mixed | |
| 20 | + */ | |
| 21 | +function gamipress_ultimate_member_get_option( $option_name, $default = false ) { | |
| 22 | + | |
| 23 | + $prefix = 'ultimate_member_'; | |
| 24 | + | |
| 25 | + return gamipress_get_option( $prefix . $option_name, $default ); | |
| 26 | +} | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * Ultimate Member Settings meta boxes | |
| 30 | + * | |
| 31 | + * @since 1.0.0 | |
| 32 | + * | |
| 33 | + * @param $meta_boxes | |
| 34 | + * | |
| 35 | + * @return mixed | |
| 36 | + */ | |
| 37 | +function gamipress_ultimate_member_settings_meta_boxes( $meta_boxes ) { | |
| 38 | + | |
| 39 | + $prefix = 'ultimate_member_'; | |
| 40 | + | |
| 41 | + // Setup dynamic achievement fields | |
| 42 | + $achievement_fields = array(); | |
| 43 | + | |
| 44 | + foreach( GamiPress()->shortcodes['gamipress_achievement']->fields as $field_id => $field_args ) { | |
| 45 | + | |
| 46 | + if( $field_id === 'id' ) { | |
| 47 | + continue; | |
| 48 | + } | |
| 49 | + | |
| 50 | + if( $field_args['type'] === 'checkbox' && isset( $field_args['default'] ) ) { | |
| 51 | + unset( $field_args['default'] ); | |
| 52 | + } | |
| 53 | + | |
| 54 | + $achievement_fields[$prefix . 'profile_achievements_' . $field_id] = $field_args; | |
| 55 | + | |
| 56 | + } | |
| 57 | + | |
| 58 | + // Setup dynamic rank fields | |
| 59 | + $rank_fields = array(); | |
| 60 | + | |
| 61 | + foreach( GamiPress()->shortcodes['gamipress_rank']->fields as $field_id => $field_args ) { | |
| 62 | + | |
| 63 | + if( $field_id === 'id' ) { | |
| 64 | + continue; | |
| 65 | + } | |
| 66 | + | |
| 67 | + if( $field_args['type'] === 'checkbox' && isset( $field_args['default'] ) ) { | |
| 68 | + unset( $field_args['default'] ); | |
| 69 | + } | |
| 70 | + | |
| 71 | + $rank_fields[$prefix . 'profile_ranks_' . $field_id] = $field_args; | |
| 72 | + | |
| 73 | + } | |
| 74 | + | |
| 75 | + $meta_boxes['gamipress-ultimate-member-settings'] = array( | |
| 76 | + 'title' => __( 'Ultimate Member', 'gamipress' ), | |
| 77 | + 'fields' => apply_filters( 'gamipress_ultimate_member_settings_fields', array_merge( array( | |
| 78 | + | |
| 79 | + // Points Types | |
| 80 | + | |
| 81 | + $prefix . 'points_placement' => array( | |
| 82 | + 'name' => __( 'Where Place User Points?', 'gamipress' ), | |
| 83 | + 'desc' => __( 'Check this option to show the user points on the Ultimate Member profile.', 'gamipress' ), | |
| 84 | + 'type' => 'select', | |
| 85 | + 'options' => array( | |
| 86 | + '' => __( 'Not display', 'gamipress' ), | |
| 87 | + 'tab' => __( 'As a new profile tab', 'gamipress' ), | |
| 88 | + 'top' => __( 'At top (before the user name)', 'gamipress' ), | |
| 89 | + 'both' => __( 'Both', 'gamipress' ), | |
| 90 | + ), | |
| 91 | + ), | |
| 92 | + $prefix . 'points_tab_title' => array( | |
| 93 | + 'name' => __( 'User Profile Points Tab Title', 'gamipress' ), | |
| 94 | + 'desc' => __( 'Text to show on the Ultimate Member user profile.', 'gamipress' ), | |
| 95 | + 'type' => 'text', | |
| 96 | + 'default' => __( 'Points', 'gamipress' ), | |
| 97 | + ), | |
| 98 | + $prefix . 'points_tab_slug' => array( | |
| 99 | + 'name' => __( 'User Profile Points Tab Slug (Option)', 'gamipress' ), | |
| 100 | + 'desc' => __( 'URL slug to use on the profile tab. Leave blank and slug will be a URL version of the tab title (eg: "My Tab Title" will have a slug like "my-tab-title").', 'gamipress' ) | |
| 101 | + . '<br>' . __( '<strong>Important:</strong> If you set a tab title with special characters then provide a slug with URL friendly characters.', 'gamipress' ), | |
| 102 | + 'type' => 'text', | |
| 103 | + ), | |
| 104 | + $prefix . 'points_tab_icon' => array( | |
| 105 | + 'name' => __( 'User Profile Points Tab Icon', 'gamipress' ), | |
| 106 | + 'desc' => __( 'Icon to show on the Ultimate Member user profile tab.', 'gamipress' ) | |
| 107 | + . '<a href="https://gist.github.com/wpdelighter/5be397d1a4261f07b819c22a23d9da95" target="_blank">' . __( 'Full list of available icons.', 'gamipress' ) . '</a>', | |
| 108 | + 'type' => 'text', | |
| 109 | + 'default' => 'um-faicon-star', | |
| 110 | + ), | |
| 111 | + $prefix . 'profile_points_types' => array( | |
| 112 | + 'name' => __( 'User Profile Points Types', 'gamipress' ), | |
| 113 | + 'desc' => __( 'Choose the points types you want to show on Ultimate Member user profile.', 'gamipress' ) | |
| 114 | + . '<br>' . __( '<strong>Note:</strong> You can drag and drop this options to reorder them. The order you set will affect to the order they will get displayed on the profile.', 'gamipress' ), | |
| 115 | + 'type' => 'multicheck', | |
| 116 | + 'options_cb' => 'gamipress_ultimate_member_profile_points_types_option_cb', | |
| 117 | + ), | |
| 118 | + $prefix . 'profile_points_types_top_display_title' => array( | |
| 119 | + 'name' => __( 'Points At Top Display Options', 'gamipress' ), | |
| 120 | + 'desc' => __( 'Setup how points should look at top of the Ultimate Member user profile.', 'gamipress' ), | |
| 121 | + 'type' => 'title', | |
| 122 | + ), | |
| 123 | + $prefix . 'profile_points_types_top_thumbnail' => array( | |
| 124 | + 'name' => __( 'Show Thumbnail', 'gamipress' ), | |
| 125 | + 'desc' => __( 'Show the points type featured image.', 'gamipress' ), | |
| 126 | + 'type' => 'checkbox', | |
| 127 | + 'classes' => 'gamipress-switch', | |
| 128 | + ), | |
| 129 | + $prefix . 'profile_points_types_top_thumbnail_size' => array( | |
| 130 | + 'name' => __( 'Thumbnail Size', 'gamipress' ), | |
| 131 | + 'desc' => __( 'Set the thumbnail size (in pixels).', 'gamipress' ), | |
| 132 | + 'type' => 'text', | |
| 133 | + 'default' => '25', | |
| 134 | + ), | |
| 135 | + $prefix . 'profile_points_types_top_label' => array( | |
| 136 | + 'name' => __( 'Show Label', 'gamipress' ), | |
| 137 | + 'desc' => __( 'Show the points type singular or plural label.', 'gamipress' ), | |
| 138 | + 'type' => 'checkbox', | |
| 139 | + 'classes' => 'gamipress-switch', | |
| 140 | + ), | |
| 141 | + | |
| 142 | + // Achievement Types | |
| 143 | + | |
| 144 | + $prefix . 'achievements_placement' => array( | |
| 145 | + 'name' => __( 'Where Place User Achievements?', 'gamipress' ), | |
| 146 | + 'desc' => __( 'Check this option to show the user achievements on the Ultimate Member profile.', 'gamipress' ), | |
| 147 | + 'type' => 'select', | |
| 148 | + 'options' => array( | |
| 149 | + '' => __( 'Not display', 'gamipress' ), | |
| 150 | + 'tab' => __( 'As a new profile tab', 'gamipress' ), | |
| 151 | + 'top' => __( 'At top (before the user name)', 'gamipress' ), | |
| 152 | + 'both' => __( 'Both', 'gamipress' ), | |
| 153 | + ), | |
| 154 | + ), | |
| 155 | + $prefix . 'achievements_tab_title' => array( | |
| 156 | + 'name' => __( 'User Profile Achievement Types Tab Title', 'gamipress' ), | |
| 157 | + 'desc' => __( 'Text to show on the Ultimate Member user profile.', 'gamipress' ), | |
| 158 | + 'type' => 'text', | |
| 159 | + 'default' => __( 'Achievements', 'gamipress' ), | |
| 160 | + ), | |
| 161 | + $prefix . 'achievements_tab_slug' => array( | |
| 162 | + 'name' => __( 'User Profile Achievement Types Tab Slug (Option)', 'gamipress' ), | |
| 163 | + 'desc' => __( 'URL slug to use on the profile tab. Leave blank and slug will be a URL version of the tab title (eg: "My Tab Title" will have a slug like "my-tab-title").', 'gamipress' ) | |
| 164 | + . '<br>' . __( '<strong>Important:</strong> If you set a tab title with special characters then provide a slug with URL friendly characters.', 'gamipress' ), | |
| 165 | + 'type' => 'text', | |
| 166 | + ), | |
| 167 | + $prefix . 'achievements_tab_icon' => array( | |
| 168 | + 'name' => __( 'User Profile Achievements Tab Icon', 'gamipress' ), | |
| 169 | + 'desc' => __( 'Icon to show on the Ultimate Member user profile tab.', 'gamipress' ) | |
| 170 | + . '<a href="https://gist.github.com/wpdelighter/5be397d1a4261f07b819c22a23d9da95" target="_blank">' . __( 'Full list of available icons.', 'gamipress' ) . '</a>', | |
| 171 | + 'type' => 'text', | |
| 172 | + 'default' => 'um-faicon-flag', | |
| 173 | + ), | |
| 174 | + $prefix . 'profile_achievements_types' => array( | |
| 175 | + 'name' => __( 'User Profile Achievement Types', 'gamipress' ), | |
| 176 | + 'desc' => __( 'Choose the achievement types you want to show on Ultimate Member user profile achievements tab.', 'gamipress' ) | |
| 177 | + . '<br>' . __( '<strong>Note:</strong> You can drag and drop this options to reorder them. The order you set will affect to the order they will get displayed on the profile.', 'gamipress' ), | |
| 178 | + 'type' => 'multicheck', | |
| 179 | + 'options_cb' => 'gamipress_ultimate_member_profile_achievements_types_option_cb', | |
| 180 | + ), | |
| 181 | + $prefix . 'profile_achievements_top_display_title' => array( | |
| 182 | + 'name' => __( 'Achievements At Top Display Options', 'gamipress' ), | |
| 183 | + 'desc' => __( 'Setup how achievements should look at top of the Ultimate Member user profile.', 'gamipress' ), | |
| 184 | + 'type' => 'title', | |
| 185 | + ), | |
| 186 | + $prefix . 'profile_achievements_top_thumbnail' => array( | |
| 187 | + 'name' => __( 'Show Thumbnail', 'gamipress' ), | |
| 188 | + 'desc' => __( 'Show the achievement featured image.', 'gamipress' ), | |
| 189 | + 'type' => 'checkbox', | |
| 190 | + 'classes' => 'gamipress-switch', | |
| 191 | + ), | |
| 192 | + $prefix . 'profile_achievements_top_thumbnail_size' => array( | |
| 193 | + 'name' => __( 'Thumbnail Size', 'gamipress' ), | |
| 194 | + 'desc' => __( 'Set the thumbnail size (in pixels).', 'gamipress' ), | |
| 195 | + 'type' => 'text', | |
| 196 | + 'default' => '25', | |
| 197 | + ), | |
| 198 | + $prefix . 'profile_achievements_top_title' => array( | |
| 199 | + 'name' => __( 'Show Title', 'gamipress' ), | |
| 200 | + 'desc' => __( 'Show the achievements title.', 'gamipress' ), | |
| 201 | + 'type' => 'checkbox', | |
| 202 | + 'classes' => 'gamipress-switch', | |
| 203 | + ), | |
| 204 | + $prefix . 'profile_achievements_top_link' => array( | |
| 205 | + 'name' => __( 'Show Link', 'gamipress' ), | |
| 206 | + 'desc' => __( 'Add a link to the achievement page.', 'gamipress' ), | |
| 207 | + 'type' => 'checkbox', | |
| 208 | + 'classes' => 'gamipress-switch', | |
| 209 | + ), | |
| 210 | + $prefix . 'profile_achievements_top_label' => array( | |
| 211 | + 'name' => __( 'Show Label', 'gamipress' ), | |
| 212 | + 'desc' => __( 'Show the achievement type label.', 'gamipress' ), | |
| 213 | + 'type' => 'checkbox', | |
| 214 | + 'classes' => 'gamipress-switch', | |
| 215 | + ), | |
| 216 | + $prefix . 'profile_achievements_top_limit' => array( | |
| 217 | + 'name' => __( 'Limit', 'gamipress' ), | |
| 218 | + 'desc' => __( 'Number of achievements to display.', 'gamipress' ), | |
| 219 | + 'type' => 'text', | |
| 220 | + 'default' => '10', | |
| 221 | + ), | |
| 222 | + $prefix . 'profile_achievements_template_title' => array( | |
| 223 | + 'name' => __( 'Achievements Tab Display Options', 'gamipress' ), | |
| 224 | + 'description' => __( 'Setup how achievements should look on the Ultimate Member user profile tab.', 'gamipress' ), | |
| 225 | + 'type' => 'title', | |
| 226 | + ), | |
| 227 | + $prefix . 'profile_achievements_columns' => array( | |
| 228 | + 'name' => __( 'Columns', 'gamipress' ), | |
| 229 | + 'description' => __( 'Columns to divide achievements.', 'gamipress' ), | |
| 230 | + 'type' => 'select', | |
| 231 | + 'options' => array( | |
| 232 | + '1' => __( '1 Column', 'gamipress' ), | |
| 233 | + '2' => __( '2 Columns', 'gamipress' ), | |
| 234 | + '3' => __( '3 Columns', 'gamipress' ), | |
| 235 | + '4' => __( '4 Columns', 'gamipress' ), | |
| 236 | + '5' => __( '5 Columns', 'gamipress' ), | |
| 237 | + '6' => __( '6 Columns', 'gamipress' ), | |
| 238 | + ), | |
| 239 | + 'default' => '1' | |
| 240 | + ), | |
| 241 | + $prefix . 'profile_achievements_limit' => array( | |
| 242 | + 'name' => __( 'Limit', 'gamipress' ), | |
| 243 | + 'description' => __( 'Number of achievements to display.', 'gamipress' ), | |
| 244 | + 'type' => 'text', | |
| 245 | + 'default' => 10, | |
| 246 | + ), | |
| 247 | + $prefix . 'profile_achievements_orderby' => array( | |
| 248 | + 'name' => __( 'Order By', 'gamipress' ), | |
| 249 | + 'description' => __( 'Parameter to use for sorting.', 'gamipress' ), | |
| 250 | + 'type' => 'select', | |
| 251 | + 'options' => array( | |
| 252 | + 'menu_order' => __( 'Menu Order', 'gamipress' ), | |
| 253 | + 'ID' => __( 'Achievement ID', 'gamipress' ), | |
| 254 | + 'title' => __( 'Achievement Title', 'gamipress' ), | |
| 255 | + 'date' => __( 'Published Date', 'gamipress' ), | |
| 256 | + 'modified' => __( 'Last Modified Date', 'gamipress' ), | |
| 257 | + 'author' => __( 'Achievement Author', 'gamipress' ), | |
| 258 | + 'rand' => __( 'Random', 'gamipress' ), | |
| 259 | + ), | |
| 260 | + 'default' => 'menu_order', | |
| 261 | + ), | |
| 262 | + $prefix . 'profile_achievements_order' => array( | |
| 263 | + 'name' => __( 'Order', 'gamipress' ), | |
| 264 | + 'description' => __( 'Sort order.', 'gamipress' ), | |
| 265 | + 'type' => 'select', | |
| 266 | + 'options' => array( 'ASC' => __( 'Ascending', 'gamipress' ), 'DESC' => __( 'Descending', 'gamipress' ) ), | |
| 267 | + 'default' => 'ASC', | |
| 268 | + ), | |
| 269 | + | |
| 270 | + // Rank Types | |
| 271 | + | |
| 272 | + $prefix . 'ranks_placement' => array( | |
| 273 | + 'name' => __( 'Where Place User Ranks?', 'gamipress' ), | |
| 274 | + 'desc' => __( 'Check this option to show the user ranks on the Ultimate Member profile.', 'gamipress' ), | |
| 275 | + 'type' => 'select', | |
| 276 | + 'options' => array( | |
| 277 | + '' => __( 'Not display', 'gamipress' ), | |
| 278 | + 'tab' => __( 'As a new profile tab', 'gamipress' ), | |
| 279 | + 'top' => __( 'At top (before the user name)', 'gamipress' ), | |
| 280 | + 'both' => __( 'Both', 'gamipress' ), | |
| 281 | + ), | |
| 282 | + ), | |
| 283 | + $prefix . 'ranks_tab_title' => array( | |
| 284 | + 'name' => __( 'User Profile Rank Types Tab Title', 'gamipress' ), | |
| 285 | + 'desc' => __( 'Text to show on the Ultimate Member user profile.', 'gamipress' ), | |
| 286 | + 'type' => 'text', | |
| 287 | + 'default' => __( 'Ranks', 'gamipress' ), | |
| 288 | + ), | |
| 289 | + $prefix . 'ranks_tab_slug' => array( | |
| 290 | + 'name' => __( 'User Profile Rank Types Tab Slug (Option)', 'gamipress' ), | |
| 291 | + 'desc' => __( 'URL slug to use on the profile tab. Leave blank and slug will be a URL version of the tab title (eg: "My Tab Title" will have a slug like "my-tab-title").', 'gamipress' ) | |
| 292 | + . '<br>' . __( '<strong>Important:</strong> If you set a tab title with special characters then provide a slug with URL friendly characters.', 'gamipress' ), | |
| 293 | + 'type' => 'text', | |
| 294 | + ), | |
| 295 | + $prefix . 'ranks_tab_icon' => array( | |
| 296 | + 'name' => __( 'User Profile Ranks Tab Icon', 'gamipress' ), | |
| 297 | + 'desc' => __( 'Icon to show on the Ultimate Member user profile tab.', 'gamipress' ) | |
| 298 | + . '<a href="https://gist.github.com/wpdelighter/5be397d1a4261f07b819c22a23d9da95" target="_blank">' . __( 'Full list of available icons.', 'gamipress' ) . '</a>', | |
| 299 | + 'type' => 'text', | |
| 300 | + 'default' => 'um-faicon-certificate', | |
| 301 | + ), | |
| 302 | + $prefix . 'profile_ranks_types' => array( | |
| 303 | + 'name' => __( 'User Profile Rank Types', 'gamipress' ), | |
| 304 | + 'desc' => __( 'Choose the rank types you want to show on Ultimate Member user profile ranks tab.', 'gamipress' ) | |
| 305 | + . '<br>' . __( '<strong>Note:</strong> You can drag and drop this options to reorder them. The order you set will affect to the order they will get displayed on the profile.', 'gamipress' ), | |
| 306 | + 'type' => 'multicheck', | |
| 307 | + 'options_cb' => 'gamipress_ultimate_member_profile_ranks_types_option_cb', | |
| 308 | + ), | |
| 309 | + $prefix . 'profile_ranks_top_display_title' => array( | |
| 310 | + 'name' => __( 'Ranks At Top Display Options', 'gamipress' ), | |
| 311 | + 'desc' => __( 'Setup how ranks should look at top of the Ultimate Member user profile.', 'gamipress' ), | |
| 312 | + 'type' => 'title', | |
| 313 | + ), | |
| 314 | + $prefix . 'profile_ranks_top_thumbnail' => array( | |
| 315 | + 'name' => __( 'Show Thumbnail', 'gamipress' ), | |
| 316 | + 'desc' => __( 'Show the achievement featured image.', 'gamipress' ), | |
| 317 | + 'type' => 'checkbox', | |
| 318 | + 'classes' => 'gamipress-switch', | |
| 319 | + ), | |
| 320 | + $prefix . 'profile_ranks_top_thumbnail_size' => array( | |
| 321 | + 'name' => __( 'Thumbnail Size', 'gamipress' ), | |
| 322 | + 'desc' => __( 'Set the thumbnail size (in pixels).', 'gamipress' ), | |
| 323 | + 'type' => 'text', | |
| 324 | + 'default' => '25', | |
| 325 | + ), | |
| 326 | + $prefix . 'profile_ranks_top_title' => array( | |
| 327 | + 'name' => __( 'Show Title', 'gamipress' ), | |
| 328 | + 'desc' => __( 'Show the rank title.', 'gamipress' ), | |
| 329 | + 'type' => 'checkbox', | |
| 330 | + 'classes' => 'gamipress-switch', | |
| 331 | + ), | |
| 332 | + $prefix . 'profile_ranks_top_link' => array( | |
| 333 | + 'name' => __( 'Show Link', 'gamipress' ), | |
| 334 | + 'desc' => __( 'Add a link to the rank page.', 'gamipress' ), | |
| 335 | + 'type' => 'checkbox', | |
| 336 | + 'classes' => 'gamipress-switch', | |
| 337 | + ), | |
| 338 | + $prefix . 'profile_ranks_top_label' => array( | |
| 339 | + 'name' => __( 'Show Label', 'gamipress' ), | |
| 340 | + 'desc' => __( 'Show the rank type label.', 'gamipress' ), | |
| 341 | + 'type' => 'checkbox', | |
| 342 | + 'classes' => 'gamipress-switch', | |
| 343 | + ), | |
| 344 | + $prefix . 'profile_ranks_template_title' => array( | |
| 345 | + 'name' => __( 'Ranks Tab Display Options', 'gamipress' ), | |
| 346 | + 'description' => __( 'Setup how ranks should look on the Ultimate Member user profile tab.', 'gamipress' ), | |
| 347 | + 'type' => 'title', | |
| 348 | + ), | |
| 349 | + $prefix . 'profile_ranks_columns' => array( | |
| 350 | + 'name' => __( 'Columns', 'gamipress' ), | |
| 351 | + 'description' => __( 'Columns to divide ranks.', 'gamipress' ), | |
| 352 | + 'type' => 'select', | |
| 353 | + 'options' => array( | |
| 354 | + '1' => __( '1 Column', 'gamipress' ), | |
| 355 | + '2' => __( '2 Columns', 'gamipress' ), | |
| 356 | + '3' => __( '3 Columns', 'gamipress' ), | |
| 357 | + '4' => __( '4 Columns', 'gamipress' ), | |
| 358 | + '5' => __( '5 Columns', 'gamipress' ), | |
| 359 | + '6' => __( '6 Columns', 'gamipress' ), | |
| 360 | + ), | |
| 361 | + 'default' => '1' | |
| 362 | + ), | |
| 363 | + $prefix . 'profile_ranks_orderby' => array( | |
| 364 | + 'name' => __( 'Order By', 'gamipress' ), | |
| 365 | + 'description' => __( 'Parameter to use for sorting.', 'gamipress' ), | |
| 366 | + 'type' => 'select', | |
| 367 | + 'options' => array( | |
| 368 | + 'priority' => __( 'Priority', 'gamipress' ), | |
| 369 | + 'ID' => __( 'Rank ID', 'gamipress' ), | |
| 370 | + 'title' => __( 'Rank Title', 'gamipress' ), | |
| 371 | + 'date' => __( 'Published Date', 'gamipress' ), | |
| 372 | + 'modified' => __( 'Last Modified Date', 'gamipress' ), | |
| 373 | + 'rand' => __( 'Random', 'gamipress' ), | |
| 374 | + ), | |
| 375 | + 'default' => 'priority', | |
| 376 | + ), | |
| 377 | + $prefix . 'profile_ranks_order' => array( | |
| 378 | + 'name' => __( 'Order', 'gamipress' ), | |
| 379 | + 'description' => __( 'Sort order.', 'gamipress' ), | |
| 380 | + 'type' => 'select', | |
| 381 | + 'options' => array( 'ASC' => __( 'Ascending', 'gamipress' ), 'DESC' => __( 'Descending', 'gamipress' ) ), | |
| 382 | + 'default' => 'DESC', | |
| 383 | + ), | |
| 384 | + | |
| 385 | + ), $achievement_fields, $rank_fields ) ), | |
| 386 | + 'vertical_tabs' => true, | |
| 387 | + 'tabs' => apply_filters( 'gamipress_ultimate_member_settings_tabs', array( | |
| 388 | + 'points' => array( | |
| 389 | + 'title' => __( 'Points', 'gamipress' ), | |
| 390 | + 'icon' => 'dashicons-star-filled', | |
| 391 | + 'fields' => array( | |
| 392 | + $prefix . 'points_placement', | |
| 393 | + $prefix . 'points_tab_title', | |
| 394 | + $prefix . 'points_tab_slug', | |
| 395 | + $prefix . 'points_tab_icon', | |
| 396 | + $prefix . 'profile_points_types', | |
| 397 | + | |
| 398 | + $prefix . 'profile_points_types_top_display_title', | |
| 399 | + $prefix . 'profile_points_types_top_thumbnail', | |
| 400 | + $prefix . 'profile_points_types_top_thumbnail_size', | |
| 401 | + $prefix . 'profile_points_types_top_label' | |
| 402 | + ) | |
| 403 | + ), | |
| 404 | + 'achievements' => array( | |
| 405 | + 'title' => __( 'Achievements', 'gamipress' ), | |
| 406 | + 'icon' => 'dashicons-awards', | |
| 407 | + 'fields' => array_merge( array( | |
| 408 | + $prefix . 'achievements_placement', | |
| 409 | + $prefix . 'achievements_tab_title', | |
| 410 | + $prefix . 'achievements_tab_slug', | |
| 411 | + $prefix . 'achievements_tab_icon', | |
| 412 | + $prefix . 'profile_achievements_types', | |
| 413 | + | |
| 414 | + $prefix . 'profile_achievements_top_display_title', | |
| 415 | + $prefix . 'profile_achievements_top_thumbnail', | |
| 416 | + $prefix . 'profile_achievements_top_thumbnail_size', | |
| 417 | + $prefix . 'profile_achievements_top_title', | |
| 418 | + $prefix . 'profile_achievements_top_link', | |
| 419 | + $prefix . 'profile_achievements_top_label', | |
| 420 | + $prefix . 'profile_achievements_top_limit', | |
| 421 | + | |
| 422 | + $prefix . 'profile_achievements_template_title', | |
| 423 | + $prefix . 'profile_achievements_columns', | |
| 424 | + $prefix . 'profile_achievements_limit', | |
| 425 | + $prefix . 'profile_achievements_orderby', | |
| 426 | + $prefix . 'profile_achievements_order', | |
| 427 | + ), array_keys( $achievement_fields ) ) | |
| 428 | + ), | |
| 429 | + 'ranks' => array( | |
| 430 | + 'title' => __( 'Ranks', 'gamipress' ), | |
| 431 | + 'icon' => 'dashicons-rank', | |
| 432 | + 'fields' => array_merge( array( | |
| 433 | + $prefix . 'ranks_placement', | |
| 434 | + $prefix . 'ranks_tab_title', | |
| 435 | + $prefix . 'ranks_tab_slug', | |
| 436 | + $prefix . 'ranks_tab_icon', | |
| 437 | + $prefix . 'profile_ranks_types', | |
| 438 | + $prefix . 'profile_ranks_thumbnail', | |
| 439 | + | |
| 440 | + $prefix . 'profile_ranks_top_display_title', | |
| 441 | + $prefix . 'profile_ranks_top_thumbnail', | |
| 442 | + $prefix . 'profile_ranks_top_thumbnail_size', | |
| 443 | + $prefix . 'profile_ranks_top_title', | |
| 444 | + $prefix . 'profile_ranks_top_link', | |
| 445 | + $prefix . 'profile_ranks_top_label', | |
| 446 | + | |
| 447 | + $prefix . 'profile_ranks_template_title', | |
| 448 | + $prefix . 'profile_ranks_columns', | |
| 449 | + $prefix . 'profile_ranks_orderby', | |
| 450 | + $prefix . 'profile_ranks_order', | |
| 451 | + ), array_keys( $rank_fields ) ) | |
| 452 | + ) | |
| 453 | + ) ) | |
| 454 | + ); | |
| 455 | + | |
| 456 | + return $meta_boxes; | |
| 457 | + | |
| 458 | +} | |
| 459 | +add_filter( 'gamipress_settings_addons_meta_boxes', 'gamipress_ultimate_member_settings_meta_boxes' ); | |
| 460 | + | |
| 461 | +function gamipress_ultimate_member_profile_points_types_option_cb() { | |
| 462 | + | |
| 463 | + $points_types_slugs = gamipress_get_points_types_slugs(); | |
| 464 | + | |
| 465 | + $gamipress_settings = ( $exists = get_option( 'gamipress_settings' ) ) ? $exists : array(); | |
| 466 | + | |
| 467 | + $points_types_order = isset( $gamipress_settings['ultimate_member_profile_points_types_order'] ) ? | |
| 468 | + $gamipress_settings['ultimate_member_profile_points_types_order'] : $points_types_slugs; | |
| 469 | + | |
| 470 | + $points_types = gamipress_get_points_types(); | |
| 471 | + | |
| 472 | + $options = array(); | |
| 473 | + | |
| 474 | + foreach( $points_types_order as $points_type_slug ) { | |
| 475 | + | |
| 476 | + // Skip if points type not exists | |
| 477 | + if( ! isset( $points_types[$points_type_slug] ) ) { | |
| 478 | + continue; | |
| 479 | + } | |
| 480 | + | |
| 481 | + $options[$points_type_slug] = '<input type="hidden" name="ultimate_member_profile_points_types_order[]" value="' . $points_type_slug . '" />' | |
| 482 | + . $points_types[$points_type_slug]['plural_name']; | |
| 483 | + } | |
| 484 | + | |
| 485 | + $unordered_points_types = array_diff( $points_types_slugs, $points_types_order ); | |
| 486 | + | |
| 487 | + // Append new achievement types | |
| 488 | + foreach( $unordered_points_types as $unordered_points_type ) { | |
| 489 | + | |
| 490 | + // Skip if points type not exists | |
| 491 | + if( ! isset( $points_types[$unordered_points_type] ) ) { | |
| 492 | + continue; | |
| 493 | + } | |
| 494 | + | |
| 495 | + $options[$unordered_points_type] = '<input type="hidden" name="ultimate_member_profile_points_types_order[]" value="' . $unordered_points_type . '" />' | |
| 496 | + . $points_types[$unordered_points_type]['plural_name']; | |
| 497 | + } | |
| 498 | + | |
| 499 | + return $options; | |
| 500 | + | |
| 501 | +} | |
| 502 | + | |
| 503 | +function gamipress_ultimate_member_profile_achievements_types_option_cb() { | |
| 504 | + | |
| 505 | + $achievement_types_slugs = array_diff( | |
| 506 | + gamipress_get_achievement_types_slugs(), | |
| 507 | + gamipress_get_requirement_types_slugs() | |
| 508 | + ); | |
| 509 | + | |
| 510 | + $gamipress_settings = ( $exists = get_option( 'gamipress_settings' ) ) ? $exists : array(); | |
| 511 | + | |
| 512 | + $achievement_types_order = isset( $gamipress_settings['ultimate_member_profile_achievements_types_order'] ) ? | |
| 513 | + $gamipress_settings['ultimate_member_profile_achievements_types_order'] : $achievement_types_slugs; | |
| 514 | + | |
| 515 | + $achievement_types = gamipress_get_achievement_types(); | |
| 516 | + | |
| 517 | + $options = array(); | |
| 518 | + | |
| 519 | + foreach( $achievement_types_order as $achievement_type_slug ) { | |
| 520 | + | |
| 521 | + // Skip if is a requirement type or not exists on $achievement_types | |
| 522 | + if( in_array( $achievement_type_slug, gamipress_get_requirement_types_slugs() ) || ! isset( $achievement_types[$achievement_type_slug] ) ) { | |
| 523 | + continue; | |
| 524 | + } | |
| 525 | + | |
| 526 | + $options[$achievement_type_slug] = '<input type="hidden" name="ultimate_member_profile_achievements_types_order[]" value="' . $achievement_type_slug . '" />' | |
| 527 | + . $achievement_types[$achievement_type_slug]['plural_name']; | |
| 528 | + } | |
| 529 | + | |
| 530 | + $unordered_achievement_types = array_diff( $achievement_types_slugs, $achievement_types_order ); | |
| 531 | + | |
| 532 | + // Append new achievement types | |
| 533 | + foreach( $unordered_achievement_types as $unordered_achievement_type ) { | |
| 534 | + | |
| 535 | + // Skip if achievement not exists | |
| 536 | + if( ! isset( $achievement_types[$unordered_achievement_type] ) ) { | |
| 537 | + continue; | |
| 538 | + } | |
| 539 | + | |
| 540 | + $options[$unordered_achievement_type] = '<input type="hidden" name="ultimate_member_profile_achievements_types_order[]" value="' . $unordered_achievement_type . '" />' | |
| 541 | + . $achievement_types[$unordered_achievement_type]['plural_name']; | |
| 542 | + } | |
| 543 | + | |
| 544 | + return $options; | |
| 545 | + | |
| 546 | +} | |
| 547 | + | |
| 548 | +function gamipress_ultimate_member_profile_ranks_types_option_cb() { | |
| 549 | + | |
| 550 | + $rank_types_slugs = gamipress_get_rank_types_slugs(); | |
| 551 | + | |
| 552 | + $gamipress_settings = ( $exists = get_option( 'gamipress_settings' ) ) ? $exists : array(); | |
| 553 | + | |
| 554 | + $rank_types_order = isset( $gamipress_settings['ultimate_member_profile_ranks_types_order'] ) ? | |
| 555 | + $gamipress_settings['ultimate_member_profile_ranks_types_order'] : $rank_types_slugs; | |
| 556 | + | |
| 557 | + $rank_types = gamipress_get_rank_types(); | |
| 558 | + | |
| 559 | + $options = array(); | |
| 560 | + | |
| 561 | + foreach( $rank_types_order as $rank_type_slug ) { | |
| 562 | + | |
| 563 | + // Skip if rank not exists | |
| 564 | + if( ! isset( $rank_types[$rank_type_slug] ) ) { | |
| 565 | + continue; | |
| 566 | + } | |
| 567 | + | |
| 568 | + $options[$rank_type_slug] = '<input type="hidden" name="ultimate_member_profile_ranks_types_order[]" value="' . $rank_type_slug . '" />' | |
| 569 | + . $rank_types[$rank_type_slug]['plural_name']; | |
| 570 | + | |
| 571 | + } | |
| 572 | + | |
| 573 | + $unordered_rank_types = array_diff( $rank_types_slugs, $rank_types_order ); | |
| 574 | + | |
| 575 | + // Append new rank types | |
| 576 | + foreach( $unordered_rank_types as $unordered_rank_type ) { | |
| 577 | + | |
| 578 | + // Skip if rank not exists | |
| 579 | + if( ! isset( $rank_types[$unordered_rank_type] ) ) { | |
| 580 | + continue; | |
| 581 | + } | |
| 582 | + | |
| 583 | + $options[$unordered_rank_type] = '<input type="hidden" name="ultimate_member_profile_ranks_types_order[]" value="' . $unordered_rank_type . '" />' | |
| 584 | + . $rank_types[$unordered_rank_type]['plural_name']; | |
| 585 | + | |
| 586 | + } | |
| 587 | + | |
| 588 | + return $options; | |
| 589 | + | |
| 590 | +} | |
| 591 | + | |
| 592 | +function gamipress_ultimate_member_save_gamipress_settings() { | |
| 593 | + | |
| 594 | + if( ! isset( $_POST['submit-cmb'] ) ) { | |
| 595 | + return; | |
| 596 | + } | |
| 597 | + | |
| 598 | + if( ! ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'gamipress_settings' ) ) { | |
| 599 | + return; | |
| 600 | + } | |
| 601 | + | |
| 602 | + if( ! isset( $_POST['ultimate_member_profile_points_types_order'] ) || ! isset( $_POST['ultimate_member_profile_achievements_types_order'] ) || ! isset( $_POST['ultimate_member_profile_ranks_types_order'] ) ) { | |
| 603 | + return; | |
| 604 | + } | |
| 605 | + | |
| 606 | + // Setup GamiPress options | |
| 607 | + $gamipress_settings = ( $exists = get_option( 'gamipress_settings' ) ) ? $exists : array(); | |
| 608 | + | |
| 609 | + // Setup new setting | |
| 610 | + $gamipress_settings['ultimate_member_profile_points_types_order'] = $_POST['ultimate_member_profile_points_types_order']; | |
| 611 | + $gamipress_settings['ultimate_member_profile_achievements_types_order'] = $_POST['ultimate_member_profile_achievements_types_order']; | |
| 612 | + $gamipress_settings['ultimate_member_profile_ranks_types_order'] = $_POST['ultimate_member_profile_ranks_types_order']; | |
| 613 | + | |
| 614 | + // Update GamiPress settings | |
| 615 | + update_option( 'gamipress_settings', $gamipress_settings ); | |
| 616 | + | |
| 617 | +} | |
| 618 | +add_action( 'cmb2_save_options-page_fields', 'gamipress_ultimate_member_save_gamipress_settings' ); | |
| 619 | + | |
| 620 | +/** | |
| 621 | + * Plugin automatic updates | |
| 622 | + * | |
| 623 | + * @since 1.0.0 | |
| 624 | + * | |
| 625 | + * @param array $automatic_updates_plugins | |
| 626 | + * | |
| 627 | + * @return array | |
| 628 | + */ | |
| 629 | +function gamipress_ultimate_member_automatic_updates( $automatic_updates_plugins ) { | |
| 630 | + | |
| 631 | + $automatic_updates_plugins['gamipress'] = __( 'Ultimate Member integration', 'gamipress' ); | |
| 632 | + | |
| 633 | + return $automatic_updates_plugins; | |
| 634 | +} | |
| 635 | +add_filter( 'gamipress_automatic_updates_plugins', 'gamipress_ultimate_member_automatic_updates' ); | |