PluginProbe
Polylang / 1.9.2
Polylang v1.9.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / admin / admin.php

admin.php in Polylang 1.9.2, at admin/admin.php

118 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * admin side controller
5 * accessible in $polylang global object
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 => inherited, reference to PLL_Admin_Links object
12 * static_pages => inherited, reference to PLL_Admin_Static_Pages object
13 * filters_links => inherited, reference to PLL_Filters_Links object
14 * curlang => inherited, optional, current language used to filter admin content
15 * pref_lang => inherited, preferred language used as default when saving posts or terms
16 * filters => reference to PLL_Filters object
17 * filters_columns => reference to PLL_Admin_Filters_Columns object
18 * filters_post => reference to PLL_Admin_Filters_Post object
19 * filters_term => reference to PLL_Admin_filters_Term object
20 * nav_menu => reference to PLL_Admin_Nav_Menu object
21 * filters_media => optional, reference to PLL_Admin_Filters_Media object
22 *
23 * @since 1.2
24 */
25 class PLL_Admin extends PLL_Admin_Base {
26 public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media;
27
28 /**
29 * loads the polylang text domain
30 * setups filters and action needed on all admin pages and on plugins page
31 *
32 * @since 1.2
33 *
34 * @param object $links_model
35 */
36 public function __construct( &$links_model ) {
37 parent::__construct( $links_model );
38
39 // adds a 'settings' link in the plugins table
40 add_filter( 'plugin_action_links_' . POLYLANG_BASENAME, array( &$this, 'plugin_action_links' ) );
41 add_action( 'in_plugin_update_message-' . POLYLANG_BASENAME, array( &$this, 'plugin_update_message' ), 10, 2 );
42 }
43
44 /**
45 * setups filters and action needed on all admin pages and on plugins page
46 * loads the settings pages or the filters base on the request
47 *
48 * @since 1.2
49 *
50 * @param object $links_model
51 */
52 public function init() {
53 parent::init();
54
55 // setup filters for admin pages
56 // priority 5 to make sure filters are there before customize_register is fired
57 if ( $this->model->get_languages_list() ) {
58 add_action( 'wp_loaded', array( &$this, 'add_filters' ), 5 );
59 }
60 }
61
62 /**
63 * adds a 'settings' link in the plugins table
64 *
65 * @since 0.1
66 *
67 * @param array $links list of links associated to the plugin
68 * @return array modified list of links
69 */
70 public function plugin_action_links( $links ) {
71 array_unshift( $links, '<a href="admin.php?page=mlang">' . __( 'Settings', 'polylang' ) . '</a>' );
72 return $links;
73 }
74
75 /**
76 * adds the upgrade notice in plugins table
77 *
78 * @since 1.1.6
79 *
80 * @param array $plugin_data not used
81 * @param object $r plugin update data
82 */
83 function plugin_update_message( $plugin_data, $r ) {
84 if ( isset( $r->upgrade_notice ) ) {
85 printf( '<p style="margin: 3px 0 0 0; border-top: 1px solid #ddd; padding-top: 3px">%s</p>', esc_html( $r->upgrade_notice ) );
86 }
87 }
88
89 /**
90 * setup filters for admin pages
91 *
92 * @since 1.2
93 */
94 public function add_filters() {
95 // all these are separated just for convenience and maintainability
96 $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync' );
97
98 // don't load media filters if option is disabled or if user has no right
99 if ( $this->options['media_support'] && ( $obj = get_post_type_object( 'attachment' ) ) && ( current_user_can( $obj->cap->edit_posts ) || current_user_can( $obj->cap->create_posts ) ) ) {
100 $classes[] = 'Filters_Media';
101 }
102
103 foreach ( $classes as $class ) {
104 $obj = strtolower( $class );
105
106 /**
107 * Filter the class to instantiate when loding admin filters
108 *
109 * @since 1.5
110 *
111 * @param string $class class name
112 */
113 $class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class );
114 $this->$obj = new $class( $this );
115 }
116 }
117 }
118