Plugin Directory

Changeset 2050579


Ignore:
Timestamp:
03/14/2019 03:27:49 PM (7 years ago)
Author:
warriorrocker
Message:

Fix routes output for posts without rewrite base

Location:
xo-for-angular
Files:
4 edited
17 copied

Legend:

Unmodified
Added
Removed
  • xo-for-angular/tags/1.0.3/Includes/Services/Classes/RouteGenerator.class.php

    r2042983 r2050579  
    8686        global $wp_post_types;
    8787
     88        // Iterate through all available post types
    8889        foreach ($wp_post_types as $post_type => $post_type_config) {
     90            // Skip if the post type is not public or is a page
    8991            if ((!$post_type_config->public) || ($post_type == 'page'))
    9092                continue;
    9193
    92             if ((!$template = $this->Xo->Services->Options->GetOption('xo_' . $post_type . '_template', false))
    93                 || (!$attrs = $this->Xo->Services->TemplateReader->GetAnnotatedTemplate($template)))
    94                 continue;
     94            // Check if the post type has a rewrite base
     95            if (isset($post_type_config->rewrite['slug'])) {
     96                // Get the template of the rewrite base
     97                if ((!$template = $this->Xo->Services->Options->GetOption('xo_' . $post_type . '_template', false))
     98                    || (!$attrs = $this->Xo->Services->TemplateReader->GetAnnotatedTemplate($template)))
     99                    continue;
    95100
    96             $rewrite = ((isset($post_type_config->rewrite['slug'])) ? $post_type_config->rewrite['slug'] : $post_type);
    97             $routes[] = new XoApiAbstractRoute($rewrite, $attrs['loadChildren'], 'prefix');
     101                // Generate route for a posts hub page which will handle individual post urls
     102                $routes[] = new XoApiAbstractRoute($post_type_config->rewrite['slug'], $attrs['loadChildren'], 'prefix');
     103            } else {
     104                // Get all the published posts of a particular post type
     105                $posts = get_posts(array(
     106                    'post_status' => 'publish',
     107                    'post_type' => $post_type,
     108                    'posts_per_page' => -1,
     109                    'fields' => 'ids'
     110                ));
     111
     112                // Iterate through the found posts
     113                foreach ($posts as $postId) {
     114                    // Generate route for individual post pages which are routed individually
     115                    if ($attrs = $this->Xo->Services->TemplateReader->GetTemplateForPost($postId)) {
     116                        $path = ltrim(wp_make_link_relative(get_permalink($postId)), '/');
     117                        $routes[] = new XoApiAbstractRoute($path, $attrs['loadChildren'], 'full');
     118                    }
     119                }
     120            }
    98121        }
    99122    }
  • xo-for-angular/tags/1.0.3/readme.txt

    r2047166 r2050579  
    44Requires at least: 4.9
    55Tested up to: 5.1
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.3
    77Requires PHP: 7.0.0
    88License: GPLv2 or later
     
    3434== Changelog ==
    3535
     36= 1.0.3 =
     37* Fix routes output for posts without rewrite base.
     38
    3639= 1.0.2 =
    37 * Fix issue with SVG icon loading in admin options
     40* Fix issue with SVG icon loading in admin options.
    3841
    3942= 1.0.1 =
    40 * Added link target to menu item output
    41 * Fix for posts filter api returning results when there is no match
     43* Added link target to menu item output.
     44* Fix for posts filter api returning results when there is no match.
    4245
    4346= 1.0.0 =
  • xo-for-angular/tags/1.0.3/xo-angular.php

    r2047166 r2050579  
    44Plugin URI: https://angularxo.io
    55Description: Angular theme development in WordPress with templates and a powerful API.
    6 Version: 1.0.2
     6Version: 1.0.3
    77Author: Travis Brown
    88Author URI: http://www.xodustech.com
  • xo-for-angular/trunk/Includes/Services/Classes/RouteGenerator.class.php

    r2042983 r2050579  
    8686        global $wp_post_types;
    8787
     88        // Iterate through all available post types
    8889        foreach ($wp_post_types as $post_type => $post_type_config) {
     90            // Skip if the post type is not public or is a page
    8991            if ((!$post_type_config->public) || ($post_type == 'page'))
    9092                continue;
    9193
    92             if ((!$template = $this->Xo->Services->Options->GetOption('xo_' . $post_type . '_template', false))
    93                 || (!$attrs = $this->Xo->Services->TemplateReader->GetAnnotatedTemplate($template)))
    94                 continue;
     94            // Check if the post type has a rewrite base
     95            if (isset($post_type_config->rewrite['slug'])) {
     96                // Get the template of the rewrite base
     97                if ((!$template = $this->Xo->Services->Options->GetOption('xo_' . $post_type . '_template', false))
     98                    || (!$attrs = $this->Xo->Services->TemplateReader->GetAnnotatedTemplate($template)))
     99                    continue;
    95100
    96             $rewrite = ((isset($post_type_config->rewrite['slug'])) ? $post_type_config->rewrite['slug'] : $post_type);
    97             $routes[] = new XoApiAbstractRoute($rewrite, $attrs['loadChildren'], 'prefix');
     101                // Generate route for a posts hub page which will handle individual post urls
     102                $routes[] = new XoApiAbstractRoute($post_type_config->rewrite['slug'], $attrs['loadChildren'], 'prefix');
     103            } else {
     104                // Get all the published posts of a particular post type
     105                $posts = get_posts(array(
     106                    'post_status' => 'publish',
     107                    'post_type' => $post_type,
     108                    'posts_per_page' => -1,
     109                    'fields' => 'ids'
     110                ));
     111
     112                // Iterate through the found posts
     113                foreach ($posts as $postId) {
     114                    // Generate route for individual post pages which are routed individually
     115                    if ($attrs = $this->Xo->Services->TemplateReader->GetTemplateForPost($postId)) {
     116                        $path = ltrim(wp_make_link_relative(get_permalink($postId)), '/');
     117                        $routes[] = new XoApiAbstractRoute($path, $attrs['loadChildren'], 'full');
     118                    }
     119                }
     120            }
    98121        }
    99122    }
  • xo-for-angular/trunk/readme.txt

    r2047166 r2050579  
    44Requires at least: 4.9
    55Tested up to: 5.1
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.3
    77Requires PHP: 7.0.0
    88License: GPLv2 or later
     
    3434== Changelog ==
    3535
     36= 1.0.3 =
     37* Fix routes output for posts without rewrite base.
     38
    3639= 1.0.2 =
    37 * Fix issue with SVG icon loading in admin options
     40* Fix issue with SVG icon loading in admin options.
    3841
    3942= 1.0.1 =
    40 * Added link target to menu item output
    41 * Fix for posts filter api returning results when there is no match
     43* Added link target to menu item output.
     44* Fix for posts filter api returning results when there is no match.
    4245
    4346= 1.0.0 =
  • xo-for-angular/trunk/xo-angular.php

    r2047166 r2050579  
    44Plugin URI: https://angularxo.io
    55Description: Angular theme development in WordPress with templates and a powerful API.
    6 Version: 1.0.2
     6Version: 1.0.3
    77Author: Travis Brown
    88Author URI: http://www.xodustech.com
Note: See TracChangeset for help on using the changeset viewer.