Plugin Directory

Changeset 2056075


Ignore:
Timestamp:
03/23/2019 11:31:57 PM (7 years ago)
Author:
warriorrocker
Message:

Fix issue preventing new posts from saving and and add new sitemap api endpoint

Location:
xo-for-angular/trunk
Files:
7 added
4 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • xo-for-angular/trunk/Includes/Api/Abstract/Controller.class.php

    r2042983 r2056075  
    1111     * @var Xo
    1212     */
    13     public $Xo;
     13    protected $Xo;
    1414
    15     function __construct(Xo $Xo) {
     15    public function __construct(Xo $Xo) {
    1616        $this->Xo = $Xo;
    1717    }
  • xo-for-angular/trunk/Includes/Api/Abstract/Objects/Menu.class.php

    r2054976 r2056075  
    126126     * @param bool $fields Optionally include ACF fields in menu object.
    127127     */
    128     function __construct(WP_Post $menu, $terms = false, $meta = false, $fields = false) {
     128    public function __construct(WP_Post $menu, $terms = false, $meta = false, $fields = false) {
    129129        // Extend the fully formed post object
    130130        parent::__construct($menu, $terms, $meta, $fields);
  • xo-for-angular/trunk/Includes/Api/Abstract/Objects/Post.class.php

    r2054976 r2056075  
    145145     * @param bool $breadcrumbs Optionally include breadcrumb items in post object.
    146146     */
    147     function __construct(WP_Post $post, $terms = false, $meta = false, $fields = false, $breadcrumbs = false) {
     147    public function __construct(WP_Post $post, $terms = false, $meta = false, $fields = false, $breadcrumbs = false) {
    148148        // Map base post object properties
    149149        $this->id = intval($post->ID);
  • xo-for-angular/trunk/Includes/Api/Abstract/Objects/Route.class.php

    r2042983 r2056075  
    5454     * @param mixed $data Additional data added to the data property of the Angular Route item.
    5555     */
    56     function __construct($path, $loadChildren, $pathMatch = 'prefix', $data = false) {
     56    public function __construct($path, $loadChildren, $pathMatch = 'prefix', $data = false) {
    5757        // Map base route properties
    5858        $this->path = $path;
  • xo-for-angular/trunk/Includes/Api/Abstract/Objects/Term.class.php

    r2054167 r2056075  
    116116     * @param bool $fields Optionally include ACF fields in post object.
    117117     */
    118     function __construct(WP_Term $term, $meta = false, $fields = false) {
     118    public function __construct(WP_Term $term, $meta = false, $fields = false) {
    119119        // Map base term object properties
    120120        $this->id = $term->term_id;
  • xo-for-angular/trunk/Includes/Api/Abstract/Responses/IndexResponse.class.php

    r2042983 r2056075  
    2626     * @param mixed $controller Reflected controller info.
    2727     */
    28     function __construct($success, $message, $controller = false) {
     28    public function __construct($success, $message, $controller = false) {
    2929        // Extend base response
    3030        parent::__construct($success, $message);
  • xo-for-angular/trunk/Includes/Api/Abstract/Responses/PostsConfigResponse.class.php

    r2051907 r2056075  
    2626     * @param WP_Post_Type $config WordPress post type config object.
    2727     */
    28     function __construct($success, $message, $config = false) {
     28    public function __construct($success, $message, $config = false) {
    2929        // Extend base response
    3030        parent::__construct($success, $message);
  • xo-for-angular/trunk/Includes/Api/Abstract/Responses/PostsFilterResponse.class.php

    r2042983 r2056075  
    4646     * @param int $total The total amount of posts found by the given filters before pagination.
    4747     */
    48     function __construct($success, $message, $posts = false, $count = 0, $total = 0) {
     48    public function __construct($success, $message, $posts = false, $count = 0, $total = 0) {
    4949        // Extend base response
    5050        parent::__construct($success, $message);
  • xo-for-angular/trunk/Includes/Api/Abstract/Responses/PostsGetResponse.class.php

    r2042983 r2056075  
    2626     * @param XoApiAbstractPost $post The fully formed post object.
    2727     */
    28     function __construct($success, $message, XoApiAbstractPost $post = NULL) {
     28    public function __construct($success, $message, XoApiAbstractPost $post = NULL) {
    2929        // Extend base response
    3030        parent::__construct($success, $message);
  • xo-for-angular/trunk/Includes/Api/Abstract/Responses/TermsFilterResponse.class.php

    r2054167 r2056075  
    2626     * @param XoApiAbstractTerm[] $terms Collection of fully formed term objects.
    2727     */
    28     function __construct($success, $message, $terms = false) {
     28    public function __construct($success, $message, $terms = false) {
    2929        // Extend base response
    3030        parent::__construct($success, $message);
  • xo-for-angular/trunk/Includes/Api/Abstract/Responses/TermsGetResponse.class.php

    r2054167 r2056075  
    2626     * @param XoApiAbstractTerm $total Fully formed term object.
    2727     */
    28     function __construct($success, $message, XoApiAbstractTerm $term = NULL) {
     28    public function __construct($success, $message, XoApiAbstractTerm $term = NULL) {
    2929        // Extend base response
    3030        parent::__construct($success, $message);
  • xo-for-angular/trunk/Includes/Api/Api.class.php

    r2054167 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
     13    protected $Xo;
    1414
    1515    /**
    1616     * @var XoApiClassRouter
    1717     */
    18     var $Router;
     18    public $Router;
    1919
    20     function __construct($Xo) {
     20    public function __construct($Xo) {
    2121        $this->Xo = $Xo;
    2222
     
    2525    }
    2626
    27     function Init() {
     27    protected function Init() {
    2828        $this->Router = new XoApiClassRouter($this->Xo);
    2929
     
    3737    }
    3838
    39     function Includes() {
     39    protected function Includes() {
    4040        // Include abstract interface classes used for fully formed objects
    4141        $this->IncludeAbstractObjects();
     
    5151    }
    5252
    53     function IncludeAbstractObjects() {
     53    protected function IncludeAbstractObjects() {
    5454        $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Post.class.php');
    5555        $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Menu.class.php');
    5656        $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Term.class.php');
    5757        $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Route.class.php');
     58        $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/SitemapEntry.class.php');
    5859    }
    5960
    60     function IncludeAbstractResponses() {
     61    protected function IncludeAbstractResponses() {
    6162        $this->Xo->RequireOnce('Includes/Api/Abstract/Response.class.php');
    6263
    6364        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/IndexResponse.class.php');
    64         $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/ConfigResponse.class.php');
    65         $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/RoutesResponse.class.php');
     65
     66        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/ConfigGetResponse.class.php');
     67
     68        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/RoutesGetResponse.class.php');
     69        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/RoutesSitemapResponse.class.php');
     70
    6671        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/PostsGetResponse.class.php');
    6772        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/PostsFilterResponse.class.php');
    6873        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/PostsConfigResponse.class.php');
    69         $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/MenusResponse.class.php');
     74
     75        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/MenusGetResponse.class.php');
     76
    7077        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/TermsGetResponse.class.php');
    7178        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/TermsFilterResponse.class.php');
    72         $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/OptionsResponse.class.php');
     79
     80        $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/OptionsGetResponse.class.php');
    7381    }
    7482
    75     function IncludeApiBaseServices() {
     83    protected function IncludeApiBaseServices() {
    7684        $this->Xo->RequireOnce('Includes/Api/Classes/Router.class.php');
    7785        $this->Xo->RequireOnce('Includes/Api/Classes/Reflector.class.php');
    7886    }
    7987
    80     function IncludeApiControllers() {
     88    protected function IncludeApiControllers() {
    8189        $this->Xo->RequireOnce('Includes/Api/Abstract/Controller.class.php');
    8290        $this->Xo->RequireOnce('Includes/Api/Abstract/IndexController.class.php');
  • xo-for-angular/trunk/Includes/Api/Classes/Router.class.php

    r2042983 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
    14 
    15     var $classQueryVar = 'xo_api_class';
    16     var $methodQueryVar = 'xo_api_method';
    17 
    18     var $controllers = array();
    19 
    20     function __construct(Xo $Xo) {
     13    protected $Xo;
     14
     15    /**
     16     * WordPress rewrite class matching query var.
     17     *
     18     * @since 1.0.0
     19     *
     20     * @var string
     21     */
     22    protected $classQueryVar = 'xo_api_class';
     23
     24    /**
     25     * WordPress rewrite method matching query var.
     26     *
     27     * @since 1.0.0
     28     *
     29     * @var string
     30     */
     31    protected $methodQueryVar = 'xo_api_method';
     32
     33    /**
     34     * Collection of endpoints and controllers defined for the Xo API.
     35     *
     36     * @since 1.0.0
     37     *
     38     * @var string[]
     39     */
     40    public $controllers = array();
     41
     42    public function __construct(Xo $Xo) {
    2143        $this->Xo = $Xo;
    2244
     
    2547    }
    2648
    27     function Init() {
     49    public function Init() {
    2850        global $wp;
    2951
     
    3456    }
    3557
    36     function AddRewrites() {
     58    /**
     59     * Conditionally add rewrites used by the Xo API at the desired endpoint.
     60     *
     61     * @since 1.0.0
     62     *
     63     * @return void
     64     */
     65    protected function AddRewrites() {
    3766        if ((!$this->Xo->Services->Options->GetOption('xo_api_enabled', false))
    3867            || (!$apiEndpoint = $this->Xo->Services->Options->GetOption('xo_api_endpoint')))
     
    6190    }
    6291
    63     function AddController($endpoint, $class) {
     92    /**
     93     * Add a new controller at the desired endpoint to the Xo API.
     94     *
     95     * @since 1.0.0
     96     *
     97     * @param string $endpoint Endpoint slug used to encapsulate methods provided by the class.
     98     * @param string $class Name of the class to instantiate when called by the endpoint.
     99     * @return void
     100     */
     101    public function AddController($endpoint, $class) {
    64102        $class = apply_filters('xo/api/router/controllers/add', $class, $endpoint);
    65103        $this->controllers[$endpoint] = $class;
    66104    }
    67105
    68     function ApiQuery() {
     106    /**
     107     * Attempt to parse the incomming request as an Xo API endpoint.
     108     *
     109     * @since 1.0.0
     110     *
     111     * @return void
     112     */
     113    public function ApiQuery() {
    69114        global $wp;
    70115
     116        // Return to normal operation if the Xo API is disabled
    71117        if (!$this->Xo->Services->Options->GetOption('xo_api_enabled', false))
    72118            return;
    73119
     120        // Return to normal if the query does not match the class query var
    74121        if (empty($wp->query_vars[$this->classQueryVar]))
    75122            return;
    76123
     124        // Set the header as json output
    77125        header('Content-Type: application/json');
    78126
     127        // Determine the class configured for the current endpoint
    79128        $endpoint = $wp->query_vars[$this->classQueryVar];
     129
     130        // Filter the the request class
    80131        $class = apply_filters('xo/api/router/controllers/get', $this->controllers[$endpoint], $endpoint);
    81132
     133        // Return an error if the class was not defined
    82134        if (!$class)
    83135            return $this->ReturnError(__('No class defined for endpoint.', 'xo'));
    84136
     137        // Return an error if the class does not exist or was not included
    85138        if (!class_exists($class))
    86139            return $this->ReturnError(sprintf(__('Class %s was not found.', 'xo'), $class));
    87140
     141        // Determine the desired method within the endpoint
    88142        $method = ((!empty($wp->query_vars[$this->methodQueryVar])) ? ucfirst($wp->query_vars[$this->methodQueryVar]) : 'Index');
     143
     144        // Filter the request method
    89145        $method = apply_filters('xo/api/router/methods/get', $method, $class, $endpoint);
    90146
     147        // Return an error if the method was not determined
    91148        if (!$method)
    92149            return $this->ReturnError(__('No method determined for endpoint.', 'xo'));
    93150
     151        // Return an error if the requested method is not public
    94152        if (!is_callable(array($class, $method)))
    95153            return $this->ReturnError(sprintf(__('Method %s in class %s was not found or private.', 'xo'), $method, $class));
    96154
     155        // Exit and return no data if the request method is options, likely a CORS precursor
    97156        if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS')
    98157            exit;
    99158
     159        // Decode the body of the request, expected to be a json blob
    100160        $request = json_decode(file_get_contents("php://input"), true);
    101161
     162        // Extract the object vars from the request if its an object
    102163        if (is_object($request))
    103164            $request = get_object_vars($request);
    104165
     166        // If the body was empty use the PHP combined $_REQUEST object instead
    105167        $request = (((is_array($request)) && count($request)) ? $request : $_REQUEST);
     168
     169        // Filter the request object
    106170        $request = apply_filters('xo/api/router/request/get', $request, $method, $class, $endpoint);
    107171
     172        // Create a class reflection to check if method requires params
    108173        $reflect = new ReflectionMethod($class, $method);
    109         if (($params = $reflect->getParameters()) && (!$params[0]->isOptional()) && (!$request))
     174
     175        // Get the parameters of the method and check if they are optional
     176        if (($params = $reflect->getParameters()) && (!$params[0]->isOptional()) && (!$request)) {
     177            // Return an error if the parameters were expected by the method
    110178            $this->ReturnError(sprintf(__('Method %s in class %s expects %u parameters.', 'xo'), $method, $class, count($params)));
    111 
     179        }
     180
     181        // Call the requested method in a new instance of the requested class using the request object
    112182        $response = call_user_func(array(new $class($this->Xo), $method), $request);
    113183
     184        // Filter the response
    114185        $response = apply_filters('xo/api/router/response', $response, $request, $method, $class, $endpoint);
    115186
     187        // Return the generated response object
    116188        $this->ReturnResponse($response);
    117189    }
    118190
    119     function ReturnResponse($response) {
     191    /**
     192     * Output a json encoded response and exit.
     193     *
     194     * @since 1.0.0
     195     *
     196     * @param mixed $response Response to output.
     197     */
     198    protected function ReturnResponse($response) {
    120199        echo json_encode($response);
    121200        die();
    122201    }
    123202
    124     function ReturnError($message) {
     203    /**
     204     * Return a general API error.
     205     *
     206     * @since 1.0.0
     207     *
     208     * @param string $message Human readable reason for the error.
     209     */
     210    protected function ReturnError($message) {
    125211        header('HTTP/1.0 404 Not Found');
    126212        $this->ReturnResponse(new XoApiAbstractResponse(false, $message));
  • xo-for-angular/trunk/Includes/Api/Controllers/ConfigController.class.php

    r2042983 r2056075  
    1515     * @return XoApiAbstractConfigGetResponse
    1616     */
    17     function Get() {
     17    public function Get() {
    1818        $theme = wp_get_theme();
    1919
  • xo-for-angular/trunk/Includes/Api/Controllers/MenusController.class.php

    r2054976 r2056075  
    1616     * @return XoApiAbstractMenusGetResponse
    1717     */
    18     function Get($params) {
     18    public function Get($params) {
    1919        // Return an error if menu location name is missing
    2020        if (empty($params['menu']))
  • xo-for-angular/trunk/Includes/Api/Controllers/OptionsController.class.php

    r2042983 r2056075  
    1616     * @return XoApiAbstractOptionsGetResponse
    1717     */
    18     function Get($params) {
     18    public function Get($params) {
    1919        // Return an error if ACF is not present or activated
    2020        if ((!function_exists('acf_get_fields')) ||
  • xo-for-angular/trunk/Includes/Api/Controllers/PostsController.class.php

    r2051900 r2056075  
    6868     * @return XoApiAbstractPostsGetResponse
    6969     */
    70     function GetDraftOrPreview($params) {
     70    public function GetDraftOrPreview($params) {
    7171        // Return an error if the user is not logged in or not an editor
    7272        if (!current_user_can('edit_others_pages'))
  • xo-for-angular/trunk/Includes/Api/Controllers/RoutesController.class.php

    r2042983 r2056075  
    22
    33/**
    4  * Provide endpoints for retrieving dynamic routes.
     4 * Provide endpoints for retrieving dynamic routes and sitemap.
    55 *
    66 * @since 1.0.0
     
    1515     * @return XoApiAbstractRoutesGetResponse
    1616     */
    17     function Get() {
     17    public function Get() {
    1818        // Check if the currently logged in user can edit pages and previews are enabled
    1919        $previewsEnabled = ((current_user_can('edit_others_pages')) &&
     
    2727            return new XoApiAbstractRoutesGetResponse(false, __('Unable to retrieve routes.', 'xo'));
    2828
    29         // Return success
     29        // Return success and generated routes
    3030        return new XoApiAbstractRoutesGetResponse(
    3131            true, __('Successfully retrieved routes.', 'xo'),
     
    3333        );
    3434    }
     35
     36    /**
     37     * Get sitemap entries for posts and terms.
     38     *
     39     * @since 1.0.9
     40     *
     41     * @return XoApiAbstractRoutesSitemapResponse
     42     */
     43    public function Sitemap() {
     44        // Get a combined list of all post and term sitemap entries
     45        $sitemapEntries = array_merge(
     46            $this->Xo->Services->SitemapGenerator->GenerateSitemapForPosts(),
     47            $this->Xo->Services->SitemapGenerator->GenerateSitemapForTaxonomies()
     48        );
     49
     50        // Convert the flat sitemap entries to a nested collection
     51        $sitemapEntries = $this->Xo->Services->SitemapGenerator->FlatSitemapToTree($sitemapEntries);
     52
     53        // Return success and generated sitemap entries
     54        return new XoApiAbstractRoutesSitemapResponse(
     55            true, __('Successfully retrieved sitemap entries.', 'xo'),
     56            $sitemapEntries
     57        );
     58    }
    3559}
  • xo-for-angular/trunk/Includes/Api/Controllers/TermsController.class.php

    r2054167 r2056075  
    5050     * @return XoApiAbstractTermsFilterResponse
    5151     */
    52     function Filter($params) {
     52    public function Filter($params) {
    5353        // Return an error if the taxonomy is missing
    5454        if (empty($params['taxonomy']))
     
    9797     */
    9898    private function GetTaxonomyByUrl($url) {
    99         $taxonomies = get_taxonomies(array(), 'objects');
     99        $taxonomies = get_taxonomies(array(
     100            'public' => 1
     101        ), 'objects');
    100102
    101103        foreach ($taxonomies as $taxonomy_config) {
  • xo-for-angular/trunk/Includes/Filters/External/PostTemplates.class.php

    r2042983 r2056075  
    1616        $this->Xo = $Xo;
    1717
    18         add_filter('template_include', array($this, 'TemplateInclude'), 1, 1);
    19         add_action('admin_init', array($this, 'RegisterTemplateFilters'), 10, 0);
     18        $this->Init();
    2019    }
    2120
    22     function RegisterTemplateFilters() {
     21    function Init() {
     22        add_filter('template_include', array($this, 'TemplateInclude'), 1, 1);
    2323        add_filter('default_page_template_title', array($this, 'DefaultPageTemplateTitle'), 10, 2);
    2424        add_filter('theme_page_templates', array($this, 'ThemeTemplates'), 10, 4);
     
    3434
    3535    function ThemeTemplates($templates, WP_Theme $theme, $post, $post_type) {
     36        echo 'theme templates';
    3637        $annotatedTemplates = $this->Xo->Services->TemplateReader->GetAnnotatedTemplates();
    3738
  • xo-for-angular/trunk/Includes/Options/Options.class.php

    r2051900 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
     13    protected $Xo;
    1414
    1515    /**
    1616     * @var XoOptionsMenuPage
    1717     */
    18     var $MainSettingsPage;
     18    public $MainSettingsPage;
    1919
    2020    /**
    2121     * @var XoOptionsSubMenuPage
    2222     */
    23     var $GeneralSettingsPage;
     23    public $GeneralSettingsPage;
    2424
    2525    /**
    2626     * @var XoOptionsSubMenuPage
    2727     */
    28     var $ToolsPage;
     28    public $ToolsPage;
    2929
    30     function __construct($Xo) {
     30    public function __construct($Xo) {
    3131        $this->Xo = $Xo;
    3232
     
    3535    }
    3636
    37     function Init() {
     37    protected function Init() {
    3838        $this->InitGeneralSettingsPage();
    3939
     
    4747    }
    4848
    49     function AddAdminStyles() {
     49    public function AddAdminStyles() {
    5050        $adminCssFile = $this->Xo->GetFile('assets/css/admin.css', true);
    5151
     
    5454    }
    5555
    56     function InitMainSettingsPage() {
     56    protected function InitMainSettingsPage() {
    5757        $this->MainSettingsPage = new XoOptionsMenuPage(
    5858            $this->Xo,
     
    6767    }
    6868
    69     function InitMainSettingsPageTabs() {
     69    protected function InitMainSettingsPageTabs() {
    7070        $this->MainSettingsPage->AddTab('index', __('Index', 'xo'), 'XoOptionsTabIndex');
    7171        $this->MainSettingsPage->AddTab('api', __('API', 'xo'), 'XoOptionsTabApi');
     
    7878    }
    7979
    80     function InitGeneralSettingsPage() {
     80    protected function InitGeneralSettingsPage() {
    8181        $this->GeneralSettingsPage = new XoOptionsSubMenuPage(
    8282            $this->Xo,
     
    9090    }
    9191
    92     function InitToolsPage() {
     92    protected function InitToolsPage() {
    9393        $this->ToolsPage = new XoOptionsSubMenuPage(
    9494            $this->Xo,
     
    102102    }
    103103
    104     function InitToolsPageTabs() {
     104    protected function InitToolsPageTabs() {
    105105        $this->ToolsPage->AddTab('tools', __('Tools', 'xo'), 'XoOptionsTabTools');
    106106        $this->ToolsPage->AddTab('profile', __('Profile', 'xo'), 'XoOptionsTabProfile');
     
    108108    }
    109109
    110     function Includes() {
     110    protected function Includes() {
    111111        // Include abstract classes for admin pages and tabs
    112112        $this->IncludeAbstractClasses();
     
    119119    }
    120120
    121     function IncludeAbstractClasses() {
     121    protected function IncludeAbstractClasses() {
    122122        $this->Xo->RequireOnce('Includes/Options/Abstract/Tab.class.php');
    123123        $this->Xo->RequireOnce('Includes/Options/Abstract/FieldsTab.class.php');
     
    129129    }
    130130
    131     function IncludeGeneralTabs() {
     131    protected function IncludeGeneralTabs() {
    132132        $this->Xo->RequireOnce('Includes/Options/Tabs/General/IndexTab.class.php');
    133133        $this->Xo->RequireOnce('Includes/Options/Tabs/General/ApiTab.class.php');
     
    138138    }
    139139
    140     function IncludeToolsTabs() {
     140    protected function IncludeToolsTabs() {
    141141        $this->Xo->RequireOnce('Includes/Options/Tabs/Tools/ToolsTab.class.php');
    142142        $this->Xo->RequireOnce('Includes/Options/Tabs/Tools/ProfileTab.class.php');
  • xo-for-angular/trunk/Includes/Services/Classes/AdminNotice.class.php

    r2043391 r2056075  
    1515     * @var string
    1616     */
    17     var $key;
     17    protected $key;
    1818
    1919    /**
     
    2424     * @var callable
    2525     */
    26     var $renderFn;
     26    public $renderFn;
    2727
    2828    /**
     
    3434     * @param callable $renderFn Callback for generating the body of the notice.
    3535     */
    36     function __construct($key, callable $renderFn) {
     36    public function __construct($key, callable $renderFn) {
    3737        $this->key = $key;
    3838        $this->renderFn = $renderFn;
     
    4848     * @param array $settings Additional data passed to the notice such as the expiration.
    4949     */
    50     function RegisterNotice($settings = array()) {
     50    public function RegisterNotice($settings = array()) {
    5151        if (!isset($settings['dismissable']))
    5252            $settings['dismissable'] = true;
     
    6565     * @return void
    6666     */
    67     function ShowNotice() {
     67    public function ShowNotice() {
    6868        if (!$settings = get_transient($this->key))
    6969            return;
     
    8686     * @return void
    8787     */
    88     function DismissNotice() {
     88    public function DismissNotice() {
    8989        delete_transient($this->key);
    9090    }
  • xo-for-angular/trunk/Includes/Services/Classes/IndexBuilder.class.php

    r2042983 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
     13    protected $Xo;
    1414
    1515    /**
     
    2020     * @var string
    2121     */
    22     var $appConfigScriptId = 'xo-config';
    23 
    24     function __construct(Xo $Xo) {
     22    protected $appConfigScriptId = 'xo-config';
     23
     24    public function __construct(Xo $Xo) {
    2525        $this->Xo = $Xo;
    2626    }
     
    3333     * @return boolean|string Rendered index output.
    3434     */
    35     function RenderDistIndex() {
     35    public function RenderDistIndex() {
    3636        if (!$srcIndex = $this->Xo->Services->Options->GetOption('xo_index_dist', false))
    3737            return false;
     
    7171     * @return boolean Whether wp_head was successfully added to the output stream.
    7272     */
    73     private function AddWpHead(&$output) {
     73    protected function AddWpHead(&$output) {
    7474        $headPos = strpos($output, '</head>');
    7575        if ($headPos === false)
     
    9797     * @return boolean Whether wp_footer was successfully added to the output stream.
    9898     */
    99     private function AddWpFooter(&$output) {
     99    protected function AddWpFooter(&$output) {
    100100        $bodyPos = strpos($output, '</body>');
    101101        if ($bodyPos === false)
     
    123123     * @return boolean Whether App Config was successfully added to the output stream.
    124124     */
    125     private function AddAppConfig(&$output) {
     125    protected function AddAppConfig(&$output) {
    126126        $XoApiConfigController = new XoApiControllerConfig($this->Xo);
    127127        $config = $XoApiConfigController->Get();
     
    159159     * @return boolean Whether the entrypoint was successfully found or added in the src index.
    160160     */
    161     function AddAppConfigEntrypoint() {
     161    public function AddAppConfigEntrypoint() {
    162162        if (!$srcIndex = $this->Xo->Services->Options->GetOption('xo_index_src', false))
    163163            return false;
     
    205205     * @return boolean Whether the App Config entrypoint is found in the src index.
    206206     */
    207     function CheckAppConfigEntrypoint() {
     207    public function CheckAppConfigEntrypoint() {
    208208        if (!$srcIndex = $this->Xo->Services->Options->GetOption('xo_index_src', false))
    209209            return false;
     
    239239     * @return void
    240240     */
    241     private function InsertBetween(&$stream, $content, $start, $end = false) {
     241    protected function InsertBetween(&$stream, $content, $start, $end = false) {
    242242        if (!$end)
    243243            $end = $start;
     
    248248    /**
    249249     * Write the index file with the given content.
    250      * 
    251      * @since 1.0.0
    252      * 
     250     *
     251     * @since 1.0.0
     252     *
    253253     * @param string $file Absolute path to the file to write.
    254254     * @param string $content Content to write into the file.
    255255     * @return boolean Whether the content was successfully written.
    256256     */
    257     private function WriteIndex($file, $content) {
     257    protected function WriteIndex($file, $content) {
    258258        if (!$handle = fopen($file, 'r+'))
    259259            return false;
  • xo-for-angular/trunk/Includes/Services/Classes/Options.class.php

    r2042983 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
     13    protected $Xo;
    1414
    1515    /**
     
    2020     * @var array
    2121     */
    22     var $overrides = array();
    23 
    24     function __construct(Xo $Xo) {
     22    protected $overrides = array();
     23
     24    public function __construct(Xo $Xo) {
    2525        $this->Xo = $Xo;
    2626        add_action('init', array($this, 'Init'), 10, 0);
    2727    }
    2828
    29     function Init() {
     29    public function Init() {
    3030        $this->SetOverrides();
    3131    }
     
    3838     * @return void
    3939     */
    40     function SetOverrides() {
     40    public function SetOverrides() {
    4141        if (!defined('XO_SETTINGS'))
    4242            return;
     
    5858     * @return mixed Return value of the option.
    5959     */
    60     function GetOption($name, $value = false) {
     60    public function GetOption($name, $value = false) {
    6161        if (isset($this->overrides[$name])) {
    6262            $value = $this->overrides[$name];
     
    7979     * @return bool Whether the option was updated.
    8080     */
    81     function SetOption($name, $value = false) {
     81    public function SetOption($name, $value = false) {
    8282        $value = apply_filters('xo/options/set/' . $name, $value);
    8383
     
    9292     * @return array
    9393     */
    94     function GetDefaultSettings() {
     94    protected function GetDefaultSettings() {
    9595        $defaults = array(
    9696            // Index Tab
     
    131131     * @return array All current settings.
    132132     */
    133     function GetCurrentSettings() {
     133    public function GetCurrentSettings() {
    134134        $settings = array();
    135135        $defaults = $this->GetDefaults();
     
    150150     * @return mixed The defaults filtered by xo/options/defaults.
    151151     */
    152     function GetDefaults() {
     152    public function GetDefaults() {
    153153        $defaults = $this->GetDefaultSettings();
    154154
     
    168168     * @return bool Whether any options were set.
    169169     */
    170     function SetDefaults() {
     170    public function SetDefaults() {
    171171        $defaults = $this->GetDefaults();
    172172
     
    186186     * @return bool Whether any options were set.
    187187     */
    188     function ResetDefaults() {
     188    public function ResetDefaults() {
    189189        $defaults = $this->GetDefaults();
    190190
     
    205205     * @return array States of the given option.
    206206     */
    207     function GetStates($option) {
     207    public function GetStates($option) {
    208208        $states = array();
    209209
     
    223223     * @return bool|string[]
    224224     */
    225     function GetOptionsFromJson() {
     225    protected function GetOptionsFromJson() {
    226226        if (!$jsons = $this->Xo->Services->AngularJson->ParseConfig())
    227227            return false;
  • xo-for-angular/trunk/Includes/Services/Classes/RouteGenerator.class.php

    r2054167 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
     13    protected $Xo;
    1414
    15     function __construct(Xo $Xo) {
     15    public function __construct(Xo $Xo) {
    1616        $this->Xo = $Xo;
    1717    }
     
    5454    }
    5555
    56     private function AddRoutesForPages(&$routes) {
     56    protected function AddRoutesForPages(&$routes) {
    5757        $page404Id = intval($this->Xo->Services->Options->GetOption('xo_404_page_id', 0));
    5858
     
    7373    }
    7474
    75     private function AddRouteFor404Page(&$routes) {
     75    protected function AddRouteFor404Page(&$routes) {
    7676        if (($page404Id = intval($this->Xo->Services->Options->GetOption('xo_404_page_id', 0))) &&
    7777            ($attrs = $this->Xo->Services->TemplateReader->GetTemplateForPost($page404Id))) {
     
    8383    }
    8484
    85     private function AddRoutesForPosts(&$routes) {
     85    protected function AddRoutesForPosts(&$routes) {
    8686        global $wp_post_types;
    8787
     
    128128    }
    129129
    130     private function AddRoutesForPageDrafts(&$routes) {
     130    protected function AddRoutesForPageDrafts(&$routes) {
    131131        $posts = get_posts(array(
    132132            'post_status' => 'draft',
     
    145145    }
    146146
    147     private function AddRoutesForPagePreviews(&$routes) {
     147    protected function AddRoutesForPagePreviews(&$routes) {
    148148        $posts = get_posts(array(
    149149            'post_status' => 'publish',
     
    163163    }
    164164
    165     private function AddRoutesForPostDraftsAndPreviews(&$routes) {
     165    protected function AddRoutesForPostDraftsAndPreviews(&$routes) {
    166166        global $wp_post_types;
    167167
  • xo-for-angular/trunk/Includes/Services/Classes/TemplateReader.class.php

    r2042983 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
     13    protected $Xo;
    1414
    1515    /**
    1616     * @var XoServiceAdminNotice
    1717     */
    18     var $UpdateTemplatesNotice;
     18    protected $UpdateTemplatesNotice;
    1919
    2020    /**
     
    2525     * @var string
    2626     */
    27     var $templateDir;
     27    protected $templateDir;
    2828
    2929    /**
     
    3434     * @var string
    3535     */
    36     var $templatesPath;
     36    protected $templatesPath;
    3737
    3838    /**
     
    4343     * @var array
    4444     */
    45     var $templatesExtensions = array('ts');
     45    protected $templatesExtensions = array('ts');
    4646
    4747    /**
     
    5252     * @var string
    5353     */
    54     var $commentBlockRegex = '/\/\*\*\s*?\n(.*?)\n\s*?\*\//is';
     54    protected $commentBlockRegex = '/\/\*\*\s*?\n(.*?)\n\s*?\*\//is';
    5555
    5656    /**
     
    6161     * @var string
    6262     */
    63     var $annotationsRegex = '/(?: *\*+ *@Xo)(?P<key>\w+)(?: )(?P<value>[ \w!,]+)/';
     63    protected $annotationsRegex = '/(?: *\*+ *@Xo)(?P<key>\w+)(?: )(?P<value>[ \w!,]+)/';
    6464
    6565    /**
     
    7070     * @var array
    7171     */
    72     var $annotationsFormats = array(
     72    protected $annotationsFormats = array(
    7373        'disableEditor' => 'boolean',
    7474        'defaultTemplate' => 'boolean',
     
    8484     * @var array
    8585     */
    86     var $annotatedTemplates = array();
    87 
    88     function __construct(Xo $Xo) {
     86    protected $annotatedTemplates = array();
     87
     88    public function __construct(Xo $Xo) {
    8989        $this->Xo = $Xo;
    9090
     
    104104     * @return void
    105105     */
    106     function Init() {
     106    public function Init() {
    107107        $this->templateDir = get_template_directory();
    108108        $this->templatesPath = $this->Xo->Services->Options->GetOption('xo_templates_path', '');
     
    117117     * @return array|boolean Annotated template data.
    118118     */
    119     function GetTemplateForPost($post) {
     119    public function GetTemplateForPost($post) {
    120120        $this->GetAnnotatedTemplates();
    121121
     
    148148     * @return array All templates and annotations.
    149149     */
    150     function GetAnnotatedTemplates() {
     150    public function GetAnnotatedTemplates() {
    151151        if (!$this->Xo->Services->Options->GetOption('xo_templates_reader_enabled', false))
    152152            return array();
     
    169169     * @return array|boolean Annotations for the given template.
    170170     */
    171     function GetAnnotatedTemplate($template) {
     171    public function GetAnnotatedTemplate($template) {
    172172        $this->GetAnnotatedTemplates();
    173173
     
    192192     * @return array All templates and annotations.
    193193     */
    194     function GetTemplates($caching = true, $useCache = true) {
     194    public function GetTemplates($caching = true, $useCache = true) {
    195195        $templatesCache = $this->Xo->Services->Options->GetOption('xo_templates_cache', array());
    196196
     
    231231     * @return array All possible template files.
    232232     */
    233     private function GetTemplateFiles() {
     233    protected function GetTemplateFiles() {
    234234        $length = strlen($this->templateDir) + 1;
    235235        $files = array();
     
    265265     * @return array|boolean Annotations.
    266266     */
    267     private function ParseTemplateCommentBlocks($template) {
     267    protected function ParseTemplateCommentBlocks($template) {
    268268        $fileName = $this->templateDir . '/' . $template;
    269269
     
    291291     * @return array|boolean Formatted annotations.
    292292     */
    293     private function ParseTemplateCommentBlockAnnotations($template, $block) {
     293    protected function ParseTemplateCommentBlockAnnotations($template, $block) {
    294294        if (preg_match_all($this->annotationsRegex, $block, $matchAttrs, PREG_SET_ORDER)) {
    295295            $attrs = array();
     
    320320    }
    321321
    322     function RenderUpdateTemplatesNotice() {
     322    public function RenderUpdateTemplatesNotice() {
    323323        $output = '<p><strong>' . sprintf(
    324324            __('%s templates cache updated.', 'xo'),
  • xo-for-angular/trunk/Includes/Services/Services.class.php

    r2042983 r2056075  
    1111     * @var Xo
    1212     */
    13     var $Xo;
     13    protected $Xo;
    1414
    1515    /**
     
    3131     * @var XoServiceIndexBuilder
    3232     */
    33     var $IndexBuilder;
     33    public $IndexBuilder;
    3434
    3535    /**
    3636     * @var XoServiceRouteGenerator
    3737     */
    38     var $RouteGenerator;
     38    public $RouteGenerator;
    3939
    40     function __construct($Xo) {
     40    /**
     41     * @var XoServiceSitemapGenerator
     42     */
     43    public $SitemapGenerator;
     44
     45    public function __construct($Xo) {
    4146        $this->Xo = $Xo;
    4247
     
    4550    }
    4651
    47     function Init() {
     52    protected function Init() {
    4853        $this->Options = new XoServiceOptions($this->Xo);
    4954        $this->AngularJson = new XoServiceAngularJson();
     
    5156        $this->IndexBuilder = new XoServiceIndexBuilder($this->Xo);
    5257        $this->RouteGenerator = new XoServiceRouteGenerator($this->Xo);
     58        $this->SitemapGenerator = new XoServiceSitemapGenerator($this->Xo);
    5359    }
    5460
    55     function Includes() {
     61    protected function Includes() {
    5662        $this->Xo->RequireOnce('Includes/Services/Classes/Options.class.php');
    5763        $this->Xo->RequireOnce('Includes/Services/Classes/AngularJson.class.php');
     
    5965        $this->Xo->RequireOnce('Includes/Services/Classes/IndexBuilder.class.php');
    6066        $this->Xo->RequireOnce('Includes/Services/Classes/RouteGenerator.class.php');
     67        $this->Xo->RequireOnce('Includes/Services/Classes/SitemapGenerator.class.php');
    6168        $this->Xo->RequireOnce('Includes/Services/Classes/AdminNotice.class.php');
    6269    }
  • xo-for-angular/trunk/xo-angular.php

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