Changeset 2056075
- Timestamp:
- 03/23/2019 11:31:57 PM (7 years ago)
- Location:
- xo-for-angular/trunk
- Files:
-
- 7 added
- 4 deleted
- 28 edited
-
Includes/Api/Abstract/Controller.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Objects/Menu.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Objects/Post.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Objects/Route.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Objects/SitemapEntry.class.php (added)
-
Includes/Api/Abstract/Objects/Term.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Responses/ConfigGetResponse.class.php (added)
-
Includes/Api/Abstract/Responses/ConfigResponse.class.php (deleted)
-
Includes/Api/Abstract/Responses/IndexResponse.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Responses/MenusGetResponse.class.php (added)
-
Includes/Api/Abstract/Responses/MenusResponse.class.php (deleted)
-
Includes/Api/Abstract/Responses/OptionsGetResponse.class.php (added)
-
Includes/Api/Abstract/Responses/OptionsResponse.class.php (deleted)
-
Includes/Api/Abstract/Responses/PostsConfigResponse.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Responses/PostsFilterResponse.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Responses/PostsGetResponse.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Responses/RoutesGetResponse.class.php (added)
-
Includes/Api/Abstract/Responses/RoutesResponse.class.php (deleted)
-
Includes/Api/Abstract/Responses/RoutesSitemapResponse.class.php (added)
-
Includes/Api/Abstract/Responses/TermsFilterResponse.class.php (modified) (1 diff)
-
Includes/Api/Abstract/Responses/TermsGetResponse.class.php (modified) (1 diff)
-
Includes/Api/Api.class.php (modified) (4 diffs)
-
Includes/Api/Classes/Router.class.php (modified) (4 diffs)
-
Includes/Api/Controllers/ConfigController.class.php (modified) (1 diff)
-
Includes/Api/Controllers/MenusController.class.php (modified) (1 diff)
-
Includes/Api/Controllers/OptionsController.class.php (modified) (1 diff)
-
Includes/Api/Controllers/PostsController.class.php (modified) (1 diff)
-
Includes/Api/Controllers/RoutesController.class.php (modified) (4 diffs)
-
Includes/Api/Controllers/TermsController.class.php (modified) (2 diffs)
-
Includes/Filters/External/PostTemplates.class.php (modified) (2 diffs)
-
Includes/Options/Options.class.php (modified) (12 diffs)
-
Includes/Services/Classes/AdminNotice.class.php (modified) (6 diffs)
-
Includes/Services/Classes/IndexBuilder.class.php (modified) (10 diffs)
-
Includes/Services/Classes/Options.class.php (modified) (12 diffs)
-
Includes/Services/Classes/RouteGenerator.class.php (modified) (7 diffs)
-
Includes/Services/Classes/SitemapGenerator.class.php (added)
-
Includes/Services/Classes/TemplateReader.class.php (modified) (17 diffs)
-
Includes/Services/Services.class.php (modified) (5 diffs)
-
xo-angular.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
xo-for-angular/trunk/Includes/Api/Abstract/Controller.class.php
r2042983 r2056075 11 11 * @var Xo 12 12 */ 13 p ublic$Xo;13 protected $Xo; 14 14 15 function __construct(Xo $Xo) {15 public function __construct(Xo $Xo) { 16 16 $this->Xo = $Xo; 17 17 } -
xo-for-angular/trunk/Includes/Api/Abstract/Objects/Menu.class.php
r2054976 r2056075 126 126 * @param bool $fields Optionally include ACF fields in menu object. 127 127 */ 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) { 129 129 // Extend the fully formed post object 130 130 parent::__construct($menu, $terms, $meta, $fields); -
xo-for-angular/trunk/Includes/Api/Abstract/Objects/Post.class.php
r2054976 r2056075 145 145 * @param bool $breadcrumbs Optionally include breadcrumb items in post object. 146 146 */ 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) { 148 148 // Map base post object properties 149 149 $this->id = intval($post->ID); -
xo-for-angular/trunk/Includes/Api/Abstract/Objects/Route.class.php
r2042983 r2056075 54 54 * @param mixed $data Additional data added to the data property of the Angular Route item. 55 55 */ 56 function __construct($path, $loadChildren, $pathMatch = 'prefix', $data = false) {56 public function __construct($path, $loadChildren, $pathMatch = 'prefix', $data = false) { 57 57 // Map base route properties 58 58 $this->path = $path; -
xo-for-angular/trunk/Includes/Api/Abstract/Objects/Term.class.php
r2054167 r2056075 116 116 * @param bool $fields Optionally include ACF fields in post object. 117 117 */ 118 function __construct(WP_Term $term, $meta = false, $fields = false) {118 public function __construct(WP_Term $term, $meta = false, $fields = false) { 119 119 // Map base term object properties 120 120 $this->id = $term->term_id; -
xo-for-angular/trunk/Includes/Api/Abstract/Responses/IndexResponse.class.php
r2042983 r2056075 26 26 * @param mixed $controller Reflected controller info. 27 27 */ 28 function __construct($success, $message, $controller = false) {28 public function __construct($success, $message, $controller = false) { 29 29 // Extend base response 30 30 parent::__construct($success, $message); -
xo-for-angular/trunk/Includes/Api/Abstract/Responses/PostsConfigResponse.class.php
r2051907 r2056075 26 26 * @param WP_Post_Type $config WordPress post type config object. 27 27 */ 28 function __construct($success, $message, $config = false) {28 public function __construct($success, $message, $config = false) { 29 29 // Extend base response 30 30 parent::__construct($success, $message); -
xo-for-angular/trunk/Includes/Api/Abstract/Responses/PostsFilterResponse.class.php
r2042983 r2056075 46 46 * @param int $total The total amount of posts found by the given filters before pagination. 47 47 */ 48 function __construct($success, $message, $posts = false, $count = 0, $total = 0) {48 public function __construct($success, $message, $posts = false, $count = 0, $total = 0) { 49 49 // Extend base response 50 50 parent::__construct($success, $message); -
xo-for-angular/trunk/Includes/Api/Abstract/Responses/PostsGetResponse.class.php
r2042983 r2056075 26 26 * @param XoApiAbstractPost $post The fully formed post object. 27 27 */ 28 function __construct($success, $message, XoApiAbstractPost $post = NULL) {28 public function __construct($success, $message, XoApiAbstractPost $post = NULL) { 29 29 // Extend base response 30 30 parent::__construct($success, $message); -
xo-for-angular/trunk/Includes/Api/Abstract/Responses/TermsFilterResponse.class.php
r2054167 r2056075 26 26 * @param XoApiAbstractTerm[] $terms Collection of fully formed term objects. 27 27 */ 28 function __construct($success, $message, $terms = false) {28 public function __construct($success, $message, $terms = false) { 29 29 // Extend base response 30 30 parent::__construct($success, $message); -
xo-for-angular/trunk/Includes/Api/Abstract/Responses/TermsGetResponse.class.php
r2054167 r2056075 26 26 * @param XoApiAbstractTerm $total Fully formed term object. 27 27 */ 28 function __construct($success, $message, XoApiAbstractTerm $term = NULL) {28 public function __construct($success, $message, XoApiAbstractTerm $term = NULL) { 29 29 // Extend base response 30 30 parent::__construct($success, $message); -
xo-for-angular/trunk/Includes/Api/Api.class.php
r2054167 r2056075 11 11 * @var Xo 12 12 */ 13 var$Xo;13 protected $Xo; 14 14 15 15 /** 16 16 * @var XoApiClassRouter 17 17 */ 18 var$Router;18 public $Router; 19 19 20 function __construct($Xo) {20 public function __construct($Xo) { 21 21 $this->Xo = $Xo; 22 22 … … 25 25 } 26 26 27 function Init() {27 protected function Init() { 28 28 $this->Router = new XoApiClassRouter($this->Xo); 29 29 … … 37 37 } 38 38 39 function Includes() {39 protected function Includes() { 40 40 // Include abstract interface classes used for fully formed objects 41 41 $this->IncludeAbstractObjects(); … … 51 51 } 52 52 53 function IncludeAbstractObjects() {53 protected function IncludeAbstractObjects() { 54 54 $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Post.class.php'); 55 55 $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Menu.class.php'); 56 56 $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Term.class.php'); 57 57 $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/Route.class.php'); 58 $this->Xo->RequireOnce('Includes/Api/Abstract/Objects/SitemapEntry.class.php'); 58 59 } 59 60 60 function IncludeAbstractResponses() {61 protected function IncludeAbstractResponses() { 61 62 $this->Xo->RequireOnce('Includes/Api/Abstract/Response.class.php'); 62 63 63 64 $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 66 71 $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/PostsGetResponse.class.php'); 67 72 $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/PostsFilterResponse.class.php'); 68 73 $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 70 77 $this->Xo->RequireOnce('Includes/Api/Abstract/Responses/TermsGetResponse.class.php'); 71 78 $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'); 73 81 } 74 82 75 function IncludeApiBaseServices() {83 protected function IncludeApiBaseServices() { 76 84 $this->Xo->RequireOnce('Includes/Api/Classes/Router.class.php'); 77 85 $this->Xo->RequireOnce('Includes/Api/Classes/Reflector.class.php'); 78 86 } 79 87 80 function IncludeApiControllers() {88 protected function IncludeApiControllers() { 81 89 $this->Xo->RequireOnce('Includes/Api/Abstract/Controller.class.php'); 82 90 $this->Xo->RequireOnce('Includes/Api/Abstract/IndexController.class.php'); -
xo-for-angular/trunk/Includes/Api/Classes/Router.class.php
r2042983 r2056075 11 11 * @var Xo 12 12 */ 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) { 21 43 $this->Xo = $Xo; 22 44 … … 25 47 } 26 48 27 function Init() {49 public function Init() { 28 50 global $wp; 29 51 … … 34 56 } 35 57 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() { 37 66 if ((!$this->Xo->Services->Options->GetOption('xo_api_enabled', false)) 38 67 || (!$apiEndpoint = $this->Xo->Services->Options->GetOption('xo_api_endpoint'))) … … 61 90 } 62 91 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) { 64 102 $class = apply_filters('xo/api/router/controllers/add', $class, $endpoint); 65 103 $this->controllers[$endpoint] = $class; 66 104 } 67 105 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() { 69 114 global $wp; 70 115 116 // Return to normal operation if the Xo API is disabled 71 117 if (!$this->Xo->Services->Options->GetOption('xo_api_enabled', false)) 72 118 return; 73 119 120 // Return to normal if the query does not match the class query var 74 121 if (empty($wp->query_vars[$this->classQueryVar])) 75 122 return; 76 123 124 // Set the header as json output 77 125 header('Content-Type: application/json'); 78 126 127 // Determine the class configured for the current endpoint 79 128 $endpoint = $wp->query_vars[$this->classQueryVar]; 129 130 // Filter the the request class 80 131 $class = apply_filters('xo/api/router/controllers/get', $this->controllers[$endpoint], $endpoint); 81 132 133 // Return an error if the class was not defined 82 134 if (!$class) 83 135 return $this->ReturnError(__('No class defined for endpoint.', 'xo')); 84 136 137 // Return an error if the class does not exist or was not included 85 138 if (!class_exists($class)) 86 139 return $this->ReturnError(sprintf(__('Class %s was not found.', 'xo'), $class)); 87 140 141 // Determine the desired method within the endpoint 88 142 $method = ((!empty($wp->query_vars[$this->methodQueryVar])) ? ucfirst($wp->query_vars[$this->methodQueryVar]) : 'Index'); 143 144 // Filter the request method 89 145 $method = apply_filters('xo/api/router/methods/get', $method, $class, $endpoint); 90 146 147 // Return an error if the method was not determined 91 148 if (!$method) 92 149 return $this->ReturnError(__('No method determined for endpoint.', 'xo')); 93 150 151 // Return an error if the requested method is not public 94 152 if (!is_callable(array($class, $method))) 95 153 return $this->ReturnError(sprintf(__('Method %s in class %s was not found or private.', 'xo'), $method, $class)); 96 154 155 // Exit and return no data if the request method is options, likely a CORS precursor 97 156 if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') 98 157 exit; 99 158 159 // Decode the body of the request, expected to be a json blob 100 160 $request = json_decode(file_get_contents("php://input"), true); 101 161 162 // Extract the object vars from the request if its an object 102 163 if (is_object($request)) 103 164 $request = get_object_vars($request); 104 165 166 // If the body was empty use the PHP combined $_REQUEST object instead 105 167 $request = (((is_array($request)) && count($request)) ? $request : $_REQUEST); 168 169 // Filter the request object 106 170 $request = apply_filters('xo/api/router/request/get', $request, $method, $class, $endpoint); 107 171 172 // Create a class reflection to check if method requires params 108 173 $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 110 178 $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 112 182 $response = call_user_func(array(new $class($this->Xo), $method), $request); 113 183 184 // Filter the response 114 185 $response = apply_filters('xo/api/router/response', $response, $request, $method, $class, $endpoint); 115 186 187 // Return the generated response object 116 188 $this->ReturnResponse($response); 117 189 } 118 190 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) { 120 199 echo json_encode($response); 121 200 die(); 122 201 } 123 202 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) { 125 211 header('HTTP/1.0 404 Not Found'); 126 212 $this->ReturnResponse(new XoApiAbstractResponse(false, $message)); -
xo-for-angular/trunk/Includes/Api/Controllers/ConfigController.class.php
r2042983 r2056075 15 15 * @return XoApiAbstractConfigGetResponse 16 16 */ 17 function Get() {17 public function Get() { 18 18 $theme = wp_get_theme(); 19 19 -
xo-for-angular/trunk/Includes/Api/Controllers/MenusController.class.php
r2054976 r2056075 16 16 * @return XoApiAbstractMenusGetResponse 17 17 */ 18 function Get($params) {18 public function Get($params) { 19 19 // Return an error if menu location name is missing 20 20 if (empty($params['menu'])) -
xo-for-angular/trunk/Includes/Api/Controllers/OptionsController.class.php
r2042983 r2056075 16 16 * @return XoApiAbstractOptionsGetResponse 17 17 */ 18 function Get($params) {18 public function Get($params) { 19 19 // Return an error if ACF is not present or activated 20 20 if ((!function_exists('acf_get_fields')) || -
xo-for-angular/trunk/Includes/Api/Controllers/PostsController.class.php
r2051900 r2056075 68 68 * @return XoApiAbstractPostsGetResponse 69 69 */ 70 function GetDraftOrPreview($params) {70 public function GetDraftOrPreview($params) { 71 71 // Return an error if the user is not logged in or not an editor 72 72 if (!current_user_can('edit_others_pages')) -
xo-for-angular/trunk/Includes/Api/Controllers/RoutesController.class.php
r2042983 r2056075 2 2 3 3 /** 4 * Provide endpoints for retrieving dynamic routes .4 * Provide endpoints for retrieving dynamic routes and sitemap. 5 5 * 6 6 * @since 1.0.0 … … 15 15 * @return XoApiAbstractRoutesGetResponse 16 16 */ 17 function Get() {17 public function Get() { 18 18 // Check if the currently logged in user can edit pages and previews are enabled 19 19 $previewsEnabled = ((current_user_can('edit_others_pages')) && … … 27 27 return new XoApiAbstractRoutesGetResponse(false, __('Unable to retrieve routes.', 'xo')); 28 28 29 // Return success 29 // Return success and generated routes 30 30 return new XoApiAbstractRoutesGetResponse( 31 31 true, __('Successfully retrieved routes.', 'xo'), … … 33 33 ); 34 34 } 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 } 35 59 } -
xo-for-angular/trunk/Includes/Api/Controllers/TermsController.class.php
r2054167 r2056075 50 50 * @return XoApiAbstractTermsFilterResponse 51 51 */ 52 function Filter($params) {52 public function Filter($params) { 53 53 // Return an error if the taxonomy is missing 54 54 if (empty($params['taxonomy'])) … … 97 97 */ 98 98 private function GetTaxonomyByUrl($url) { 99 $taxonomies = get_taxonomies(array(), 'objects'); 99 $taxonomies = get_taxonomies(array( 100 'public' => 1 101 ), 'objects'); 100 102 101 103 foreach ($taxonomies as $taxonomy_config) { -
xo-for-angular/trunk/Includes/Filters/External/PostTemplates.class.php
r2042983 r2056075 16 16 $this->Xo = $Xo; 17 17 18 add_filter('template_include', array($this, 'TemplateInclude'), 1, 1); 19 add_action('admin_init', array($this, 'RegisterTemplateFilters'), 10, 0); 18 $this->Init(); 20 19 } 21 20 22 function RegisterTemplateFilters() { 21 function Init() { 22 add_filter('template_include', array($this, 'TemplateInclude'), 1, 1); 23 23 add_filter('default_page_template_title', array($this, 'DefaultPageTemplateTitle'), 10, 2); 24 24 add_filter('theme_page_templates', array($this, 'ThemeTemplates'), 10, 4); … … 34 34 35 35 function ThemeTemplates($templates, WP_Theme $theme, $post, $post_type) { 36 echo 'theme templates'; 36 37 $annotatedTemplates = $this->Xo->Services->TemplateReader->GetAnnotatedTemplates(); 37 38 -
xo-for-angular/trunk/Includes/Options/Options.class.php
r2051900 r2056075 11 11 * @var Xo 12 12 */ 13 var$Xo;13 protected $Xo; 14 14 15 15 /** 16 16 * @var XoOptionsMenuPage 17 17 */ 18 var$MainSettingsPage;18 public $MainSettingsPage; 19 19 20 20 /** 21 21 * @var XoOptionsSubMenuPage 22 22 */ 23 var$GeneralSettingsPage;23 public $GeneralSettingsPage; 24 24 25 25 /** 26 26 * @var XoOptionsSubMenuPage 27 27 */ 28 var$ToolsPage;28 public $ToolsPage; 29 29 30 function __construct($Xo) {30 public function __construct($Xo) { 31 31 $this->Xo = $Xo; 32 32 … … 35 35 } 36 36 37 function Init() {37 protected function Init() { 38 38 $this->InitGeneralSettingsPage(); 39 39 … … 47 47 } 48 48 49 function AddAdminStyles() {49 public function AddAdminStyles() { 50 50 $adminCssFile = $this->Xo->GetFile('assets/css/admin.css', true); 51 51 … … 54 54 } 55 55 56 function InitMainSettingsPage() {56 protected function InitMainSettingsPage() { 57 57 $this->MainSettingsPage = new XoOptionsMenuPage( 58 58 $this->Xo, … … 67 67 } 68 68 69 function InitMainSettingsPageTabs() {69 protected function InitMainSettingsPageTabs() { 70 70 $this->MainSettingsPage->AddTab('index', __('Index', 'xo'), 'XoOptionsTabIndex'); 71 71 $this->MainSettingsPage->AddTab('api', __('API', 'xo'), 'XoOptionsTabApi'); … … 78 78 } 79 79 80 function InitGeneralSettingsPage() {80 protected function InitGeneralSettingsPage() { 81 81 $this->GeneralSettingsPage = new XoOptionsSubMenuPage( 82 82 $this->Xo, … … 90 90 } 91 91 92 function InitToolsPage() {92 protected function InitToolsPage() { 93 93 $this->ToolsPage = new XoOptionsSubMenuPage( 94 94 $this->Xo, … … 102 102 } 103 103 104 function InitToolsPageTabs() {104 protected function InitToolsPageTabs() { 105 105 $this->ToolsPage->AddTab('tools', __('Tools', 'xo'), 'XoOptionsTabTools'); 106 106 $this->ToolsPage->AddTab('profile', __('Profile', 'xo'), 'XoOptionsTabProfile'); … … 108 108 } 109 109 110 function Includes() {110 protected function Includes() { 111 111 // Include abstract classes for admin pages and tabs 112 112 $this->IncludeAbstractClasses(); … … 119 119 } 120 120 121 function IncludeAbstractClasses() {121 protected function IncludeAbstractClasses() { 122 122 $this->Xo->RequireOnce('Includes/Options/Abstract/Tab.class.php'); 123 123 $this->Xo->RequireOnce('Includes/Options/Abstract/FieldsTab.class.php'); … … 129 129 } 130 130 131 function IncludeGeneralTabs() {131 protected function IncludeGeneralTabs() { 132 132 $this->Xo->RequireOnce('Includes/Options/Tabs/General/IndexTab.class.php'); 133 133 $this->Xo->RequireOnce('Includes/Options/Tabs/General/ApiTab.class.php'); … … 138 138 } 139 139 140 function IncludeToolsTabs() {140 protected function IncludeToolsTabs() { 141 141 $this->Xo->RequireOnce('Includes/Options/Tabs/Tools/ToolsTab.class.php'); 142 142 $this->Xo->RequireOnce('Includes/Options/Tabs/Tools/ProfileTab.class.php'); -
xo-for-angular/trunk/Includes/Services/Classes/AdminNotice.class.php
r2043391 r2056075 15 15 * @var string 16 16 */ 17 var$key;17 protected $key; 18 18 19 19 /** … … 24 24 * @var callable 25 25 */ 26 var$renderFn;26 public $renderFn; 27 27 28 28 /** … … 34 34 * @param callable $renderFn Callback for generating the body of the notice. 35 35 */ 36 function __construct($key, callable $renderFn) {36 public function __construct($key, callable $renderFn) { 37 37 $this->key = $key; 38 38 $this->renderFn = $renderFn; … … 48 48 * @param array $settings Additional data passed to the notice such as the expiration. 49 49 */ 50 function RegisterNotice($settings = array()) {50 public function RegisterNotice($settings = array()) { 51 51 if (!isset($settings['dismissable'])) 52 52 $settings['dismissable'] = true; … … 65 65 * @return void 66 66 */ 67 function ShowNotice() {67 public function ShowNotice() { 68 68 if (!$settings = get_transient($this->key)) 69 69 return; … … 86 86 * @return void 87 87 */ 88 function DismissNotice() {88 public function DismissNotice() { 89 89 delete_transient($this->key); 90 90 } -
xo-for-angular/trunk/Includes/Services/Classes/IndexBuilder.class.php
r2042983 r2056075 11 11 * @var Xo 12 12 */ 13 var$Xo;13 protected $Xo; 14 14 15 15 /** … … 20 20 * @var string 21 21 */ 22 var$appConfigScriptId = 'xo-config';23 24 function __construct(Xo $Xo) {22 protected $appConfigScriptId = 'xo-config'; 23 24 public function __construct(Xo $Xo) { 25 25 $this->Xo = $Xo; 26 26 } … … 33 33 * @return boolean|string Rendered index output. 34 34 */ 35 function RenderDistIndex() {35 public function RenderDistIndex() { 36 36 if (!$srcIndex = $this->Xo->Services->Options->GetOption('xo_index_dist', false)) 37 37 return false; … … 71 71 * @return boolean Whether wp_head was successfully added to the output stream. 72 72 */ 73 pr ivatefunction AddWpHead(&$output) {73 protected function AddWpHead(&$output) { 74 74 $headPos = strpos($output, '</head>'); 75 75 if ($headPos === false) … … 97 97 * @return boolean Whether wp_footer was successfully added to the output stream. 98 98 */ 99 pr ivatefunction AddWpFooter(&$output) {99 protected function AddWpFooter(&$output) { 100 100 $bodyPos = strpos($output, '</body>'); 101 101 if ($bodyPos === false) … … 123 123 * @return boolean Whether App Config was successfully added to the output stream. 124 124 */ 125 pr ivatefunction AddAppConfig(&$output) {125 protected function AddAppConfig(&$output) { 126 126 $XoApiConfigController = new XoApiControllerConfig($this->Xo); 127 127 $config = $XoApiConfigController->Get(); … … 159 159 * @return boolean Whether the entrypoint was successfully found or added in the src index. 160 160 */ 161 function AddAppConfigEntrypoint() {161 public function AddAppConfigEntrypoint() { 162 162 if (!$srcIndex = $this->Xo->Services->Options->GetOption('xo_index_src', false)) 163 163 return false; … … 205 205 * @return boolean Whether the App Config entrypoint is found in the src index. 206 206 */ 207 function CheckAppConfigEntrypoint() {207 public function CheckAppConfigEntrypoint() { 208 208 if (!$srcIndex = $this->Xo->Services->Options->GetOption('xo_index_src', false)) 209 209 return false; … … 239 239 * @return void 240 240 */ 241 pr ivatefunction InsertBetween(&$stream, $content, $start, $end = false) {241 protected function InsertBetween(&$stream, $content, $start, $end = false) { 242 242 if (!$end) 243 243 $end = $start; … … 248 248 /** 249 249 * Write the index file with the given content. 250 * 251 * @since 1.0.0 252 * 250 * 251 * @since 1.0.0 252 * 253 253 * @param string $file Absolute path to the file to write. 254 254 * @param string $content Content to write into the file. 255 255 * @return boolean Whether the content was successfully written. 256 256 */ 257 pr ivatefunction WriteIndex($file, $content) {257 protected function WriteIndex($file, $content) { 258 258 if (!$handle = fopen($file, 'r+')) 259 259 return false; -
xo-for-angular/trunk/Includes/Services/Classes/Options.class.php
r2042983 r2056075 11 11 * @var Xo 12 12 */ 13 var$Xo;13 protected $Xo; 14 14 15 15 /** … … 20 20 * @var array 21 21 */ 22 var$overrides = array();23 24 function __construct(Xo $Xo) {22 protected $overrides = array(); 23 24 public function __construct(Xo $Xo) { 25 25 $this->Xo = $Xo; 26 26 add_action('init', array($this, 'Init'), 10, 0); 27 27 } 28 28 29 function Init() {29 public function Init() { 30 30 $this->SetOverrides(); 31 31 } … … 38 38 * @return void 39 39 */ 40 function SetOverrides() {40 public function SetOverrides() { 41 41 if (!defined('XO_SETTINGS')) 42 42 return; … … 58 58 * @return mixed Return value of the option. 59 59 */ 60 function GetOption($name, $value = false) {60 public function GetOption($name, $value = false) { 61 61 if (isset($this->overrides[$name])) { 62 62 $value = $this->overrides[$name]; … … 79 79 * @return bool Whether the option was updated. 80 80 */ 81 function SetOption($name, $value = false) {81 public function SetOption($name, $value = false) { 82 82 $value = apply_filters('xo/options/set/' . $name, $value); 83 83 … … 92 92 * @return array 93 93 */ 94 function GetDefaultSettings() {94 protected function GetDefaultSettings() { 95 95 $defaults = array( 96 96 // Index Tab … … 131 131 * @return array All current settings. 132 132 */ 133 function GetCurrentSettings() {133 public function GetCurrentSettings() { 134 134 $settings = array(); 135 135 $defaults = $this->GetDefaults(); … … 150 150 * @return mixed The defaults filtered by xo/options/defaults. 151 151 */ 152 function GetDefaults() {152 public function GetDefaults() { 153 153 $defaults = $this->GetDefaultSettings(); 154 154 … … 168 168 * @return bool Whether any options were set. 169 169 */ 170 function SetDefaults() {170 public function SetDefaults() { 171 171 $defaults = $this->GetDefaults(); 172 172 … … 186 186 * @return bool Whether any options were set. 187 187 */ 188 function ResetDefaults() {188 public function ResetDefaults() { 189 189 $defaults = $this->GetDefaults(); 190 190 … … 205 205 * @return array States of the given option. 206 206 */ 207 function GetStates($option) {207 public function GetStates($option) { 208 208 $states = array(); 209 209 … … 223 223 * @return bool|string[] 224 224 */ 225 function GetOptionsFromJson() {225 protected function GetOptionsFromJson() { 226 226 if (!$jsons = $this->Xo->Services->AngularJson->ParseConfig()) 227 227 return false; -
xo-for-angular/trunk/Includes/Services/Classes/RouteGenerator.class.php
r2054167 r2056075 11 11 * @var Xo 12 12 */ 13 var$Xo;13 protected $Xo; 14 14 15 function __construct(Xo $Xo) {15 public function __construct(Xo $Xo) { 16 16 $this->Xo = $Xo; 17 17 } … … 54 54 } 55 55 56 pr ivatefunction AddRoutesForPages(&$routes) {56 protected function AddRoutesForPages(&$routes) { 57 57 $page404Id = intval($this->Xo->Services->Options->GetOption('xo_404_page_id', 0)); 58 58 … … 73 73 } 74 74 75 pr ivatefunction AddRouteFor404Page(&$routes) {75 protected function AddRouteFor404Page(&$routes) { 76 76 if (($page404Id = intval($this->Xo->Services->Options->GetOption('xo_404_page_id', 0))) && 77 77 ($attrs = $this->Xo->Services->TemplateReader->GetTemplateForPost($page404Id))) { … … 83 83 } 84 84 85 pr ivatefunction AddRoutesForPosts(&$routes) {85 protected function AddRoutesForPosts(&$routes) { 86 86 global $wp_post_types; 87 87 … … 128 128 } 129 129 130 pr ivatefunction AddRoutesForPageDrafts(&$routes) {130 protected function AddRoutesForPageDrafts(&$routes) { 131 131 $posts = get_posts(array( 132 132 'post_status' => 'draft', … … 145 145 } 146 146 147 pr ivatefunction AddRoutesForPagePreviews(&$routes) {147 protected function AddRoutesForPagePreviews(&$routes) { 148 148 $posts = get_posts(array( 149 149 'post_status' => 'publish', … … 163 163 } 164 164 165 pr ivatefunction AddRoutesForPostDraftsAndPreviews(&$routes) {165 protected function AddRoutesForPostDraftsAndPreviews(&$routes) { 166 166 global $wp_post_types; 167 167 -
xo-for-angular/trunk/Includes/Services/Classes/TemplateReader.class.php
r2042983 r2056075 11 11 * @var Xo 12 12 */ 13 var$Xo;13 protected $Xo; 14 14 15 15 /** 16 16 * @var XoServiceAdminNotice 17 17 */ 18 var$UpdateTemplatesNotice;18 protected $UpdateTemplatesNotice; 19 19 20 20 /** … … 25 25 * @var string 26 26 */ 27 var$templateDir;27 protected $templateDir; 28 28 29 29 /** … … 34 34 * @var string 35 35 */ 36 var$templatesPath;36 protected $templatesPath; 37 37 38 38 /** … … 43 43 * @var array 44 44 */ 45 var$templatesExtensions = array('ts');45 protected $templatesExtensions = array('ts'); 46 46 47 47 /** … … 52 52 * @var string 53 53 */ 54 var$commentBlockRegex = '/\/\*\*\s*?\n(.*?)\n\s*?\*\//is';54 protected $commentBlockRegex = '/\/\*\*\s*?\n(.*?)\n\s*?\*\//is'; 55 55 56 56 /** … … 61 61 * @var string 62 62 */ 63 var$annotationsRegex = '/(?: *\*+ *@Xo)(?P<key>\w+)(?: )(?P<value>[ \w!,]+)/';63 protected $annotationsRegex = '/(?: *\*+ *@Xo)(?P<key>\w+)(?: )(?P<value>[ \w!,]+)/'; 64 64 65 65 /** … … 70 70 * @var array 71 71 */ 72 var$annotationsFormats = array(72 protected $annotationsFormats = array( 73 73 'disableEditor' => 'boolean', 74 74 'defaultTemplate' => 'boolean', … … 84 84 * @var array 85 85 */ 86 var$annotatedTemplates = array();87 88 function __construct(Xo $Xo) {86 protected $annotatedTemplates = array(); 87 88 public function __construct(Xo $Xo) { 89 89 $this->Xo = $Xo; 90 90 … … 104 104 * @return void 105 105 */ 106 function Init() {106 public function Init() { 107 107 $this->templateDir = get_template_directory(); 108 108 $this->templatesPath = $this->Xo->Services->Options->GetOption('xo_templates_path', ''); … … 117 117 * @return array|boolean Annotated template data. 118 118 */ 119 function GetTemplateForPost($post) {119 public function GetTemplateForPost($post) { 120 120 $this->GetAnnotatedTemplates(); 121 121 … … 148 148 * @return array All templates and annotations. 149 149 */ 150 function GetAnnotatedTemplates() {150 public function GetAnnotatedTemplates() { 151 151 if (!$this->Xo->Services->Options->GetOption('xo_templates_reader_enabled', false)) 152 152 return array(); … … 169 169 * @return array|boolean Annotations for the given template. 170 170 */ 171 function GetAnnotatedTemplate($template) {171 public function GetAnnotatedTemplate($template) { 172 172 $this->GetAnnotatedTemplates(); 173 173 … … 192 192 * @return array All templates and annotations. 193 193 */ 194 function GetTemplates($caching = true, $useCache = true) {194 public function GetTemplates($caching = true, $useCache = true) { 195 195 $templatesCache = $this->Xo->Services->Options->GetOption('xo_templates_cache', array()); 196 196 … … 231 231 * @return array All possible template files. 232 232 */ 233 pr ivatefunction GetTemplateFiles() {233 protected function GetTemplateFiles() { 234 234 $length = strlen($this->templateDir) + 1; 235 235 $files = array(); … … 265 265 * @return array|boolean Annotations. 266 266 */ 267 pr ivatefunction ParseTemplateCommentBlocks($template) {267 protected function ParseTemplateCommentBlocks($template) { 268 268 $fileName = $this->templateDir . '/' . $template; 269 269 … … 291 291 * @return array|boolean Formatted annotations. 292 292 */ 293 pr ivatefunction ParseTemplateCommentBlockAnnotations($template, $block) {293 protected function ParseTemplateCommentBlockAnnotations($template, $block) { 294 294 if (preg_match_all($this->annotationsRegex, $block, $matchAttrs, PREG_SET_ORDER)) { 295 295 $attrs = array(); … … 320 320 } 321 321 322 function RenderUpdateTemplatesNotice() {322 public function RenderUpdateTemplatesNotice() { 323 323 $output = '<p><strong>' . sprintf( 324 324 __('%s templates cache updated.', 'xo'), -
xo-for-angular/trunk/Includes/Services/Services.class.php
r2042983 r2056075 11 11 * @var Xo 12 12 */ 13 var$Xo;13 protected $Xo; 14 14 15 15 /** … … 31 31 * @var XoServiceIndexBuilder 32 32 */ 33 var$IndexBuilder;33 public $IndexBuilder; 34 34 35 35 /** 36 36 * @var XoServiceRouteGenerator 37 37 */ 38 var$RouteGenerator;38 public $RouteGenerator; 39 39 40 function __construct($Xo) { 40 /** 41 * @var XoServiceSitemapGenerator 42 */ 43 public $SitemapGenerator; 44 45 public function __construct($Xo) { 41 46 $this->Xo = $Xo; 42 47 … … 45 50 } 46 51 47 function Init() {52 protected function Init() { 48 53 $this->Options = new XoServiceOptions($this->Xo); 49 54 $this->AngularJson = new XoServiceAngularJson(); … … 51 56 $this->IndexBuilder = new XoServiceIndexBuilder($this->Xo); 52 57 $this->RouteGenerator = new XoServiceRouteGenerator($this->Xo); 58 $this->SitemapGenerator = new XoServiceSitemapGenerator($this->Xo); 53 59 } 54 60 55 function Includes() {61 protected function Includes() { 56 62 $this->Xo->RequireOnce('Includes/Services/Classes/Options.class.php'); 57 63 $this->Xo->RequireOnce('Includes/Services/Classes/AngularJson.class.php'); … … 59 65 $this->Xo->RequireOnce('Includes/Services/Classes/IndexBuilder.class.php'); 60 66 $this->Xo->RequireOnce('Includes/Services/Classes/RouteGenerator.class.php'); 67 $this->Xo->RequireOnce('Includes/Services/Classes/SitemapGenerator.class.php'); 61 68 $this->Xo->RequireOnce('Includes/Services/Classes/AdminNotice.class.php'); 62 69 } -
xo-for-angular/trunk/xo-angular.php
r2054976 r2056075 4 4 Plugin URI: https://angularxo.io 5 5 Description: Angular theme development in WordPress with templates and a powerful API. 6 Version: 1.0. 86 Version: 1.0.9 7 7 Author: Travis Brown 8 8 Author URI: http://www.xodustech.com
Note: See TracChangeset
for help on using the changeset viewer.