| @@ -3,94 +3,71 @@ | ||
| 3 | 3 | * @package Polylang |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | - * Admin side controller | |
| 8 | - * accessible in $polylang global object | |
| 7 | + * Main Polylang class for admin (except Polylang pages), accessible from @see PLL(). | |
| 9 | 8 | * |
| 10 | - * Properties: | |
| 11 | - * options => inherited, reference to Polylang options array | |
| 12 | - * model => inherited, reference to PLL_Model object | |
| 13 | - * links_model => inherited, reference to PLL_Links_Model object | |
| 14 | - * links => inherited, reference to PLL_Admin_Links object | |
| 15 | - * static_pages => inherited, reference to PLL_Admin_Static_Pages object | |
| 16 | - * filters_links => inherited, reference to PLL_Filters_Links object | |
| 17 | - * curlang => inherited, optional, current language used to filter the content (language of the post or term being edited, equal to filter_lang otherwise) | |
| 18 | - * filter_lang => inherited, optional, current status of the admin languages filter (in the admin bar) | |
| 19 | - * pref_lang => inherited, preferred language used as default when saving posts or terms | |
| 20 | - * posts => reference to PLL_CRUD_Posts object | |
| 21 | - * terms => reference to PLL_CRUD_Terms object | |
| 22 | - * filters => reference to PLL_Admin_Filters object | |
| 23 | - * filters_sanitization => reference to PLL_Filters_Sanitization object | |
| 24 | - * filters_columns => reference to PLL_Admin_Filters_Columns object | |
| 25 | - * filters_post => reference to PLL_Admin_Filters_Post object | |
| 26 | - * filters_term => reference to PLL_Admin_filters_Term object | |
| 27 | - * nav_menu => reference to PLL_Admin_Nav_Menu object | |
| 28 | - * block_editor => reference to PLL_Admin_Block_Editor object | |
| 29 | - * classic_editor => reference to PLL_Admin_Classic_Editor object | |
| 30 | - * filters_media => optional, reference to PLL_Admin_Filters_Media object | |
| 31 | - * | |
| 32 | 9 | * @since 1.2 |
| 33 | 10 | */ |
| 34 | 11 | class PLL_Admin extends PLL_Admin_Base { |
| 35 | 12 | /** |
| 36 | - * Instance of PLL_Admin_Filters | |
| 37 | - * | |
| 38 | - * @var PLL_Admin_Filters | |
| 13 | + * @var PLL_Admin_Filters|null | |
| 39 | 14 | */ |
| 40 | 15 | public $filters; |
| 41 | 16 | |
| 42 | 17 | /** |
| 43 | - * Instance of PLL_Admin_Filters_Columns | |
| 44 | - * | |
| 45 | - * @var PLL_Admin_Filters_Columns | |
| 18 | + * @var PLL_Admin_Filters_Columns|null | |
| 46 | 19 | */ |
| 47 | 20 | public $filters_columns; |
| 48 | 21 | |
| 49 | 22 | /** |
| 50 | - * Instance of PLL_Admin_Filters_Post | |
| 51 | - * | |
| 52 | - * @var PLL_Admin_Filters_Post | |
| 23 | + * @var PLL_Admin_Filters_Post|null | |
| 53 | 24 | */ |
| 54 | 25 | public $filters_post; |
| 55 | 26 | |
| 56 | 27 | /** |
| 57 | - * Instance of PLL_Admin_filters_Term | |
| 58 | - * | |
| 59 | - * @var PLL_Admin_filters_Term | |
| 28 | + * @var PLL_Admin_Filters_Term|null | |
| 60 | 29 | */ |
| 61 | 30 | public $filters_term; |
| 62 | 31 | |
| 63 | 32 | /** |
| 64 | - * Instance of PLL_Admin_Nav_Menu | |
| 33 | + * @var PLL_Admin_Filters_Media|null | |
| 34 | + */ | |
| 35 | + public $filters_media; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * @since 2.9 | |
| 65 | 39 | * |
| 66 | - * @var PLL_Admin_Nav_Menu | |
| 40 | + * @var PLL_Filters_Sanitization|null | |
| 67 | 41 | */ |
| 68 | - public $nav_menu; | |
| 42 | + public $filters_sanitization; | |
| 69 | 43 | |
| 70 | 44 | /** |
| 71 | - * Instance of PLL_Admin_Filters_Media | |
| 72 | - * | |
| 73 | - * @var PLL_Admin_Filters_Media | |
| 45 | + * @var PLL_Admin_Block_Editor|null | |
| 74 | 46 | */ |
| 75 | - public $filters_media; | |
| 47 | + public $block_editor; | |
| 76 | 48 | |
| 77 | 49 | /** |
| 78 | - * Instance of PLL_Filters_Sanitization | |
| 79 | - * | |
| 80 | - * @since 2.9 | |
| 81 | - * | |
| 82 | - * @var PLL_Filters_Sanitization | |
| 50 | + * @var PLL_Admin_Classic_Editor|null | |
| 83 | 51 | */ |
| 84 | - public $filters_sanitization; | |
| 52 | + public $classic_editor; | |
| 85 | 53 | |
| 86 | 54 | /** |
| 87 | - * Loads the polylang text domain | |
| 88 | - * Setups filters and action needed on all admin pages and on plugins page | |
| 55 | + * @var PLL_Admin_Nav_Menu|null | |
| 56 | + */ | |
| 57 | + public $nav_menu; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * @var PLL_Admin_Filters_Widgets_Options|null | |
| 61 | + */ | |
| 62 | + public $filters_widgets_options; | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * Setups filters and action needed on all admin pages and on plugins page. | |
| 89 | 66 | * |
| 90 | 67 | * @since 1.2 |
| 91 | 68 | * |
| 92 | - * @param object $links_model | |
| 69 | + * @param PLL_Links_Model $links_model Reference to the links model. | |
| 93 | 70 | */ |
| 94 | 71 | public function __construct( &$links_model ) { |
| 95 | 72 | parent::__construct( $links_model ); |
| 96 | 73 | |
| @@ -115,14 +92,14 @@ | ||
| 115 | 92 | } |
| 116 | 93 | } |
| 117 | 94 | |
| 118 | 95 | /** |
| 119 | - * Adds a 'settings' link in the plugins table | |
| 96 | + * Adds a 'settings' link for our plugin in the plugins list table. | |
| 120 | 97 | * |
| 121 | 98 | * @since 0.1 |
| 122 | 99 | * |
| 123 | - * @param array $links list of links associated to the plugin | |
| 124 | - * @return array modified list of links | |
| 100 | + * @param string[] $links List of links associated to the plugin. | |
| 101 | + * @return string[] Modified list of links. | |
| 125 | 102 | */ |
| 126 | 103 | public function plugin_action_links( $links ) { |
| 127 | 104 | array_unshift( $links, '<a href="admin.php?page=mlang">' . __( 'Settings', 'polylang' ) . '</a>' ); |
| 128 | 105 | return $links; |
| @@ -134,8 +111,9 @@ | ||
| 134 | 111 | * @since 1.1.6 |
| 135 | 112 | * |
| 136 | 113 | * @param array $plugin_data Not used |
| 137 | 114 | * @param object $r Plugin update data |
| 115 | + * @return void | |
| 138 | 116 | */ |
| 139 | 117 | public function plugin_update_message( $plugin_data, $r ) { |
| 140 | 118 | if ( isset( $r->upgrade_notice ) ) { |
| 141 | 119 | printf( '<p style="margin: 3px 0 0 0; border-top: 1px solid #ddd; padding-top: 3px">%s</p>', esc_html( $r->upgrade_notice ) ); |
| @@ -146,11 +124,14 @@ | ||
| 146 | 124 | * Setup filters for admin pages |
| 147 | 125 | * |
| 148 | 126 | * @since 1.2 |
| 149 | 127 | * @since 2.7 instantiate a PLL_Bulk_Translate instance. |
| 128 | + * @return void | |
| 150 | 129 | */ |
| 151 | 130 | public function add_filters() { |
| 152 | 131 | $this->filters_sanitization = new PLL_Filters_Sanitization( $this->get_locale_for_sanitization() ); |
| 132 | + $this->filters_widgets_options = new PLL_Admin_Filters_Widgets_Options( $this ); | |
| 133 | + | |
| 153 | 134 | // All these are separated just for convenience and maintainability |
| 154 | 135 | $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Classic_Editor', 'Block_Editor' ); |
| 155 | 136 | |
| 156 | 137 | // Don't load media filters if option is disabled or if user has no right |
| @@ -171,8 +152,9 @@ | ||
| 171 | 152 | $class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class ); |
| 172 | 153 | $this->$obj = new $class( $this ); |
| 173 | 154 | } |
| 174 | 155 | } |
| 156 | + | |
| 175 | 157 | /** |
| 176 | 158 | * Retrieve the locale according to the current language instead of the language |
| 177 | 159 | * of the admin interface. |
| 178 | 160 | * |