_add_json() {
if ( ! is_admin() ) {
return false;
}
if ( is_network_admin() && Helper::is_plugin_active_for_network() ) {
return Param::get( 'page' ) === 'rank-math';
}
return Param::get( 'page' ) === 'rank-math-status';
}
/**
* Check if assets should be enqueued on current admin page.
*
* @param string $hook Page hook name.
* @return bool Whether we should proceed with the enqueue functions.
*/
private function should_enqueue( $hook ) {
if ( is_network_admin() && Helper::is_plugin_active_for_network() ) {
return 'toplevel_page_rank-math' === $hook;
}
return 'rank-math_page_rank-math-status' === $hook;
}
/**
* Replace Admin_Helper::get_view() output for the network admin tab.
*
* @param string $file File path.
* @param string $view Requested view.
* @return string New file path.
*/
public function network_admin_view( $file, $view ) {
if ( 'version_control' === Param::get( 'view' ) && is_network_admin() && Helper::is_plugin_active_for_network() ) {
return dirname( __FILE__ ) . '/display.php';
}
return $file;
}
/**
* Filter top nav links in the dashboard.
*
* @param array $nav_links Nav links.
* @return array New nav links.
*/
public function network_admin_dashboard_tabs( $nav_links ) {
if ( ! is_network_admin() ) {
return $nav_links;
}
if ( empty( $nav_links ) ) {
$nav_links = [
'help' => [
'id' => 'help',
'url' => '',
'args' => '',
'cap' => 'manage_options',
'title' => esc_html__( 'Dashboard', 'rank-math' ),
],
];
}
$nav_links['version_control'] = [
'id' => 'version_control',
'url' => '',
'args' => 'view=version_control',
'cap' => 'manage_options',
'title' => esc_html__( 'Version Control', 'rank-math' ),
];
return $nav_links;
}
/**
* Add subpage to Status & Tools screen.
*
* @param array $pages Pages.
* @return array New pages.
*/
public function add_status_page( $pages ) {
$pages['version_control'] = [
'url' => 'status',
'args' => 'view=version_control',
'cap' => 'install_plugins',
'title' => __( 'Version Control', 'rank-math' ),
'class' => '\\RankMath\\Version_Control',
];
return $pages;
}
/**
* Change default tab on the Status & Tools screen.
*
* @param string $default Default tab.
* @return string New default tab.
*/
public function change_default_tab( $default ) {
if ( is_multisite() && ! current_user_can( 'setup_network' ) ) {
return $default;
}
return 'version_control';
}
/**
* Enqueue CSS & JS.
*
* @param string $hook Page hook name.
* @return void
*/
public function enqueue( $hook ) {
if ( ! $this->should_enqueue( $hook ) ) {
return;
}
$uri = untrailingslashit( plugin_dir_url( __FILE__ ) );
wp_enqueue_style( 'rank-math-cmb2' );
wp_enqueue_style( 'rank-math-version-control', $uri . '/assets/css/version-control.css', [], rank_math()->version );
wp_enqueue_script( 'rank-math-version-control', $uri . '/assets/js/version-control.js', [ 'jquery' ], rank_math()->version, true );
}
/**
* Get Rank Math plugin information.
*
* @return mixed Plugin information array or false on fail.
*/
public static function get_plugin_info() {
$cache = get_transient( self::TRANSIENT );
if ( $cache ) {
return $cache;
}
$request = wp_remote_get( self::API_URL, [ 'timeout' => 20 ] );
if ( ! is_wp_error( $request ) && is_array( $request ) ) {
$response = json_decode( $request['body'], true );
set_transient( self::TRANSIENT, $response, ( 12 * HOUR_IN_SECONDS ) );
return $response;
}
return false;
}
/**
* Get plugin data to use in the `update_plugins` transient.
*
* @param string $version New version.
* @param string $package New version download URL.
* @return array An array of plugin metadata.
*/
public static function get_plugin_data( $version, $package ) {
return [
'id' => 'w.org/plugins/seo-by-rank-math',
'slug' => 'seo-by-rank-math',
'plugin' => 'seo-by-rank-math/rank-math.php',
'new_version' => $version,
'url' => 'https://wordpress.org/plugins/seo-by-rank-math/',
'package' => $package,
'icons' =>
[
'2x' => 'https://ps.w.org/seo-by-rank-math/assets/icon-256x256.png?rev=2034417',
'1x' => 'https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=2034417',
'svg' => 'https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=2034417',
],
'banners' =>
[
'2x' => 'https://ps.w.org/seo-by-rank-math/assets/banner-1544x500.png?rev=2034417',
'1x' => 'https://ps.w.org/seo-by-rank-math/assets/banner-772x250.png?rev=2034417',
],
'banners_rtl' => [],
];
}
/**
* Display forms.
*/
public function display() {
$directory = dirname( __FILE__ );
include_once $directory . '/display.php';
}
}
درمان خروپف بعد از عمل جراحی بینی - درمان خروپف
پرش به محتوا
wpDiscuz
افکار شما را دوست داریم، لطفا نظر دهید.
x
Insert
پیمایش به بالا