| @@ -1,72 +1,73 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | - * Main Polylang class for REST API requrests, accessible from @see PLL(). | |
| 4 | + * REST API controller | |
| 5 | + * accessible as $polylang global object | |
| 8 | 6 | * |
| 7 | + * Properties: | |
| 8 | + * options => inherited, reference to Polylang options array | |
| 9 | + * model => inherited, reference to PLL_Model object | |
| 10 | + * links_model => inherited, reference to PLL_Links_Model object | |
| 11 | + * links => reference to PLL_Admin_Links object | |
| 12 | + * static_pages => reference to PLL_Static_Pages object | |
| 13 | + * filters_links => reference to PLL_Filters_Links object | |
| 14 | + * posts => reference to PLL_CRUD_Posts object | |
| 15 | + * terms => reference to PLL_CRUD_Terms object | |
| 16 | + * sync => reference to PLL_Sync object | |
| 17 | + * | |
| 9 | 18 | * @since 2.6 |
| 10 | 19 | */ |
| 11 | 20 | class PLL_REST_Request extends PLL_Base { |
| 21 | + public $links, $posts, $terms, $filters_links, $sync; | |
| 12 | 22 | |
| 13 | 23 | /** |
| 14 | - * @var PLL_Filters | |
| 15 | - */ | |
| 16 | - public $filters; | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * @var PLL_Filters_Links | |
| 20 | - */ | |
| 21 | - public $filters_links; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @var PLL_Admin_Links | |
| 25 | - */ | |
| 26 | - public $links; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * @var PLL_Nav_Menu | |
| 30 | - */ | |
| 31 | - public $nav_menu; | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * @var PLL_Static_Pages | |
| 35 | - */ | |
| 36 | - public $static_pages; | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * @var PLL_Filters_Widgets_Options | |
| 40 | - */ | |
| 41 | - public $filters_widgets; | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * Setup filters. | |
| 24 | + * Setup filters | |
| 45 | 25 | * |
| 46 | 26 | * @since 2.6 |
| 47 | - * | |
| 48 | - * @return void | |
| 49 | 27 | */ |
| 50 | 28 | public function init() { |
| 51 | 29 | parent::init(); |
| 52 | 30 | |
| 53 | 31 | if ( $this->model->get_languages_list() ) { |
| 54 | - | |
| 55 | - /** This action is documented in include/class-polylang.php */ | |
| 56 | - do_action( 'pll_no_language_defined' ); // To load overridden textdomains. | |
| 57 | - | |
| 58 | 32 | $this->filters_links = new PLL_Filters_Links( $this ); |
| 59 | - $this->filters = new PLL_Filters( $this ); | |
| 60 | - $this->filters_widgets = new PLL_Filters_Widgets_Options( $this ); | |
| 61 | 33 | |
| 62 | - // Static front page and page for posts. | |
| 34 | + // Static front page and page for posts | |
| 63 | 35 | if ( 'page' === get_option( 'show_on_front' ) ) { |
| 64 | 36 | $this->static_pages = new PLL_Static_Pages( $this ); |
| 65 | 37 | } |
| 66 | 38 | |
| 67 | 39 | $this->links = new PLL_Admin_Links( $this ); |
| 40 | + $this->posts = new PLL_CRUD_Posts( $this ); | |
| 41 | + $this->terms = new PLL_CRUD_Terms( $this ); | |
| 42 | + $this->sync = new PLL_Sync( $this ); | |
| 68 | 43 | |
| 69 | - $this->nav_menu = new PLL_Nav_Menu( $this ); // For auto added pages to menu. | |
| 44 | + $this->nav_menu = new PLL_Nav_Menu( $this ); // For auto added pages to menu | |
| 45 | + | |
| 46 | + // Share term slugs | |
| 47 | + if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Share_Term_Slug' ) ) { | |
| 48 | + $this->share_term_slug = version_compare( $GLOBALS['wp_version'], '4.8', '<' ) ? | |
| 49 | + new PLL_Frontend_Share_Term_Slug( $this ) : | |
| 50 | + new PLL_Share_Term_Slug( $this ); | |
| 51 | + } | |
| 52 | + | |
| 53 | + // Translate slugs, only for pretty permalinks | |
| 54 | + if ( get_option( 'permalink_structure' ) && class_exists( 'PLL_Translate_Slugs' ) ) { | |
| 55 | + $curlang = null; | |
| 56 | + $slugs_model = new PLL_Translate_Slugs_Model( $this ); | |
| 57 | + $this->translate_slugs = new PLL_Translate_Slugs( $slugs_model, $curlang ); | |
| 58 | + } | |
| 59 | + | |
| 60 | + if ( class_exists( 'PLL_Sync_Content' ) ) { | |
| 61 | + $this->sync_content = new PLL_Sync_Content( $this ); | |
| 62 | + } | |
| 63 | + | |
| 64 | + if ( class_exists( 'PLL_Sync_Post_REST' ) ) { | |
| 65 | + $this->sync_post = new PLL_Sync_Post_REST( $this ); | |
| 66 | + } | |
| 67 | + | |
| 68 | + if ( class_exists( 'PLL_Duplicate_REST' ) ) { | |
| 69 | + $this->duplicate_rest = new PLL_Duplicate_REST(); | |
| 70 | + } | |
| 70 | 71 | } |
| 71 | 72 | } |
| 72 | 73 | } |