Making WordPress.org

Changeset 5230


Ignore:
Timestamp:
04/01/2017 02:00:51 PM (10 years ago)
Author:
ocean90
Message:

Rosetta: Allow locale managers to view site stats.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/filter/class-options.php

    r4032 r5230  
    99         */
    1010        private $options = [];
     11
     12        /**
     13         * @var Option[]
     14         */
     15        private $filter_options = [];
     16
    1117
    1218        /**
    … …  
    2430
    2531        /**
     32         * @param Option $option The option.
     33         */
     34        public function add_filter_option( Option $option ) {
     35                $this->filter_options[] = $option;
     36        }
     37
     38        /**
    2639         * Registers the filters.
    2740         */
    … …  
    3548                        );
    3649                }
     50
     51                foreach ( $this->filter_options as $option ) {
     52                        add_filter(
     53                                "option_{$option->get_name()}",
     54                                $option->get_callback(),
     55                                $option->get_priority(),
     56                                $option->get_num_args()
     57                        );
     58                }
    3759        }
    3860}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/site/class-locale-main.php

    r4108 r5230  
    108108                                } )
    109109                );
     110                $options->add_filter_option(
     111                        ( new Filter\Option() )
     112                                ->set_name( 'stats_options' )
     113                                ->set_callback( function( $options ) {
     114                                        $options['roles'] = [
     115                                                'administrator',
     116                                                'editor',
     117                                                'author',
     118                                                Role\Locale_Manager::get_name(),
     119                                        ];
     120                                        return $options;
     121                                } )
     122                                ->set_num_args( 1 )
     123                );
     124
    110125                $options->setup();
    111126        }
Note: See TracChangeset for help on using the changeset viewer.