PluginProbe
Translation with DeepL API / 1.0
Translation with DeepL API v1.0
trunk 0.1.20180323 1.0 1.2.5.1 1.5.2.5 1.7.5 2.4.3.12 2.4.3.9 2.4.5
wpdeepl / admin / deepl-admin-hooks.php

deepl-admin-hooks.php in Translation with DeepL API 1.0, at admin/deepl-admin-hooks.php

55 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 add_action( 'init', 'deepl_init_admin' );
4 function deepl_init_admin() {
5 if( !is_admin() ) {
6 return;
7 }
8
9 if( DeepLConfiguration::isPluginInstalled() === false ) {
10 deepl_install_plugin();
11 }
12
13 global $WP_Improved_Settings_DeepL;
14
15 if( !$WP_Improved_Settings_DeepL ) {
16 $WP_Improved_Settings_DeepL = new WP_Improved_Settings_DeepL();
17 }
18
19 global $DeepL_Metabox;
20 $DeepL_Metabox = new DeepL_Metabox();
21 }
22
23 add_action( 'admin_enqueue_scripts', 'deepl_load_admin_javascript' );
24 function deepl_load_admin_javascript( $hook ) {
25 if( $hook == 'settings_page_deepl_settings' ) {
26 wp_enqueue_style( 'deepl_admin', WPDEEPL_URL . '/assets/deepl-admin.css', array(), WPDEEPL_VERSION );
27 }
28 if( $hook == 'settings_page_deepl_settings' || $hook == 'post.php' ) {
29 wp_enqueue_script( 'deepl_admin', trailingslashit( WPDEEPL_URL ) . 'assets/deepl-metabox.js' );
30 }
31 }
32
33 //add_filter( 'post_row_actions', 'wpdeepl_modify_list_row_actions', 10, 2 );
34 function wpdeepl_modify_list_row_actions( $actions, $post ) {
35 // Check for your post type.
36 $post_types = DeepLConfiguration::getMetaBoxPostTypes();
37
38 if ( in_array( $post->post_type, $post_types )) {
39 // Build your links URL.
40 $url = admin_url( 'admin.php?page=mycpt_page&post=' . $post->ID );
41
42 // Maybe put in some extra arguments based on the post status.
43 $edit_link = add_query_arg( array( 'action' => 'edit' ), $url );
44
45 // The default $actions passed has the Edit, Quick-edit and Trash links.
46 $actions['translate'] = sprintf(
47 '<a href="%1$s">%2$s</a>',
48 esc_url( $edit_link ),
49 'Test'
50 );
51 }
52 plouf( $actions );
53 return $actions;
54 }
55