PLL_Admin

Admin side controller accessible in $polylang global object.

Defined (1)

The class is defined in the following location(s).

/admin/admin.php  
  1. class PLL_Admin extends PLL_Admin_Base { 
  2. public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media; 
  3.  
  4. /** 
  5. * loads the polylang text domain 
  6. * setups filters and action needed on all admin pages and on plugins page 
  7. * @since 1.2 
  8. * @param object $links_model 
  9. */ 
  10. public function __construct( &$links_model ) { 
  11. parent::__construct( $links_model ); 
  12.  
  13. // adds a 'settings' link in the plugins table 
  14. add_filter( 'plugin_action_links_' . POLYLANG_BASENAME, array( $this, 'plugin_action_links' ) ); 
  15. add_action( 'in_plugin_update_message-' . POLYLANG_BASENAME, array( $this, 'plugin_update_message' ), 10, 2 ); 
  16.  
  17. /** 
  18. * setups filters and action needed on all admin pages and on plugins page 
  19. * loads the settings pages or the filters base on the request 
  20. * @since 1.2 
  21. * @param object $links_model 
  22. */ 
  23. public function init() { 
  24. parent::init(); 
  25.  
  26. // setup filters for admin pages 
  27. // priority 5 to make sure filters are there before customize_register is fired 
  28. if ( $this->model->get_languages_list() ) { 
  29. add_action( 'wp_loaded', array( $this, 'add_filters' ), 5 ); 
  30.  
  31. /** 
  32. * adds a 'settings' link in the plugins table 
  33. * @since 0.1 
  34. * @param array $links list of links associated to the plugin 
  35. * @return array modified list of links 
  36. */ 
  37. public function plugin_action_links( $links ) { 
  38. array_unshift( $links, '<a href="admin.php?page=mlang">' . __( 'Settings', 'polylang' ) . '</a>' ); 
  39. return $links; 
  40.  
  41. /** 
  42. * adds the upgrade notice in plugins table 
  43. * @since 1.1.6 
  44. * @param array $plugin_data not used 
  45. * @param object $r plugin update data 
  46. */ 
  47. function plugin_update_message( $plugin_data, $r ) { 
  48. if ( isset( $r->upgrade_notice ) ) { 
  49. printf( '<p style="margin: 3px 0 0 0; border-top: 1px solid #ddd; padding-top: 3px">%s</p>', esc_html( $r->upgrade_notice ) ); 
  50.  
  51. /** 
  52. * setup filters for admin pages 
  53. * @since 1.2 
  54. */ 
  55. public function add_filters() { 
  56. // all these are separated just for convenience and maintainability 
  57. $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync' ); 
  58.  
  59. // don't load media filters if option is disabled or if user has no right 
  60. 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 ) ) ) { 
  61. $classes[] = 'Filters_Media'; 
  62.  
  63. foreach ( $classes as $class ) { 
  64. $obj = strtolower( $class ); 
  65.  
  66. /** 
  67. * Filter the class to instantiate when loding admin filters 
  68. * @since 1.5 
  69. * @param string $class class name 
  70. */ 
  71. $class = apply_filters( 'pll_' . $obj, 'PLL_Admin_' . $class ); 
  72. $this->$obj = new $class( $this );