| @@ -1,0 +1,90 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Requirements Meta Boxes | |
| 4 | + * | |
| 5 | + * @package GamiPress\Admin\Meta_Boxes\Requirements | |
| 6 | + * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]> | |
| 7 | + * @since 1.4.7 | |
| 8 | + */ | |
| 9 | +// Exit if accessed directly | |
| 10 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Register requirements meta boxes | |
| 14 | + * | |
| 15 | + * @param string $post_type | |
| 16 | + * | |
| 17 | + * @since 1.0.0 | |
| 18 | + */ | |
| 19 | +function gamipress_requirements_meta_boxes( $post_type ) { | |
| 20 | + | |
| 21 | + // Start with an underscore to hide fields from custom fields list | |
| 22 | + $prefix = '_gamipress_'; | |
| 23 | + | |
| 24 | + // Grab our requirement types slugs | |
| 25 | + $requirement_types = gamipress_get_requirement_types_slugs(); | |
| 26 | + | |
| 27 | + if( ! in_array( $post_type, $requirement_types ) ) { | |
| 28 | + return; | |
| 29 | + } | |
| 30 | + | |
| 31 | + // Requirement Data | |
| 32 | + gamipress_add_meta_box( | |
| 33 | + 'requirement-data', | |
| 34 | + __( 'Requirement Data', 'gamipress' ), | |
| 35 | + $requirement_types, | |
| 36 | + array( | |
| 37 | + $prefix . 'trigger_type' => array( | |
| 38 | + 'name' => __( 'Trigger Type', 'gamipress' ), | |
| 39 | + 'desc' => '', | |
| 40 | + 'type' => 'advanced_select', | |
| 41 | + 'options' => gamipress_get_activity_triggers() | |
| 42 | + ), | |
| 43 | + $prefix . 'count' => array( | |
| 44 | + 'name' => __( 'Count', 'gamipress' ), | |
| 45 | + 'desc' => '', | |
| 46 | + 'type' => 'text_small', | |
| 47 | + ), | |
| 48 | + $prefix . 'limit' => array( | |
| 49 | + 'name' => __( 'Limit', 'gamipress' ), | |
| 50 | + 'desc' => '', | |
| 51 | + 'type' => 'text_small', | |
| 52 | + ), | |
| 53 | + $prefix . 'limit_type' => array( | |
| 54 | + 'name' => __( 'Limit Type', 'gamipress' ), | |
| 55 | + 'desc' => '', | |
| 56 | + 'type' => 'select', | |
| 57 | + 'options' => array( | |
| 58 | + 'unlimited' => __( 'Unlimited', 'gamipress' ), | |
| 59 | + 'daily' => __( 'Per Day', 'gamipress' ), | |
| 60 | + 'weekly' => __( 'Per Week', 'gamipress' ), | |
| 61 | + 'monthly' => __( 'Per Month', 'gamipress' ), | |
| 62 | + 'yearly' => __( 'Per Year', 'gamipress' ), | |
| 63 | + ) | |
| 64 | + ), | |
| 65 | + $prefix . 'achievement_type' => array( | |
| 66 | + 'name' => __( 'Achievement Type', 'gamipress' ), | |
| 67 | + 'desc' => '', | |
| 68 | + 'type' => 'text', | |
| 69 | + ), | |
| 70 | + $prefix . 'achievement_post' => array( | |
| 71 | + 'name' => __( 'Achievement Post', 'gamipress' ), | |
| 72 | + 'desc' => '', | |
| 73 | + 'type' => 'text_small', | |
| 74 | + ), | |
| 75 | + $prefix . 'points' => array( | |
| 76 | + 'name' => __( 'Points', 'gamipress' ), | |
| 77 | + 'desc' => '', | |
| 78 | + 'type' => 'gamipress_points', | |
| 79 | + ), | |
| 80 | + $prefix . 'maximum_earnings' => array( | |
| 81 | + 'name' => __( 'Maximum Earnings', 'gamipress' ), | |
| 82 | + 'desc' => '', | |
| 83 | + 'type' => 'text_small', | |
| 84 | + ), | |
| 85 | + ), | |
| 86 | + array( 'priority' => 'high' ) | |
| 87 | + ); | |
| 88 | + | |
| 89 | +} | |
| 90 | +add_action( 'gamipress_init_meta_boxes', 'gamipress_requirements_meta_boxes' ); | |