Changeset 7516
- Timestamp:
- 07/28/2018 12:46:28 AM (7 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports
- Files:
-
- 7 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-base.php
r6662 r7516 135 135 136 136 /** 137 * Filter the report data prior to caching and compiling. 138 * 139 * @param array $data The data to filter. 140 * 141 * @return array 142 */ 143 protected function filter_data_fields( array $data ) { 137 * Determine the data fields safelist based on the context of the report. 138 * 139 * @return array The list of fields that are safe to include. 140 */ 141 protected function get_data_fields_safelist() { 144 142 $safelist = $this->public_data_fields; 145 143 … … 147 145 $safelist = array_merge( $safelist, $this->private_data_fields ); 148 146 } 147 148 return $safelist; 149 } 150 151 /** 152 * Filter the report data prior to caching and compiling. 153 * 154 * @param array $data The data to filter. 155 * 156 * @return array 157 */ 158 protected function filter_data_fields( array $data ) { 159 $safelist = $this->get_data_fields_safelist(); 149 160 150 161 array_walk( $data, function ( &$row ) use ( $safelist ) { -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-status.php
r6662 r7516 7 7 defined( 'WPINC' ) || die(); 8 8 9 use Exception; 10 use WordCamp\Reports; 11 use function WordCamp\Reports\Validation\validate_wordcamp_status; 9 12 use WordCamp_Loader; 10 use WordCamp\Reports;11 13 12 14 /** … … 101 103 // Report-specific options. 102 104 $options = wp_parse_args( $options, array( 103 'status_subset' => array(),105 'status_subset' => [], 104 106 ) ); 105 107 106 108 parent::__construct( $start_date, $end_date, $options ); 107 109 108 if ( 'any' === $status ) { 109 $status = ''; 110 } 111 112 if ( $status && $this->validate_status_input( $status ) ) { 113 $this->status = $status; 114 } 115 } 116 117 /** 118 * Validate the given status ID string. 119 * 120 * @param string $status The status ID to filter for in the report. 121 * 122 * @return bool True if the status ID is valid. Otherwise false. 123 */ 124 protected function validate_status_input( $status ) { 125 if ( is_array( $this->options['status_subset'] ) && ! empty( $this->options['status_subset'] ) ) { 126 if ( ! in_array( $status, $this->options['status_subset'], true ) ) { 127 $this->error->add( 'invalid_status', 'Please enter a valid status ID.' ); 128 129 return false; 130 } 131 132 return true; 133 } 134 135 if ( ! in_array( $status, array_keys( WordCamp_Loader::get_post_statuses() ), true ) ) { 136 $this->error->add( 'invalid_status', 'Please enter a valid status ID.' ); 137 138 return false; 139 } 140 141 return true; 110 if ( $status && 'any' !== $status ) { 111 try { 112 $this->status = validate_wordcamp_status( $status, $options ); 113 } catch ( Exception $e ) { 114 $this->error->add( 115 self::$slug . '-status-error', 116 $e->getMessage() 117 ); 118 } 119 } 142 120 } 143 121 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/index.php
r7465 r7516 32 32 33 33 /** 34 * Get the path for the includes directory. 35 * 36 * @return string Path with trailing slash. 37 */ 38 function get_includes_dir_path() { 39 return trailingslashit( PLUGIN_DIR ) . 'includes/'; 40 } 41 42 /** 34 43 * Get the path for the views directory. 35 44 * … … 57 66 return trailingslashit( PLUGIN_URL ) . 'assets/'; 58 67 } 68 69 /** 70 * Autoload all the files in the includes directory. 71 * 72 * @return void 73 */ 74 function load_includes() { 75 foreach ( glob( get_includes_dir_path() . '*.php' ) as $filename ) { 76 if ( is_readable( $filename ) ) { 77 include_once ( $filename ); 78 } 79 } 80 } 81 82 add_action( 'plugins_loaded', __NAMESPACE__ . '\load_includes' ); 59 83 60 84 /** … … 110 134 __NAMESPACE__ . '\Report\Payment_Activity', 111 135 __NAMESPACE__ . '\Report\Sponsorship_Grants', 136 __NAMESPACE__ . '\Report\WordCamp_Details', 112 137 __NAMESPACE__ . '\Report\WordCamp_Status', 113 138 __NAMESPACE__ . '\Report\Meetup_Groups',
Note: See TracChangeset
for help on using the changeset viewer.