PluginProbe
Translation with DeepL API / 2.4.5
Translation with DeepL API v2.4.5
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
← All changes | admin/deepl-admin-hooks.php +16 -14 1.7.52.4.5 View file →
@@ -1,19 +1,19 @@
1 1 <?php
2 2
3 -add_action( 'init', 'deepl_init_admin' );
3 +add_action( 'init', 'deepl_init_admin', 40 );
4 4 function deepl_init_admin() {
5 - if( !is_admin() ) {
5 + if ( !is_admin() ) {
6 6 return;
7 7 }
8 8
9 - if( DeepLConfiguration::isPluginInstalled() === false ) {
9 + if ( DeepLConfiguration::isPluginInstalled() === false ) {
10 10 deepl_install_plugin();
11 11 }
12 12
13 13 global $WP_Improved_Settings_DeepL;
14 14
15 - if( !$WP_Improved_Settings_DeepL ) {
15 + if ( !$WP_Improved_Settings_DeepL ) {
16 16 $WP_Improved_Settings_DeepL = new WP_Improved_Settings_DeepL();
17 17 }
18 18
19 19 global $DeepL_Metabox;
@@ -19,16 +19,18 @@
19 19 global $DeepL_Metabox;
20 20 $DeepL_Metabox = new DeepL_Metabox();
21 21 }
22 22
23 +
23 24 add_action( 'admin_enqueue_scripts', 'deepl_load_admin_javascript' );
24 25 function deepl_load_admin_javascript( $hook ) {
25 - if( $hook == 'settings_page_deepl_settings' ) {
26 +
27 + if ( $hook == 'settings_page_deepl_settings' ) {
26 28 wp_enqueue_style( 'deepl_admin', WPDEEPL_URL . '/assets/deepl-admin.css', array(), WPDEEPL_VERSION );
27 29 }
28 - if( $hook == 'settings_page_deepl_settings' || $hook == 'post.php' ) {
29 - wp_enqueue_script( 'deepl_admin', trailingslashit( WPDEEPL_URL ) . 'assets/deepl-metabox.js' );
30 - wp_localize_script( 'deepl_admin', 'DeepLStrings', deepl_get_localized_strings() );
30 + if ( $hook == 'settings_page_deepl_settings' || $hook == 'post.php' || $hook == 'post-new.php' ) {
31 + wp_enqueue_script( 'deepl_admin', trailingslashit( WPDEEPL_URL ) . 'assets/deepl-metabox.js' );
32 + wp_localize_script( 'deepl_admin', 'DeepLStrings', deepl_get_localized_strings() );
31 33 }
32 34 }
33 35
34 36 function deepl_get_localized_strings() {
@@ -40,9 +42,9 @@
40 42
41 43 add_action('admin_footer', 'deepl_admin_footer');
42 44 function deepl_admin_footer() {
43 45
44 - if( get_current_screen()->base != 'settings_page_deepl_settings' ) {
46 + if ( get_current_screen()->base != 'settings_page_deepl_settings' ) {
45 47 return;
46 48 }
47 49 ?>
48 50 <script>
@@ -49,9 +51,9 @@
49 51 jQuery(document).ready(function() {
50 52
51 53 var behaviours_notice = jQuery('input[name="wpdeepl_metabox_behaviour"]').parent().find('p.description');
52 54 var usingMultilingualPlugins = <?php echo DeeplConfiguration::usingMultilingualPlugins() ? 1 : 0; ?>;
53 - if( !usingMultilingualPlugins ) {
55 + if ( !usingMultilingualPlugins ) {
54 56
55 57 jQuery('#wpdeepl_metabox_behaviour_append').attr('disabled','disabled');
56 58 jQuery(behaviours_notice).show();
57 59 }
@@ -62,9 +64,9 @@
62 64
63 65 });
64 66 </script>
65 67
66 - <?php
68 + <?php
67 69 }
68 70
69 71 //add_filter( 'post_row_actions', 'wpdeepl_modify_list_row_actions', 10, 2 );
70 72 function wpdeepl_modify_list_row_actions( $actions, $post ) {
@@ -72,12 +74,12 @@
72 74 $post_types = DeepLConfiguration::getMetaBoxPostTypes();
73 75
74 76 if ( in_array( $post->post_type, $post_types )) {
75 77 // Build your links URL.
76 - $url = admin_url( 'admin.php?page=mycpt_page&post=' . $post->ID );
78 + $url = admin_url( 'admin.php?page=deepl&post=' . $post->ID );
77 79
78 80 // Maybe put in some extra arguments based on the post status.
79 - $edit_link = add_query_arg( array( 'action' => 'edit' ), $url );
81 + if( $url ) $edit_link = add_query_arg( array( 'action' => 'edit' ), $url );
80 82
81 83 // The default $actions passed has the Edit, Quick-edit and Trash links.
82 84 $actions['translate'] = sprintf(
83 85 '<a href="%1$s">%2$s</a>',
@@ -84,7 +86,7 @@
84 86 esc_url( $edit_link ),
85 87 'Test'
86 88 );
87 89 }
88 - plouf( $actions );
90 + //plouf( $actions );
89 91 return $actions;
90 92 }