| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Base class for both admin and frontend |
| 8 | 5 | * |
| @@ -8,44 +5,11 @@ | ||
| 8 | 5 | * |
| 9 | 6 | * @since 1.2 |
| 10 | 7 | */ |
| 11 | 8 | abstract class PLL_Base { |
| 12 | - /** | |
| 13 | - * Stores the plugin options. | |
| 14 | - * | |
| 15 | - * @var array | |
| 16 | - */ | |
| 17 | - public $options; | |
| 9 | + public $links_model, $model, $options; | |
| 18 | 10 | |
| 19 | 11 | /** |
| 20 | - * Instance of PLL_Model. | |
| 21 | - * | |
| 22 | - * @var PLL_Model | |
| 23 | - */ | |
| 24 | - public $model; | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * Instance of a child class of PLL_Links_Model. | |
| 28 | - * | |
| 29 | - * @var PLL_Links_Model | |
| 30 | - */ | |
| 31 | - public $links_model; | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * Registers hooks on insert / update post related actions and filters. | |
| 35 | - * | |
| 36 | - * @var PLL_CRUD_Posts | |
| 37 | - */ | |
| 38 | - public $posts; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * Registers hooks on insert / update term related action and filters. | |
| 42 | - * | |
| 43 | - * @var PLL_CRUD_Terms | |
| 44 | - */ | |
| 45 | - public $terms; | |
| 46 | - | |
| 47 | - /** | |
| 48 | 12 | * Constructor |
| 49 | 13 | * |
| 50 | 14 | * @since 1.2 |
| 51 | 15 | * |
| @@ -68,17 +32,33 @@ | ||
| 68 | 32 | add_action( 'switch_blog', array( $this, 'switch_blog' ), 10, 2 ); |
| 69 | 33 | } |
| 70 | 34 | |
| 71 | 35 | /** |
| 72 | - * Instantiates classes reacting to CRUD operations on posts and terms, | |
| 73 | - * only when at least one language is defined. | |
| 36 | + * Instantiate classes always needed | |
| 74 | 37 | * |
| 75 | 38 | * @since 2.6 |
| 76 | 39 | */ |
| 77 | 40 | public function init() { |
| 41 | + // REST API | |
| 42 | + if ( class_exists( 'PLL_REST_API' ) ) { | |
| 43 | + $this->rest_api = new PLL_REST_API( $this ); | |
| 44 | + } | |
| 45 | + | |
| 78 | 46 | if ( $this->model->get_languages_list() ) { |
| 79 | - $this->posts = new PLL_CRUD_Posts( $this ); | |
| 80 | - $this->terms = new PLL_CRUD_Terms( $this ); | |
| 47 | + // Used by content duplicate and post synchronization | |
| 48 | + if ( class_exists( 'PLL_Sync_Content' ) ) { | |
| 49 | + $this->sync_content = new PLL_Sync_Content( $this ); | |
| 50 | + } | |
| 51 | + | |
| 52 | + // Active languages | |
| 53 | + if ( class_exists( 'PLL_Active_Languages' ) ) { | |
| 54 | + $this->active_languages = new PLL_Active_Languages( $this ); | |
| 55 | + } | |
| 56 | + | |
| 57 | + // Share post slugs | |
| 58 | + if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Share_Post_Slug' ) ) { | |
| 59 | + $this->share_post_slug = new PLL_Share_Post_Slug( $this ); | |
| 60 | + } | |
| 81 | 61 | } |
| 82 | 62 | } |
| 83 | 63 | |
| 84 | 64 | /** |