first commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package wpml-core
|
||||
*/
|
||||
class WPML_UI_Help_Tab {
|
||||
private $wp_api;
|
||||
private $id;
|
||||
private $title;
|
||||
private $content;
|
||||
|
||||
public function __construct( WPML_WP_API $wp_api, $id, $title, $content ) {
|
||||
$this->wp_api = $wp_api;
|
||||
$this->id = $id;
|
||||
$this->title = $title;
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function init_hooks() {
|
||||
$this->wp_api->add_action( 'admin_head', array( $this, 'add_help_tab' ) );
|
||||
}
|
||||
|
||||
public function add_help_tab() {
|
||||
$screen = $this->wp_api->get_current_screen();
|
||||
|
||||
if ( null !== $screen ) {
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'content' => $this->content,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* @package wpml-core
|
||||
*/
|
||||
|
||||
class WPML_UI_Pagination extends WP_List_Table {
|
||||
public function __construct( $total, $number_per_page ) {
|
||||
parent::__construct();
|
||||
|
||||
$this->set_pagination_args(
|
||||
array(
|
||||
'total_items' => $total,
|
||||
'per_page' => $number_per_page,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$this->pagination( 'bottom' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package wpml-core
|
||||
*/
|
||||
class WPML_UI_Screen_Options_Factory {
|
||||
|
||||
/** @var SitePress $sitepress */
|
||||
private $sitepress;
|
||||
|
||||
public function __construct( SitePress $sitepress ) {
|
||||
$this->sitepress = $sitepress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option_name
|
||||
* @param int $default_per_page
|
||||
*
|
||||
* @return WPML_UI_Screen_Options_Pagination
|
||||
*/
|
||||
public function create_pagination( $option_name, $default_per_page ) {
|
||||
$pagination = new WPML_UI_Screen_Options_Pagination( $option_name, $default_per_page );
|
||||
$pagination->init_hooks();
|
||||
|
||||
return $pagination;
|
||||
}
|
||||
|
||||
public function create_help_tab( $id, $title, $content ) {
|
||||
$help_tab = new WPML_UI_Help_Tab( $this->sitepress->get_wp_api(), $id, $title, $content );
|
||||
$help_tab->init_hooks();
|
||||
|
||||
return $help_tab;
|
||||
}
|
||||
|
||||
public function create_admin_table_sort() {
|
||||
return new WPML_Admin_Table_Sort();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package wpml-core
|
||||
*/
|
||||
class WPML_UI_Screen_Options_Pagination {
|
||||
/**
|
||||
* @var string $option_name
|
||||
*/
|
||||
private $option_name;
|
||||
/**
|
||||
* @var int $default_per_page
|
||||
*/
|
||||
private $default_per_page;
|
||||
|
||||
/**
|
||||
* WPML_UI_Screen_Options_Pagination constructor.
|
||||
*
|
||||
* @param string $option_name
|
||||
* @param int $default_per_page
|
||||
*/
|
||||
public function __construct( $option_name, $default_per_page ) {
|
||||
$this->option_name = $option_name;
|
||||
$this->default_per_page = $default_per_page;
|
||||
}
|
||||
|
||||
public function init_hooks() {
|
||||
add_action( 'admin_head', array( $this, 'add_screen_options' ) );
|
||||
add_filter( 'set-screen-option', array( $this, 'set_screen_options_filter' ), 10, 3 );
|
||||
add_filter( 'set_screen_option_' . $this->option_name, [ $this, 'set_screen_options_filter' ], 10, 3 );
|
||||
}
|
||||
|
||||
public function add_screen_options() {
|
||||
add_screen_option(
|
||||
'per_page',
|
||||
array(
|
||||
'default' => $this->default_per_page,
|
||||
'option' => $this->option_name,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function set_screen_options_filter( $value, $option, $set_value ) {
|
||||
|
||||
return $option === $this->option_name ? $set_value : $value;
|
||||
}
|
||||
|
||||
public function get_items_per_page() {
|
||||
$page_size = (int) get_user_option( $this->option_name );
|
||||
if ( ! $page_size ) {
|
||||
$page_size = $this->default_per_page;
|
||||
}
|
||||
|
||||
return $page_size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
class WPML_UI_Unlock_Button {
|
||||
|
||||
public function render( $disabled, $unlocked, $radio_name, $unlocked_name ) {
|
||||
if ( $disabled && ! $unlocked ) { ?>
|
||||
<button type="button"
|
||||
class="button-secondary wpml-button-lock js-wpml-sync-lock"
|
||||
title="<?php esc_html_e( 'This setting is controlled by a wpml-config.xml file. Click here to unlock and override this setting.', 'sitepress' ); ?>"
|
||||
data-radio-name="<?php echo $radio_name; ?>"
|
||||
data-unlocked-name="<?php echo $unlocked_name; ?>">
|
||||
<i class="otgs-ico-lock"></i>
|
||||
</button>
|
||||
<?php } ?>
|
||||
|
||||
<input type="hidden" name="<?php echo $unlocked_name; ?>" value="<?php echo $unlocked ? '1' : '0'; ?>">
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user