PluginProbe
Themify Builder / 7.7.0
Themify Builder v7.7.0
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / includes / plugin-compat / wpml.php

wpml.php in Themify Builder 7.7.0, at includes/plugin-compat/wpml.php

53 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Builder Plugin Compatibility Code
4 *
5 * @package Themify_Builder
6 * @subpackage Themify_Builder/classes
7 */
8
9 class Themify_Builder_Plugin_Compat_WPML {
10
11 static function init() {
12 add_action( 'wp_ajax_themify_builder_icl_copy_from_original', array( __CLASS__, 'icl_copy_from_original' ) );
13 add_filter( 'get_translatable_documents', array( __CLASS__, 'get_translatable_documents' ) );
14 }
15
16 /**
17 * Load Builder content from original page when "Copy content" feature in WPML is used
18 *
19 * @access public
20 * @since 1.4.3
21 */
22 public static function icl_copy_from_original() {
23
24 if ( isset( $_POST['source_page_id'],$_POST['source_page_lang'] ) && current_user_can( 'edit_post', $_POST['source_page_id'] ) ) {
25 global $wpdb;
26 $post_id = $wpdb->get_var(
27 $wpdb->prepare(
28 "SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE trid='%d' AND language_code='%s' LIMIT 1",
29 $_POST[ 'source_page_id' ],
30 $_POST[ 'source_page_lang' ]
31 )
32 );
33 $post = ! empty( $post_id ) ? get_post( $post_id ) : null;
34 if ( ! empty( $post ) ) {
35 $builder_data = ThemifyBuilder_Data_Manager::get_data( $post->ID );
36 wp_send_json_success($builder_data);
37 }
38 wp_send_json_error('');
39 }
40 die;
41 }
42
43 /**
44 * Disable translation on some post types
45 *
46 * @return array
47 */
48 public static function get_translatable_documents(array $translatable_post_types=array() ):array {
49 unset( $translatable_post_types[Themify_Global_Styles::SLUG],$translatable_post_types['tb_cf'], $translatable_post_types['tbp_theme'] );
50
51 return $translatable_post_types;
52 }
53 }