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