Making WordPress.org


Ignore:
Timestamp:
06/06/2016 11:46:09 PM (10 years ago)
Author:
iandunn
Message:

WordCamp Budgets: Prevent modifications to submitted requests using Bulk Edit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php

    r3302 r3306  
    900900
    901901        /**
     902         * Get the current post when inside a `map_meta_cap` callback
     903         *
     904         * Normally it's just the global $post, but sometimes you have to dig it out of $args (e.g., a bulk edit)
     905         *
     906         * @param array $args The $args that was passed to the `map_meta_cap` callback
     907         *
     908         * @return WP_Post|null
     909         */
     910        public static function get_map_meta_cap_post( $args ) {
     911                $post = null;
     912
     913                /*
     914                 * Use a reference to the global $post if it already exists, but don't create one otherwise
     915                 *
     916                 * i.e., Don't use `global $post` and then assign the result of `get_post()` to that.
     917                 *
     918                 * If $GLOBAL['post'] didn't already exist and then we created one, then that could have unintentional
     919                 * side-effects outside of this function.
     920                 */
     921                if ( isset( $GLOBALS['post'] ) ) {
     922                        $post = $GLOBALS['post'];
     923                } elseif ( isset( $args[0] ) && is_int( $args[0] ) ) {
     924                        $post = get_post( $args[0] );
     925                }
     926
     927                return $post;
     928        }
     929
     930        /**
    902931         * Insert an entry into a log for one of the custom post types
    903932         *
Note: See TracChangeset for help on using the changeset viewer.