Plugin Directory

Changeset 451789


Ignore:
Timestamp:
10/17/2011 01:36:52 AM (14 years ago)
Author:
tombenner
Message:

Allowing for public forms and hidden menus, standardizing whitespace in loops, adding note about pretty permalinks

Location:
wp-mvc
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • wp-mvc/tags/1.1.1/README.md

    r390557 r451789  
    21211. Upload `wp-mvc` to the `wp-content/plugins/` directory
    22221. Activate the plugin through the 'Plugins' menu in WordPress
     231. Make sure that [Pretty Permalinks](http://codex.wordpress.org/Introduction_to_Blogging#Pretty_Permalinks) are enabled and working
    23241. Either set up the example plugin to see how WP MVC works or start creating an application using the code generation utility `wpmvc`:
    2425
  • wp-mvc/tags/1.1.1/core/controllers/mvc_controller.php

    r390534 r451789  
    2121       
    2222        $models = MvcModelRegistry::get_models();
    23         foreach($models as $model_name => $model) {
     23        foreach ($models as $model_name => $model) {
    2424            $underscore = MvcInflector::underscore($model_name);
    2525            $tableize = MvcInflector::tableize($model_name);
     
    108108   
    109109    protected function load_models($model_names) {
    110         foreach($model_names as $model_name) {
     110        foreach ($model_names as $model_name) {
    111111            $this->load_model($model_name);
    112112        }
     
    135135            $this->set_view_var($variable_name_or_array, $data);
    136136        } else if (is_array($variable_name_or_array)) {
    137             foreach($variable_name_or_array as $key => $value) {
     137            foreach ($variable_name_or_array as $key => $value) {
    138138                $this->set_view_var($key, $value);
    139139            }
     
    199199        if (!empty($options['collection'])) {
    200200            $var_name = empty($options['as']) ? 'object' : $options['as'];
    201             foreach($options['collection'] as $object) {
     201            foreach ($options['collection'] as $object) {
    202202                $view_vars = array();
    203203                $view_vars[$var_name] = $object;
     
    273273        $html = '';
    274274        if (!empty($flashes)) {
    275             foreach($flashes as $type => $message) {
     275            foreach ($flashes as $type => $message) {
    276276                $classes = array();
    277277                $classes[] = $type;
  • wp-mvc/tags/1.1.1/core/functions/functions.php

    r390534 r451789  
    7272    $plugins = mvc_get_plugins();
    7373    if (in_array($plugin, $plugins)) {
    74         foreach($plugins as $key => $existing_plugin) {
     74        foreach ($plugins as $key => $existing_plugin) {
    7575            if ($plugin == $existing_plugin) {
    7676                unset($plugins[$key]);
  • wp-mvc/tags/1.1.1/core/helpers/mvc_form_helper.php

    r437103 r451789  
    66        $defaults = array(
    77            'action' => $this->controller->action,
    8             'controller' => MvcInflector::tableize($model_name)
     8            'controller' => MvcInflector::tableize($model_name),
     9            'public' => false
    910        );
    1011        $options = array_merge($defaults, $options);
     
    1819            $router_options['id'] = $object_id;
    1920        }
    20         $html = '<form action="'.MvcRouter::admin_url($router_options).'" method="post">';
     21       
     22        if ($options['public']) {
     23            $html = '<form action="'.MvcRouter::public_url($router_options).'" method="post">';
     24        } else {
     25            $html = '<form action="'.MvcRouter::admin_url($router_options).'" method="post">';
     26        }
     27       
    2128        if ($object_id) {
    2229            $html .= '<input type="hidden" id="'.$this->input_id('hidden_id').'" name="'.$this->input_name('id').'" value="'.$object_id.'" />';
     
    141148            $html .= '<option value="">'.$empty_name.'</option>';
    142149        }
    143         foreach($options['options'] as $key => $value) {
     150        foreach ($options['options'] as $key => $value) {
    144151            if (is_object($value)) {
    145152                $key = $value->__id;
     
    223230       
    224231        $html .= '<ul id="'.$options['list_id'].'">';
    225         foreach($associated_objects as $associated_object) {
     232        foreach ($associated_objects as $associated_object) {
    226233            $html .= '
    227234                <li>
  • wp-mvc/tags/1.1.1/core/helpers/mvc_helper.php

    r437103 r451789  
    8282                'align',
    8383                'alt',
     84                'autocomplete',
    8485                'checked',
    8586                'class',
     
    9091                'maxlength',
    9192                'name',
     93                'placeholder',
    9294                'readonly',
     95                'required',
    9396                'size',
    9497                'src',
     
    109112                'id',
    110113                'lang',
     114                'maxlength',
    111115                'name',
    112116                'readonly',
     
    135139        );
    136140       
    137         foreach($valid_attributes_by_tag as $key => $valid_attributes) {
     141        foreach ($valid_attributes_by_tag as $key => $valid_attributes) {
    138142            $valid_attributes = array_merge($event_attributes['standard'], $valid_attributes);
    139143            $valid_attributes = self::array_flatten($valid_attributes);
     
    146150       
    147151        $attributes_html = '';
    148         foreach($attributes as $key => $value) {
     152        foreach ($attributes as $key => $value) {
    149153            $attributes_html .= ' '.$key.'="'.esc_attr($value).'"';
    150154        }
     
    157161    public function admin_header_cells($model) {
    158162        $html = '';
    159         foreach($model->admin_columns as $key => $column) {
     163        foreach ($model->admin_columns as $key => $column) {
    160164            $html .= $this->admin_header_cell($column['label']);
    161165        }
     
    171175    public function admin_table_cells($model, $objects) {
    172176        $html = '';
    173         foreach($objects as $object) {
     177        foreach ($objects as $object) {
    174178            $html .= '<tr>';
    175             foreach($model->admin_columns as $key => $column) {
     179            foreach ($model->admin_columns as $key => $column) {
    176180                $html .= $this->admin_table_cell($model, $object, $column);
    177181            }
     
    207211    private function array_flatten($array) {
    208212
    209         foreach($array as $key => $value){
     213        foreach ($array as $key => $value){
    210214            $array[$key] = (array)$value;
    211215        }
  • wp-mvc/tags/1.1.1/core/models/mvc_data_validation_error.php

    r376739 r451789  
    2727        }
    2828        $html = '';
    29         foreach($this->errors as $error) {
     29        foreach ($this->errors as $error) {
    3030            $html .= '
    3131                <div class="mvc-validation-error">
  • wp-mvc/tags/1.1.1/core/models/mvc_database.php

    r371344 r451789  
    3232   
    3333    public function escape_array($array) {
    34         foreach($array as $key => $value) {
     34        foreach ($array as $key => $value) {
    3535            $array[$key] = $this->escape($value);
    3636        }
  • wp-mvc/tags/1.1.1/core/models/mvc_database_adapter.php

    r390534 r451789  
    6767            $joins = array($joins);
    6868        }
    69         foreach($joins as $join) {
     69        foreach ($joins as $join) {
    7070            $type = empty($join['type']) ? 'JOIN' : $join['type'];
    7171            $clauses[] = $type.' '.$join['table'].' '.$join['alias'].' ON '.$join['on'];
     
    8989        $use_table_alias = isset($options['use_table_alias']) ? $options['use_table_alias'] : true;
    9090        $sql_clauses = array();
    91         foreach($conditions as $key => $value) {
     91        foreach ($conditions as $key => $value) {
    9292            if (is_array($value)) {
    9393                $clauses = $this->get_where_sql_clauses($value);
     
    123123    public function get_set_sql($data) {
    124124        $clauses = array();
    125         foreach($data as $key => $value) {
     125        foreach ($data as $key => $value) {
    126126            if (is_string($value) || is_numeric($value)) {
    127127                $clauses[] = $key.' = "'.$this->db->escape($value).'"';
     
    141141    public function get_insert_values_sql($data) {
    142142        $values = array();
    143         foreach($data as $value) {
     143        foreach ($data as $value) {
    144144            $values[] = '"'.$this->db->escape($value).'"';
    145145        }
  • wp-mvc/tags/1.1.1/core/models/mvc_model.php

    r438768 r451789  
    1212    public $validation_error = null;
    1313    public $validation_error_html = null;
     14    public $hide_menu = false;
    1415    private $data_validator = null;
    1516    private $db_adapter = null;
     
    3738        );
    3839       
    39         foreach($defaults as $key => $value) {
     40        foreach ($defaults as $key => $value) {
    4041            $this->{$key} = $value;
    4142        }
     
    5556    public function new_object($data) {
    5657        $object = false;
    57         foreach($data as $field => $value) {
     58        foreach ($data as $field => $value) {
    5859            $object->{$field} = $value;
    5960        }
     
    179180        }
    180181        $formatted_fields = array();
    181         foreach($fields as $field) {
     182        foreach ($fields as $field) {
    182183            if (strpos($field, '.') === false) {
    183184                $field = $this->name.'.'.$field;
     
    190191            $field_reference = 'CONCAT('.implode(', ', $formatted_fields).')';
    191192        }
    192         foreach($keywords as $keyword) {
     193        foreach ($keywords as $keyword) {
    193194            $conditions[] = array($field_reference.' LIKE' => '%'.$keyword.'%');
    194195        }
     
    210211                $options['joins'] = array($options['joins']);
    211212            }
    212             foreach($options['joins'] as $key => $join) {
     213            foreach ($options['joins'] as $key => $join) {
    213214                if (is_string($join)) {
    214215                    $join_model_name = $join;
     
    263264    private function update_associations($id, $model_data) {
    264265        if (!empty($this->associations)) {
    265             foreach($this->associations as $association) {
     266            foreach ($this->associations as $association) {
    266267                switch($association['type']) {
    267268                    case 'has_many':
     
    298299                ));
    299300                if (!empty($model_data[$association_name]['ids'])) {
    300                     foreach($model_data[$association_name]['ids'] as $association_id) {
     301                    foreach ($model_data[$association_name]['ids'] as $association_id) {
    301302                        if (!empty($association_id)) {
    302303                            $this->db_adapter->insert(
     
    319320        $rules = $this->validate;
    320321        if (!empty($rules)) {
    321             foreach($rules as $field => $rule) {
     322            foreach ($rules as $field => $rule) {
    322323                if (isset($data[$field])) {
    323324                    $valid = $this->data_validator->validate($field, $data[$field], $rule);
     
    350351        }
    351352        $admin_pages = array();
    352         foreach($this->admin_pages as $key => $value) {
     353        foreach ($this->admin_pages as $key => $value) {
    353354            if (is_int($key)) {
    354355                $key = $value;
     
    372373    private function init_admin_columns() {
    373374        $admin_columns = array();
    374         foreach($this->admin_columns as $key => $value) {
     375        foreach ($this->admin_columns as $key => $value) {
    375376            if (is_array($value)) {
    376377                if (!isset($value['label'])) {
     
    412413            // Instantiate associated models, so that they don't need to be instantiated multiple times in the subsequent for loop
    413414            $models = array();
    414             foreach($includes as $key => $include) {
     415            foreach ($includes as $key => $include) {
    415416                $model_name = is_string($include) ? $include : $key;
    416417                $models[$model_name] = new $model_name();
     
    420421        $recursive = isset($options['recursive']) ? $options['recursive'] - 1 : 2;
    421422       
    422         foreach($objects as $key => $object) {
     423        foreach ($objects as $key => $object) {
    423424       
    424425            if (!empty($this->primary_key)) {
     
    427428           
    428429            if (!empty($includes) && $recursive != 0) {
    429                 foreach($includes as $include_key => $include) {
     430                foreach ($includes as $include_key => $include) {
    430431                    if (is_string($include)) {
    431432                        $model_name = $include;
     
    514515        $schema = array();
    515516       
    516         foreach($results as $result) {
     517        foreach ($results as $result) {
    517518            $field = $result->Field;
    518519            $type_schema = explode('(', $result->Type);
     
    535536    protected function init_associations() {
    536537        if (!empty($this->belongs_to)) {
    537             foreach($this->belongs_to as $key => $value) {
     538            foreach ($this->belongs_to as $key => $value) {
    538539                $config = null;
    539540                if (is_string($value)) {
     
    565566        }
    566567        if (!empty($this->has_many)) {
    567             foreach($this->has_many as $association) {
     568            foreach ($this->has_many as $association) {
    568569                if (is_string($association)) {
    569570                    if (!is_array($this->associations)) {
     
    582583        }
    583584        if (!empty($this->has_and_belongs_to_many)) {
    584             foreach($this->has_and_belongs_to_many as $association_name => $association) {
     585            foreach ($this->has_and_belongs_to_many as $association_name => $association) {
    585586                if (!is_array($this->associations)) {
    586587                    $this->associations = array();
    587588                }
    588589                if (isset($association['fields'])) {
    589                     foreach($association['fields'] as $key => $field) {
     590                    foreach ($association['fields'] as $key => $field) {
    590591                        $association['fields'][$key] = $association_name.'.'.$field;
    591592                    }
  • wp-mvc/tags/1.1.1/core/mvc_dispatcher.php

    r390534 r451789  
    4545    private function escape_params($params) {
    4646        if (is_array($params)) {
    47             foreach($params as $key => $value) {
     47            foreach ($params as $key => $value) {
    4848                if (is_string($value)) {
    4949                    $params[$key] = stripslashes($value);
  • wp-mvc/tags/1.1.1/core/mvc_file_includer.php

    r390534 r451789  
    1212   
    1313    public function find_first_app_file_or_core_file($filepath) {
    14         foreach($this->plugin_app_paths as $plugin_app_path) {
     14        foreach ($this->plugin_app_paths as $plugin_app_path) {
    1515            if (file_exists($plugin_app_path.$filepath)) {
    1616                return $plugin_app_path.$filepath;
     
    4949   
    5050    public function require_first_app_file($filepath) {
    51         foreach($this->plugin_app_paths as $plugin_app_path) {
     51        foreach ($this->plugin_app_paths as $plugin_app_path) {
    5252            if ($this->include_file($plugin_app_path.$filepath)) {
    5353                return true;
     
    5959    public function include_all_app_files($filepath) {
    6060        $included = false;
    61         foreach($this->plugin_app_paths as $plugin_app_path) {
     61        foreach ($this->plugin_app_paths as $plugin_app_path) {
    6262            if ($this->include_file($plugin_app_path.$filepath)) {
    6363                $included = true;
     
    7272   
    7373    public function include_first_app_file($filepath) {
    74         foreach($this->plugin_app_paths as $plugin_app_path) {
     74        foreach ($this->plugin_app_paths as $plugin_app_path) {
    7575            if ($this->include_file($plugin_app_path.$filepath)) {
    7676                return true;
     
    8181   
    8282    public function include_first_app_file_or_core_file($filepath) {
    83         foreach($this->plugin_app_paths as $plugin_app_path) {
     83        foreach ($this->plugin_app_paths as $plugin_app_path) {
    8484            if ($this->include_file($plugin_app_path.$filepath)) {
    8585                return true;
     
    9696    public function require_all_app_files($filepath) {
    9797        $included = false;
    98         foreach($this->plugin_app_paths as $plugin_app_path) {
     98        foreach ($this->plugin_app_paths as $plugin_app_path) {
    9999            if ($this->include_require_file($plugin_app_path.$filepath)) {
    100100                $included = true;
     
    125125        $filepaths = array();
    126126       
    127         foreach($filenames as $filename) {
     127        foreach ($filenames as $filename) {
    128128            $filepath = $directory.$filename;
    129129            $filepaths[] = $filepath;
     
    156156        $files = array();
    157157       
    158         foreach($file_tmp as $item){
     158        foreach ($file_tmp as $item){
    159159            if (substr($item, -1) != DIRECTORY_SEPARATOR) {
    160160                $files[] = $item;
  • wp-mvc/tags/1.1.1/core/mvc_loader.php

    r390534 r451789  
    6060        );
    6161       
    62         foreach($files as $file) {
     62        foreach ($files as $file) {
    6363            require_once $this->core_path.$file.'.php';
    6464        }
     
    7070        $plugins = $this->get_ordered_plugins();
    7171        $plugin_app_paths = array();
    72         foreach($plugins as $plugin) {
     72        foreach ($plugins as $plugin) {
    7373            $plugin_app_paths[$plugin] = rtrim(WP_PLUGIN_DIR, '/').'/'.$plugin.'/app/';
    7474        }
     
    127127    private function load_controllers() {
    128128   
    129         foreach($this->plugin_app_paths as $plugin_app_path) {
     129        foreach ($this->plugin_app_paths as $plugin_app_path) {
    130130       
    131131            $admin_controller_filenames = $this->file_includer->require_php_files_in_directory($plugin_app_path.'controllers/admin/');
    132132            $public_controller_filenames = $this->file_includer->require_php_files_in_directory($plugin_app_path.'controllers/');
    133133           
    134             foreach($admin_controller_filenames as $filename) {
     134            foreach ($admin_controller_filenames as $filename) {
    135135                if (preg_match('/admin_([^\/]+)_controller\.php/', $filename, $match)) {
    136136                    $this->admin_controller_names[] = $match[1];
     
    138138            }
    139139           
    140             foreach($public_controller_filenames as $filename) {
     140            foreach ($public_controller_filenames as $filename) {
    141141                if (preg_match('/([^\/]+)_controller\.php/', $filename, $match)) {
    142142                    $this->public_controller_names[] = $match[1];
     
    150150    private function load_libs() {
    151151       
    152         foreach($this->plugin_app_paths as $plugin_app_path) {
     152        foreach ($this->plugin_app_paths as $plugin_app_path) {
    153153       
    154154            $this->file_includer->require_php_files_in_directory($plugin_app_path.'libs/');
     
    162162        $models = array();
    163163       
    164         foreach($this->plugin_app_paths as $plugin_app_path) {
     164        foreach ($this->plugin_app_paths as $plugin_app_path) {
    165165       
    166166            $model_filenames = $this->file_includer->require_php_files_in_directory($plugin_app_path.'models/');
    167167           
    168             foreach($model_filenames as $filename) {
     168            foreach ($model_filenames as $filename) {
    169169                $models[] = MvcInflector::class_name_from_filename($filename);
    170170            }
     
    174174        $this->model_names = array();
    175175       
    176         foreach($models as $model) {
     176        foreach ($models as $model) {
    177177            $this->model_names[] = $model;
    178178            $model_class = MvcInflector::camelize($model);
     
    219219            do_action('mvc_admin_init', $mvc_admin_init_args);
    220220       
    221             $title =  MvcInflector::titleize($controller);
     221            $title = MvcInflector::titleize($controller);
    222222            if (!empty($action) && $action != 'index') {
    223223                $title = MvcInflector::titleize($action).' &lsaquo; '.$title;
     
    237237        $menu_position = apply_filters('mvc_menu_position', $menu_position);
    238238       
    239         foreach($this->model_names as $model_name) {
     239        foreach ($this->model_names as $model_name) {
    240240       
    241241            $model = MvcModelRegistry::get_model($model_name);
    242             $tableized = MvcInflector::tableize($model_name);
    243             $pluralized = MvcInflector::pluralize($model_name);
    244             $titleized = MvcInflector::titleize($model_name);
    245             $pluralize_titleized = MvcInflector::pluralize_titleize($model_name);
    246        
    247             $controller_name = 'admin_'.$tableized;
    248            
    249             $top_level_handle = 'mvc_'.$tableized;
    250            
    251             $admin_pages = $model->admin_pages;
    252            
    253             $method = $controller_name.'_index';
    254             $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "index"));');
    255             add_menu_page(
    256                 $pluralize_titleized,
    257                 $pluralize_titleized,
    258                 'administrator',
    259                 $top_level_handle,
    260                 array($this->dispatcher, $method),
    261                 null,
    262                 $menu_position
    263             );
    264            
    265             foreach($admin_pages as $key => $admin_page) {
     242           
     243            if (!$model->hide_menu) {
     244                $tableized = MvcInflector::tableize($model_name);
     245                $pluralized = MvcInflector::pluralize($model_name);
     246                $titleized = MvcInflector::titleize($model_name);
     247                $pluralize_titleized = MvcInflector::pluralize_titleize($model_name);
     248       
     249                $controller_name = 'admin_'.$tableized;
     250           
     251                $top_level_handle = 'mvc_'.$tableized;
     252           
     253                $admin_pages = $model->admin_pages;
     254           
     255                $method = $controller_name.'_index';
     256                $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "index"));');
     257                add_menu_page(
     258                    $pluralize_titleized,
     259                    $pluralize_titleized,
     260                    'administrator',
     261                    $top_level_handle,
     262                    array($this->dispatcher, $method),
     263                    null,
     264                    $menu_position
     265                );
     266           
     267                foreach ($admin_pages as $key => $admin_page) {
    266268               
    267                 $method = $controller_name.'_'.$admin_page['action'];
     269                    $method = $controller_name.'_'.$admin_page['action'];
    268270               
    269                 if (!method_exists($this->dispatcher, $method)) {
    270                     $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "'.$admin_page['action'].'"));');
     271                    if (!method_exists($this->dispatcher, $method)) {
     272                        $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "'.$admin_page['action'].'"));');
     273                    }
     274               
     275                    $page_handle = $top_level_handle.'-'.$key;
     276               
     277                    if ($admin_page['in_menu']) {
     278                        add_submenu_page(
     279                            $top_level_handle,
     280                            $admin_page['label'].' &lsaquo; '.$pluralize_titleized,
     281                            $admin_page['label'],
     282                            $admin_page['capability'],
     283                            $page_handle,
     284                            array($this->dispatcher, $method)
     285                        );
     286                    } else {
     287                        // It looks like there isn't a more native way of creating an admin page without
     288                        // having it show up in the menu, but if there is, it should be implemented here.
     289                        // To do: set up capability handling and page title handling for these pages that aren't in the menu
     290                        $hookname = get_plugin_page_hookname($page_handle,'');
     291                        if (!empty($hookname)) {
     292                            add_action($hookname, array($this->dispatcher, $method));
     293                        }
     294                        $_registered_pages[$hookname] = true;
     295                    }
     296           
    271297                }
    272                
    273                 $page_handle = $top_level_handle.'-'.$key;
    274                
    275                 if ($admin_page['in_menu']) {
    276                     add_submenu_page(
    277                         $top_level_handle,
    278                         $admin_page['label'].' &lsaquo; '.$pluralize_titleized,
    279                         $admin_page['label'],
    280                         $admin_page['capability'],
    281                         $page_handle,
    282                         array($this->dispatcher, $method)
    283                     );
    284                 } else {
    285                     // It looks like there isn't a more native way of creating an admin page without
    286                     // having it show up in the menu, but if there is, it should be implemented here.
    287                     // To do: set up capability handling and page title handling for these pages that aren't in the menu
    288                     $hookname = get_plugin_page_hookname($page_handle,'');
    289                     if (!empty($hookname)) {
    290                         add_action($hookname, array($this->dispatcher, $method));
    291                     }
    292                     $_registered_pages[$hookname] = true;
    293                 }
    294            
    295             }
    296             $menu_position++;
    297 
     298                $menu_position++;
     299
     300            }
    298301        }
    299302   
     
    321324        }
    322325       
    323         foreach($routes as $route) {
     326        foreach ($routes as $route) {
    324327           
    325328            $route_path = $route[0];
     
    327330           
    328331            if (strpos($route_path, '{:controller}') !== false) {
    329                 foreach($this->public_controller_names as $controller) {
     332                foreach ($this->public_controller_names as $controller) {
    330333                    $route_rules = $this->get_rewrite_rules($route_path, $route_defaults, $controller);
    331334                    $new_rules = array_merge($new_rules, $route_rules);
     
    354357        // and append them to the match string for use in a WP rewrite rule
    355358        preg_match_all('/{:(.+?)(:.*?)?}/', $rewrite_path, $matches);
    356         foreach($matches[1] as $query_var) {
     359        foreach ($matches[1] as $query_var) {
    357360            $query_var = 'mvc_'.$query_var;
    358361            if ($query_var != 'mvc_controller') {
     
    365368        // Do the same as above for route params that are defined as route defaults (e.g. array('action' => 'show'))
    366369        if (!empty($route_defaults)) {
    367             foreach($route_defaults as $query_var => $value) {
     370            foreach ($route_defaults as $query_var => $value) {
    368371                $query_var = 'mvc_'.$query_var;
    369372                if ($query_var != 'mvc_controller') {
     
    404407            $query_params = $wp_query->query;
    405408            $params = array();
    406             foreach($query_params as $key => $value) {
     409            foreach ($query_params as $key => $value) {
    407410                $key = preg_replace('/^(mvc_)/', '', $key);
    408411                $params[$key] = $value;
     
    429432        $routes = MvcRouter::get_admin_ajax_routes();
    430433        if (!empty($routes)) {
    431             foreach($routes as $route) {
     434            foreach ($routes as $route) {
    432435                $route['is_admin_ajax'] = true;
    433436                $method = 'admin_ajax_'.$route['wp_action'];
  • wp-mvc/tags/1.1.1/core/mvc_plugin_loader.php

    r390534 r451789  
    3939        $plugins = $this->get_plugins();
    4040        if (in_array($plugin, $plugins)) {
    41             foreach($plugins as $key => $existing_plugin) {
     41            foreach ($plugins as $key => $existing_plugin) {
    4242                if ($plugin == $existing_plugin) {
    4343                    unset($plugins[$key]);
     
    5757   
    5858    protected function filter_nonexistent_plugins($plugins) {
    59         foreach($plugins as $key => $plugin) {
     59        foreach ($plugins as $key => $plugin) {
    6060            if (!is_dir(WP_PLUGIN_DIR.'/'.$plugin)) {
    6161                unset($plugins[$key]);
  • wp-mvc/tags/1.1.1/core/mvc_router.php

    r390534 r451789  
    2222            }
    2323        }
    24         foreach($routes as $route) {
     24        foreach ($routes as $route) {
    2525            $route_path = $route[0];
    2626            $route_defaults = $route[1];
     
    3636            preg_match_all('/{:([\w]+).*?}/', $path_pattern, $matches, PREG_SET_ORDER);
    3737            $path = $path_pattern;
    38             foreach($matches as $match) {
     38            foreach ($matches as $match) {
    3939                $pattern = $match[0];
    4040                $option_key = $match[1];
  • wp-mvc/tags/1.1.1/core/mvc_templater.php

    r371570 r451789  
    1414            $this->set_template_var($variable_name_or_array, $data);
    1515        } else if (is_array($variable_name_or_array)) {
    16             foreach($variable_name_or_array as $key => $value) {
     16            foreach ($variable_name_or_array as $key => $value) {
    1717                $this->set_template_var($key, $value);
    1818            }
  • wp-mvc/tags/1.1.1/core/shells/generate_shell.php

    r437103 r451789  
    6262            'views/admin'
    6363        );
    64         foreach($app_directories as $path) {
     64        foreach ($app_directories as $path) {
    6565            $directory->create($plugin_app_path.$path.'/');
    6666        }
  • wp-mvc/tags/1.1.1/core/shells/mvc_shell.php

    r390534 r451789  
    5252   
    5353    protected function load_models($model_names) {
    54         foreach($model_names as $model_name) {
     54        foreach ($model_names as $model_name) {
    5555            $this->load_model($model_name);
    5656        }
  • wp-mvc/tags/1.1.1/core/templates/plugin/app/views/index.php

    r390534 r451789  
    22<?php
    33echo '
    4 <?php foreach($objects as $object): ?>
     4<?php foreach ($objects as $object): ?>
    55
    66    <?php $this->render_view(\'_item\', array(\'locals\' => array(\'object\' => $object))); ?>
  • wp-mvc/tags/1.1.1/readme.txt

    r437103 r451789  
    24241. Upload `wp-mvc` to the `wp-content/plugins/` directory
    25251. Activate the plugin through the 'Plugins' menu in WordPress
     261. Make sure that [Pretty Permalinks](http://codex.wordpress.org/Introduction_to_Blogging#Pretty_Permalinks) are enabled and working
    26271. Either set up the example plugin to see how WP MVC works or start creating an application using the code generation utility `wpmvc`:
    2728
  • wp-mvc/trunk/README.md

    r390557 r451789  
    21211. Upload `wp-mvc` to the `wp-content/plugins/` directory
    22221. Activate the plugin through the 'Plugins' menu in WordPress
     231. Make sure that [Pretty Permalinks](http://codex.wordpress.org/Introduction_to_Blogging#Pretty_Permalinks) are enabled and working
    23241. Either set up the example plugin to see how WP MVC works or start creating an application using the code generation utility `wpmvc`:
    2425
  • wp-mvc/trunk/core/controllers/mvc_controller.php

    r390534 r451789  
    2121       
    2222        $models = MvcModelRegistry::get_models();
    23         foreach($models as $model_name => $model) {
     23        foreach ($models as $model_name => $model) {
    2424            $underscore = MvcInflector::underscore($model_name);
    2525            $tableize = MvcInflector::tableize($model_name);
     
    108108   
    109109    protected function load_models($model_names) {
    110         foreach($model_names as $model_name) {
     110        foreach ($model_names as $model_name) {
    111111            $this->load_model($model_name);
    112112        }
     
    135135            $this->set_view_var($variable_name_or_array, $data);
    136136        } else if (is_array($variable_name_or_array)) {
    137             foreach($variable_name_or_array as $key => $value) {
     137            foreach ($variable_name_or_array as $key => $value) {
    138138                $this->set_view_var($key, $value);
    139139            }
     
    199199        if (!empty($options['collection'])) {
    200200            $var_name = empty($options['as']) ? 'object' : $options['as'];
    201             foreach($options['collection'] as $object) {
     201            foreach ($options['collection'] as $object) {
    202202                $view_vars = array();
    203203                $view_vars[$var_name] = $object;
     
    273273        $html = '';
    274274        if (!empty($flashes)) {
    275             foreach($flashes as $type => $message) {
     275            foreach ($flashes as $type => $message) {
    276276                $classes = array();
    277277                $classes[] = $type;
  • wp-mvc/trunk/core/functions/functions.php

    r390534 r451789  
    7272    $plugins = mvc_get_plugins();
    7373    if (in_array($plugin, $plugins)) {
    74         foreach($plugins as $key => $existing_plugin) {
     74        foreach ($plugins as $key => $existing_plugin) {
    7575            if ($plugin == $existing_plugin) {
    7676                unset($plugins[$key]);
  • wp-mvc/trunk/core/helpers/mvc_form_helper.php

    r437103 r451789  
    66        $defaults = array(
    77            'action' => $this->controller->action,
    8             'controller' => MvcInflector::tableize($model_name)
     8            'controller' => MvcInflector::tableize($model_name),
     9            'public' => false
    910        );
    1011        $options = array_merge($defaults, $options);
     
    1819            $router_options['id'] = $object_id;
    1920        }
    20         $html = '<form action="'.MvcRouter::admin_url($router_options).'" method="post">';
     21       
     22        if ($options['public']) {
     23            $html = '<form action="'.MvcRouter::public_url($router_options).'" method="post">';
     24        } else {
     25            $html = '<form action="'.MvcRouter::admin_url($router_options).'" method="post">';
     26        }
     27       
    2128        if ($object_id) {
    2229            $html .= '<input type="hidden" id="'.$this->input_id('hidden_id').'" name="'.$this->input_name('id').'" value="'.$object_id.'" />';
     
    141148            $html .= '<option value="">'.$empty_name.'</option>';
    142149        }
    143         foreach($options['options'] as $key => $value) {
     150        foreach ($options['options'] as $key => $value) {
    144151            if (is_object($value)) {
    145152                $key = $value->__id;
     
    223230       
    224231        $html .= '<ul id="'.$options['list_id'].'">';
    225         foreach($associated_objects as $associated_object) {
     232        foreach ($associated_objects as $associated_object) {
    226233            $html .= '
    227234                <li>
  • wp-mvc/trunk/core/helpers/mvc_helper.php

    r437103 r451789  
    8282                'align',
    8383                'alt',
     84                'autocomplete',
    8485                'checked',
    8586                'class',
     
    9091                'maxlength',
    9192                'name',
     93                'placeholder',
    9294                'readonly',
     95                'required',
    9396                'size',
    9497                'src',
     
    109112                'id',
    110113                'lang',
     114                'maxlength',
    111115                'name',
    112116                'readonly',
     
    135139        );
    136140       
    137         foreach($valid_attributes_by_tag as $key => $valid_attributes) {
     141        foreach ($valid_attributes_by_tag as $key => $valid_attributes) {
    138142            $valid_attributes = array_merge($event_attributes['standard'], $valid_attributes);
    139143            $valid_attributes = self::array_flatten($valid_attributes);
     
    146150       
    147151        $attributes_html = '';
    148         foreach($attributes as $key => $value) {
     152        foreach ($attributes as $key => $value) {
    149153            $attributes_html .= ' '.$key.'="'.esc_attr($value).'"';
    150154        }
     
    157161    public function admin_header_cells($model) {
    158162        $html = '';
    159         foreach($model->admin_columns as $key => $column) {
     163        foreach ($model->admin_columns as $key => $column) {
    160164            $html .= $this->admin_header_cell($column['label']);
    161165        }
     
    171175    public function admin_table_cells($model, $objects) {
    172176        $html = '';
    173         foreach($objects as $object) {
     177        foreach ($objects as $object) {
    174178            $html .= '<tr>';
    175             foreach($model->admin_columns as $key => $column) {
     179            foreach ($model->admin_columns as $key => $column) {
    176180                $html .= $this->admin_table_cell($model, $object, $column);
    177181            }
     
    207211    private function array_flatten($array) {
    208212
    209         foreach($array as $key => $value){
     213        foreach ($array as $key => $value){
    210214            $array[$key] = (array)$value;
    211215        }
  • wp-mvc/trunk/core/models/mvc_data_validation_error.php

    r376739 r451789  
    2727        }
    2828        $html = '';
    29         foreach($this->errors as $error) {
     29        foreach ($this->errors as $error) {
    3030            $html .= '
    3131                <div class="mvc-validation-error">
  • wp-mvc/trunk/core/models/mvc_database.php

    r371344 r451789  
    3232   
    3333    public function escape_array($array) {
    34         foreach($array as $key => $value) {
     34        foreach ($array as $key => $value) {
    3535            $array[$key] = $this->escape($value);
    3636        }
  • wp-mvc/trunk/core/models/mvc_database_adapter.php

    r390534 r451789  
    6767            $joins = array($joins);
    6868        }
    69         foreach($joins as $join) {
     69        foreach ($joins as $join) {
    7070            $type = empty($join['type']) ? 'JOIN' : $join['type'];
    7171            $clauses[] = $type.' '.$join['table'].' '.$join['alias'].' ON '.$join['on'];
     
    8989        $use_table_alias = isset($options['use_table_alias']) ? $options['use_table_alias'] : true;
    9090        $sql_clauses = array();
    91         foreach($conditions as $key => $value) {
     91        foreach ($conditions as $key => $value) {
    9292            if (is_array($value)) {
    9393                $clauses = $this->get_where_sql_clauses($value);
     
    123123    public function get_set_sql($data) {
    124124        $clauses = array();
    125         foreach($data as $key => $value) {
     125        foreach ($data as $key => $value) {
    126126            if (is_string($value) || is_numeric($value)) {
    127127                $clauses[] = $key.' = "'.$this->db->escape($value).'"';
     
    141141    public function get_insert_values_sql($data) {
    142142        $values = array();
    143         foreach($data as $value) {
     143        foreach ($data as $value) {
    144144            $values[] = '"'.$this->db->escape($value).'"';
    145145        }
  • wp-mvc/trunk/core/models/mvc_model.php

    r438768 r451789  
    1212    public $validation_error = null;
    1313    public $validation_error_html = null;
     14    public $hide_menu = false;
    1415    private $data_validator = null;
    1516    private $db_adapter = null;
     
    3738        );
    3839       
    39         foreach($defaults as $key => $value) {
     40        foreach ($defaults as $key => $value) {
    4041            $this->{$key} = $value;
    4142        }
     
    5556    public function new_object($data) {
    5657        $object = false;
    57         foreach($data as $field => $value) {
     58        foreach ($data as $field => $value) {
    5859            $object->{$field} = $value;
    5960        }
     
    179180        }
    180181        $formatted_fields = array();
    181         foreach($fields as $field) {
     182        foreach ($fields as $field) {
    182183            if (strpos($field, '.') === false) {
    183184                $field = $this->name.'.'.$field;
     
    190191            $field_reference = 'CONCAT('.implode(', ', $formatted_fields).')';
    191192        }
    192         foreach($keywords as $keyword) {
     193        foreach ($keywords as $keyword) {
    193194            $conditions[] = array($field_reference.' LIKE' => '%'.$keyword.'%');
    194195        }
     
    210211                $options['joins'] = array($options['joins']);
    211212            }
    212             foreach($options['joins'] as $key => $join) {
     213            foreach ($options['joins'] as $key => $join) {
    213214                if (is_string($join)) {
    214215                    $join_model_name = $join;
     
    263264    private function update_associations($id, $model_data) {
    264265        if (!empty($this->associations)) {
    265             foreach($this->associations as $association) {
     266            foreach ($this->associations as $association) {
    266267                switch($association['type']) {
    267268                    case 'has_many':
     
    298299                ));
    299300                if (!empty($model_data[$association_name]['ids'])) {
    300                     foreach($model_data[$association_name]['ids'] as $association_id) {
     301                    foreach ($model_data[$association_name]['ids'] as $association_id) {
    301302                        if (!empty($association_id)) {
    302303                            $this->db_adapter->insert(
     
    319320        $rules = $this->validate;
    320321        if (!empty($rules)) {
    321             foreach($rules as $field => $rule) {
     322            foreach ($rules as $field => $rule) {
    322323                if (isset($data[$field])) {
    323324                    $valid = $this->data_validator->validate($field, $data[$field], $rule);
     
    350351        }
    351352        $admin_pages = array();
    352         foreach($this->admin_pages as $key => $value) {
     353        foreach ($this->admin_pages as $key => $value) {
    353354            if (is_int($key)) {
    354355                $key = $value;
     
    372373    private function init_admin_columns() {
    373374        $admin_columns = array();
    374         foreach($this->admin_columns as $key => $value) {
     375        foreach ($this->admin_columns as $key => $value) {
    375376            if (is_array($value)) {
    376377                if (!isset($value['label'])) {
     
    412413            // Instantiate associated models, so that they don't need to be instantiated multiple times in the subsequent for loop
    413414            $models = array();
    414             foreach($includes as $key => $include) {
     415            foreach ($includes as $key => $include) {
    415416                $model_name = is_string($include) ? $include : $key;
    416417                $models[$model_name] = new $model_name();
     
    420421        $recursive = isset($options['recursive']) ? $options['recursive'] - 1 : 2;
    421422       
    422         foreach($objects as $key => $object) {
     423        foreach ($objects as $key => $object) {
    423424       
    424425            if (!empty($this->primary_key)) {
     
    427428           
    428429            if (!empty($includes) && $recursive != 0) {
    429                 foreach($includes as $include_key => $include) {
     430                foreach ($includes as $include_key => $include) {
    430431                    if (is_string($include)) {
    431432                        $model_name = $include;
     
    514515        $schema = array();
    515516       
    516         foreach($results as $result) {
     517        foreach ($results as $result) {
    517518            $field = $result->Field;
    518519            $type_schema = explode('(', $result->Type);
     
    535536    protected function init_associations() {
    536537        if (!empty($this->belongs_to)) {
    537             foreach($this->belongs_to as $key => $value) {
     538            foreach ($this->belongs_to as $key => $value) {
    538539                $config = null;
    539540                if (is_string($value)) {
     
    565566        }
    566567        if (!empty($this->has_many)) {
    567             foreach($this->has_many as $association) {
     568            foreach ($this->has_many as $association) {
    568569                if (is_string($association)) {
    569570                    if (!is_array($this->associations)) {
     
    582583        }
    583584        if (!empty($this->has_and_belongs_to_many)) {
    584             foreach($this->has_and_belongs_to_many as $association_name => $association) {
     585            foreach ($this->has_and_belongs_to_many as $association_name => $association) {
    585586                if (!is_array($this->associations)) {
    586587                    $this->associations = array();
    587588                }
    588589                if (isset($association['fields'])) {
    589                     foreach($association['fields'] as $key => $field) {
     590                    foreach ($association['fields'] as $key => $field) {
    590591                        $association['fields'][$key] = $association_name.'.'.$field;
    591592                    }
  • wp-mvc/trunk/core/mvc_dispatcher.php

    r390534 r451789  
    4545    private function escape_params($params) {
    4646        if (is_array($params)) {
    47             foreach($params as $key => $value) {
     47            foreach ($params as $key => $value) {
    4848                if (is_string($value)) {
    4949                    $params[$key] = stripslashes($value);
  • wp-mvc/trunk/core/mvc_file_includer.php

    r390534 r451789  
    1212   
    1313    public function find_first_app_file_or_core_file($filepath) {
    14         foreach($this->plugin_app_paths as $plugin_app_path) {
     14        foreach ($this->plugin_app_paths as $plugin_app_path) {
    1515            if (file_exists($plugin_app_path.$filepath)) {
    1616                return $plugin_app_path.$filepath;
     
    4949   
    5050    public function require_first_app_file($filepath) {
    51         foreach($this->plugin_app_paths as $plugin_app_path) {
     51        foreach ($this->plugin_app_paths as $plugin_app_path) {
    5252            if ($this->include_file($plugin_app_path.$filepath)) {
    5353                return true;
     
    5959    public function include_all_app_files($filepath) {
    6060        $included = false;
    61         foreach($this->plugin_app_paths as $plugin_app_path) {
     61        foreach ($this->plugin_app_paths as $plugin_app_path) {
    6262            if ($this->include_file($plugin_app_path.$filepath)) {
    6363                $included = true;
     
    7272   
    7373    public function include_first_app_file($filepath) {
    74         foreach($this->plugin_app_paths as $plugin_app_path) {
     74        foreach ($this->plugin_app_paths as $plugin_app_path) {
    7575            if ($this->include_file($plugin_app_path.$filepath)) {
    7676                return true;
     
    8181   
    8282    public function include_first_app_file_or_core_file($filepath) {
    83         foreach($this->plugin_app_paths as $plugin_app_path) {
     83        foreach ($this->plugin_app_paths as $plugin_app_path) {
    8484            if ($this->include_file($plugin_app_path.$filepath)) {
    8585                return true;
     
    9696    public function require_all_app_files($filepath) {
    9797        $included = false;
    98         foreach($this->plugin_app_paths as $plugin_app_path) {
     98        foreach ($this->plugin_app_paths as $plugin_app_path) {
    9999            if ($this->include_require_file($plugin_app_path.$filepath)) {
    100100                $included = true;
     
    125125        $filepaths = array();
    126126       
    127         foreach($filenames as $filename) {
     127        foreach ($filenames as $filename) {
    128128            $filepath = $directory.$filename;
    129129            $filepaths[] = $filepath;
     
    156156        $files = array();
    157157       
    158         foreach($file_tmp as $item){
     158        foreach ($file_tmp as $item){
    159159            if (substr($item, -1) != DIRECTORY_SEPARATOR) {
    160160                $files[] = $item;
  • wp-mvc/trunk/core/mvc_loader.php

    r390534 r451789  
    6060        );
    6161       
    62         foreach($files as $file) {
     62        foreach ($files as $file) {
    6363            require_once $this->core_path.$file.'.php';
    6464        }
     
    7070        $plugins = $this->get_ordered_plugins();
    7171        $plugin_app_paths = array();
    72         foreach($plugins as $plugin) {
     72        foreach ($plugins as $plugin) {
    7373            $plugin_app_paths[$plugin] = rtrim(WP_PLUGIN_DIR, '/').'/'.$plugin.'/app/';
    7474        }
     
    127127    private function load_controllers() {
    128128   
    129         foreach($this->plugin_app_paths as $plugin_app_path) {
     129        foreach ($this->plugin_app_paths as $plugin_app_path) {
    130130       
    131131            $admin_controller_filenames = $this->file_includer->require_php_files_in_directory($plugin_app_path.'controllers/admin/');
    132132            $public_controller_filenames = $this->file_includer->require_php_files_in_directory($plugin_app_path.'controllers/');
    133133           
    134             foreach($admin_controller_filenames as $filename) {
     134            foreach ($admin_controller_filenames as $filename) {
    135135                if (preg_match('/admin_([^\/]+)_controller\.php/', $filename, $match)) {
    136136                    $this->admin_controller_names[] = $match[1];
     
    138138            }
    139139           
    140             foreach($public_controller_filenames as $filename) {
     140            foreach ($public_controller_filenames as $filename) {
    141141                if (preg_match('/([^\/]+)_controller\.php/', $filename, $match)) {
    142142                    $this->public_controller_names[] = $match[1];
     
    150150    private function load_libs() {
    151151       
    152         foreach($this->plugin_app_paths as $plugin_app_path) {
     152        foreach ($this->plugin_app_paths as $plugin_app_path) {
    153153       
    154154            $this->file_includer->require_php_files_in_directory($plugin_app_path.'libs/');
     
    162162        $models = array();
    163163       
    164         foreach($this->plugin_app_paths as $plugin_app_path) {
     164        foreach ($this->plugin_app_paths as $plugin_app_path) {
    165165       
    166166            $model_filenames = $this->file_includer->require_php_files_in_directory($plugin_app_path.'models/');
    167167           
    168             foreach($model_filenames as $filename) {
     168            foreach ($model_filenames as $filename) {
    169169                $models[] = MvcInflector::class_name_from_filename($filename);
    170170            }
     
    174174        $this->model_names = array();
    175175       
    176         foreach($models as $model) {
     176        foreach ($models as $model) {
    177177            $this->model_names[] = $model;
    178178            $model_class = MvcInflector::camelize($model);
     
    219219            do_action('mvc_admin_init', $mvc_admin_init_args);
    220220       
    221             $title =  MvcInflector::titleize($controller);
     221            $title = MvcInflector::titleize($controller);
    222222            if (!empty($action) && $action != 'index') {
    223223                $title = MvcInflector::titleize($action).' &lsaquo; '.$title;
     
    237237        $menu_position = apply_filters('mvc_menu_position', $menu_position);
    238238       
    239         foreach($this->model_names as $model_name) {
     239        foreach ($this->model_names as $model_name) {
    240240       
    241241            $model = MvcModelRegistry::get_model($model_name);
    242             $tableized = MvcInflector::tableize($model_name);
    243             $pluralized = MvcInflector::pluralize($model_name);
    244             $titleized = MvcInflector::titleize($model_name);
    245             $pluralize_titleized = MvcInflector::pluralize_titleize($model_name);
    246        
    247             $controller_name = 'admin_'.$tableized;
    248            
    249             $top_level_handle = 'mvc_'.$tableized;
    250            
    251             $admin_pages = $model->admin_pages;
    252            
    253             $method = $controller_name.'_index';
    254             $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "index"));');
    255             add_menu_page(
    256                 $pluralize_titleized,
    257                 $pluralize_titleized,
    258                 'administrator',
    259                 $top_level_handle,
    260                 array($this->dispatcher, $method),
    261                 null,
    262                 $menu_position
    263             );
    264            
    265             foreach($admin_pages as $key => $admin_page) {
     242           
     243            if (!$model->hide_menu) {
     244                $tableized = MvcInflector::tableize($model_name);
     245                $pluralized = MvcInflector::pluralize($model_name);
     246                $titleized = MvcInflector::titleize($model_name);
     247                $pluralize_titleized = MvcInflector::pluralize_titleize($model_name);
     248       
     249                $controller_name = 'admin_'.$tableized;
     250           
     251                $top_level_handle = 'mvc_'.$tableized;
     252           
     253                $admin_pages = $model->admin_pages;
     254           
     255                $method = $controller_name.'_index';
     256                $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "index"));');
     257                add_menu_page(
     258                    $pluralize_titleized,
     259                    $pluralize_titleized,
     260                    'administrator',
     261                    $top_level_handle,
     262                    array($this->dispatcher, $method),
     263                    null,
     264                    $menu_position
     265                );
     266           
     267                foreach ($admin_pages as $key => $admin_page) {
    266268               
    267                 $method = $controller_name.'_'.$admin_page['action'];
     269                    $method = $controller_name.'_'.$admin_page['action'];
    268270               
    269                 if (!method_exists($this->dispatcher, $method)) {
    270                     $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "'.$admin_page['action'].'"));');
     271                    if (!method_exists($this->dispatcher, $method)) {
     272                        $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "'.$controller_name.'", "action" => "'.$admin_page['action'].'"));');
     273                    }
     274               
     275                    $page_handle = $top_level_handle.'-'.$key;
     276               
     277                    if ($admin_page['in_menu']) {
     278                        add_submenu_page(
     279                            $top_level_handle,
     280                            $admin_page['label'].' &lsaquo; '.$pluralize_titleized,
     281                            $admin_page['label'],
     282                            $admin_page['capability'],
     283                            $page_handle,
     284                            array($this->dispatcher, $method)
     285                        );
     286                    } else {
     287                        // It looks like there isn't a more native way of creating an admin page without
     288                        // having it show up in the menu, but if there is, it should be implemented here.
     289                        // To do: set up capability handling and page title handling for these pages that aren't in the menu
     290                        $hookname = get_plugin_page_hookname($page_handle,'');
     291                        if (!empty($hookname)) {
     292                            add_action($hookname, array($this->dispatcher, $method));
     293                        }
     294                        $_registered_pages[$hookname] = true;
     295                    }
     296           
    271297                }
    272                
    273                 $page_handle = $top_level_handle.'-'.$key;
    274                
    275                 if ($admin_page['in_menu']) {
    276                     add_submenu_page(
    277                         $top_level_handle,
    278                         $admin_page['label'].' &lsaquo; '.$pluralize_titleized,
    279                         $admin_page['label'],
    280                         $admin_page['capability'],
    281                         $page_handle,
    282                         array($this->dispatcher, $method)
    283                     );
    284                 } else {
    285                     // It looks like there isn't a more native way of creating an admin page without
    286                     // having it show up in the menu, but if there is, it should be implemented here.
    287                     // To do: set up capability handling and page title handling for these pages that aren't in the menu
    288                     $hookname = get_plugin_page_hookname($page_handle,'');
    289                     if (!empty($hookname)) {
    290                         add_action($hookname, array($this->dispatcher, $method));
    291                     }
    292                     $_registered_pages[$hookname] = true;
    293                 }
    294            
    295             }
    296             $menu_position++;
    297 
     298                $menu_position++;
     299
     300            }
    298301        }
    299302   
     
    321324        }
    322325       
    323         foreach($routes as $route) {
     326        foreach ($routes as $route) {
    324327           
    325328            $route_path = $route[0];
     
    327330           
    328331            if (strpos($route_path, '{:controller}') !== false) {
    329                 foreach($this->public_controller_names as $controller) {
     332                foreach ($this->public_controller_names as $controller) {
    330333                    $route_rules = $this->get_rewrite_rules($route_path, $route_defaults, $controller);
    331334                    $new_rules = array_merge($new_rules, $route_rules);
     
    354357        // and append them to the match string for use in a WP rewrite rule
    355358        preg_match_all('/{:(.+?)(:.*?)?}/', $rewrite_path, $matches);
    356         foreach($matches[1] as $query_var) {
     359        foreach ($matches[1] as $query_var) {
    357360            $query_var = 'mvc_'.$query_var;
    358361            if ($query_var != 'mvc_controller') {
     
    365368        // Do the same as above for route params that are defined as route defaults (e.g. array('action' => 'show'))
    366369        if (!empty($route_defaults)) {
    367             foreach($route_defaults as $query_var => $value) {
     370            foreach ($route_defaults as $query_var => $value) {
    368371                $query_var = 'mvc_'.$query_var;
    369372                if ($query_var != 'mvc_controller') {
     
    404407            $query_params = $wp_query->query;
    405408            $params = array();
    406             foreach($query_params as $key => $value) {
     409            foreach ($query_params as $key => $value) {
    407410                $key = preg_replace('/^(mvc_)/', '', $key);
    408411                $params[$key] = $value;
     
    429432        $routes = MvcRouter::get_admin_ajax_routes();
    430433        if (!empty($routes)) {
    431             foreach($routes as $route) {
     434            foreach ($routes as $route) {
    432435                $route['is_admin_ajax'] = true;
    433436                $method = 'admin_ajax_'.$route['wp_action'];
  • wp-mvc/trunk/core/mvc_plugin_loader.php

    r390534 r451789  
    3939        $plugins = $this->get_plugins();
    4040        if (in_array($plugin, $plugins)) {
    41             foreach($plugins as $key => $existing_plugin) {
     41            foreach ($plugins as $key => $existing_plugin) {
    4242                if ($plugin == $existing_plugin) {
    4343                    unset($plugins[$key]);
     
    5757   
    5858    protected function filter_nonexistent_plugins($plugins) {
    59         foreach($plugins as $key => $plugin) {
     59        foreach ($plugins as $key => $plugin) {
    6060            if (!is_dir(WP_PLUGIN_DIR.'/'.$plugin)) {
    6161                unset($plugins[$key]);
  • wp-mvc/trunk/core/mvc_router.php

    r390534 r451789  
    2222            }
    2323        }
    24         foreach($routes as $route) {
     24        foreach ($routes as $route) {
    2525            $route_path = $route[0];
    2626            $route_defaults = $route[1];
     
    3636            preg_match_all('/{:([\w]+).*?}/', $path_pattern, $matches, PREG_SET_ORDER);
    3737            $path = $path_pattern;
    38             foreach($matches as $match) {
     38            foreach ($matches as $match) {
    3939                $pattern = $match[0];
    4040                $option_key = $match[1];
  • wp-mvc/trunk/core/mvc_templater.php

    r371570 r451789  
    1414            $this->set_template_var($variable_name_or_array, $data);
    1515        } else if (is_array($variable_name_or_array)) {
    16             foreach($variable_name_or_array as $key => $value) {
     16            foreach ($variable_name_or_array as $key => $value) {
    1717                $this->set_template_var($key, $value);
    1818            }
  • wp-mvc/trunk/core/shells/generate_shell.php

    r437103 r451789  
    6262            'views/admin'
    6363        );
    64         foreach($app_directories as $path) {
     64        foreach ($app_directories as $path) {
    6565            $directory->create($plugin_app_path.$path.'/');
    6666        }
  • wp-mvc/trunk/core/shells/mvc_shell.php

    r390534 r451789  
    5252   
    5353    protected function load_models($model_names) {
    54         foreach($model_names as $model_name) {
     54        foreach ($model_names as $model_name) {
    5555            $this->load_model($model_name);
    5656        }
  • wp-mvc/trunk/core/templates/plugin/app/views/index.php

    r390534 r451789  
    22<?php
    33echo '
    4 <?php foreach($objects as $object): ?>
     4<?php foreach ($objects as $object): ?>
    55
    66    <?php $this->render_view(\'_item\', array(\'locals\' => array(\'object\' => $object))); ?>
  • wp-mvc/trunk/readme.txt

    r437103 r451789  
    24241. Upload `wp-mvc` to the `wp-content/plugins/` directory
    25251. Activate the plugin through the 'Plugins' menu in WordPress
     261. Make sure that [Pretty Permalinks](http://codex.wordpress.org/Introduction_to_Blogging#Pretty_Permalinks) are enabled and working
    26271. Either set up the example plugin to see how WP MVC works or start creating an application using the code generation utility `wpmvc`:
    2728
Note: See TracChangeset for help on using the changeset viewer.